Integrating LaTeXML into TeX editors

Frédéric Wang edited this page May 20, 2014 · 4 revisions


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 with the following content:

latexmlc --dest "$1.html" "$1.tex"

and similarly a file

latexmlc --dest "$1.epub" "$1.tex"

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

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


@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:

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

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.


LaTeXML currently has a bug with the babel package. So if you want to use LaTeXML with LyX, first disable babel in Tools → Preferences → Languages Settings → Language Package.

Now 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/ -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