Skip to content

Integrating LaTeXML into TeX editors

Frédéric Wang edited this page Jul 12, 2022 · 5 revisions

TeXworks

TeXworks is an open-source TeX editors available on Linux, Mac and Windows which is packaged with MiKTeX, MacTeX and TeXLive. It is possible to configure your own typesetting engines with TeXworks.

On Linux/Mac, create a file latexmlc-html.sh with the following content:

#!/bin/sh
latexmlc --dest "$1.html" "$1.tex"

and similarly a file latexmlc-epub.sh:

#!/bin/sh
latexmlc --dest "$1.epub" "$1.tex"

On Windows, create two files latexmlc-html.bat and latexmlc-epub.bat:

@latexmlc --dest "%1.html" "%1.tex"

and

@latexmlc --dest "%1.epub" "%1.tex"

Now, in TeXworks go to Edit → Preference → Typesetting. In Processing Tools, add two new LaTeXML HTML5 and LaTeXML EPUB3 modes with the following configuration:

Name: LaTeXML HTML5
Program: latexmlc-html
Arguments: $basename
[ ] View PDF after running

Name: LaTeXML EPUB3
Program: latexmlc-epub
Arguments: $basename
[ ] View PDF after running

These modes will then appear in the drop-down menu of the main toolbar. You can now generate HTML5 and EPUB3 files by selecting the new corresponding LaTeXML mode and clicking on the green "Typeset" button.

Note: LaTeXML does not have non-zero exit status code when a parsing error happens. If you wish to see the result of LaTeXML in the console ouput, you can add a line "exit 1" (Linux/Mac) at then end of the script files.

LyX

In Tools → Preferences → File Handling → File Formats, create two new formats "HTML5" and "EPUB3" with respective short names html5/epub and extensions html/epub. Check the boxes "Document format" & "Show in export menu" and choose your favorite browser/reader as a viewer. For "HTML5", use the same copier as for the existing "HTML" format: python -tt $$s/scripts/ext_copy.py -e html,png,css $$i $$o, so that the files will be copied into one directory.

In Tools → Preferences → File Handling → Converters add two converters from "LaTeX (plain)" to "HTML5" & "EPUB3" respectively. In the Converter field, use the command latexmlc --dest $$o $$i. The LyX interface to export/preview the LaTeX document should now be able to handle the HTML5/EPUB3 formats!

Note: we are working on making these integrated in the default configuration of LyX when LaTeXML is detected on the system

Clone this wiki locally