GLADTEX(1) | GLADTEX(1) |
GladTeX - generate HTML with LaTeX formulas embedded as images
gladtex OPTIONS
GladTeX is a formula preprocessor for HTML files. It recognizes a special tag (<eq>...</eq>) marking formulas for conversion. The converted vector images are integrated into the output HTML document. This eases the process of creating HTML documents (or web sites) containing formulas.
The generated images are saved in a cache to not render the same image over and over again. This speeds up the process when formulas occur multiple times or when a document is extended gradually.
The LaTeX formulas are preserved in the alt attribute of the embedded images, hence screen reader users benefit from an accessible HTML version of the document.
Furthermore it can be used with Pandoc to convert Markdown documents and other formats with LaTeX formulas to HTML, EPUB and in fact to any HTML-based format, see the option -P.
See FILE FORMAT for an explanation of the file format and EXAMPLES for examples on how to use GladTeX on its own or with Pandoc.
The given path is interpreted relatively to the input file. For instance,:
gladtex -d img dir/file.htex
will create a dir/img directory and link accordingly in x/file.htex.
By default, the generated LaTeX document, containing the formula to be converted, are removed after the conversion (no matter whether it was successful or not). If it wasn’t successful, it is sometimes helpful to look at the complete document. This option will keep the file.
Caches can be unreadable if the used GladTeX version is incompatible. If this option is unset, GladTeX will simply fail when the cache is unreadable.
Each line will start with a key, followed by a colon, followed by the value, i.e. line: 5.
GladTeX can automatically detect non-ascii characters in formulas and replace them through their appropriate LaTeX commands. In the alt attribute of the resulting image, alphabetical characters won’t be replaced. That means that the alt text from the image is not exactly the same than the code used for generating the image, but it is far more readable.
For instance, the formula $\text{für alle} a$, would be compiled as $\text{f\ddot{u}r alle} a$ and displayed as “\text{für alle} a” in the alt attribute.
A .htex file is essentially a HTML file containing LaTeX formulas. The formulas have to be surrounded by <eq> and </eq>.
By default, formulas are rendered as inline maths, so they are squeezed to the height of the line. It is possible to render a formula as display maths by setting the env attribute to displaymath, i.e. <eq env="displaymath">...</eq>.
GladTeX can be customised by environment variables:
A sample HTEX document could look like this:
<html><head><!-- meta information like charset --></head> <body> <h1>Some text</h1> <p>Circumference of a circle: <eq>u = \pi\cdot d</eq><p> <p>A useful matrix: <eq env="displaymath">\begin{pmatrix} 1 &2 &3 &4\\ 5 &6 &7 &8\\ 9 &10&11&12 \end{pmatrix}</eq></p> </body></html>
This can be converted using
gladtex file.htex
and the result will be a HTML document called file.html along with two files eqn0000.png and eqn0001.png in the same directory.
GladTeX can be used together with Pandoc. That can be handy to create an online version of a scientific paper written in Markdown. The MarkDown document would look like this:
Some text ========= Circumference of a circle: $u = \pi\cdot d$ A useful matrix: $$\begin{pmatrix} 1 &2 &3 &4\\ 5 &6 &7 &8\\ 9 &10&11&12 \end{pmatrix}$$
The conversion is as easy as typing on the command-line:
pandoc -s -t html --gladtex file.md | gladtex -o file.html -
It is beyond of the scope of this document to introduce Pandoc, but with any input format, converting to EPUB with GladTeX replacing the images is as easy as:
pandoc -t json FILE.ext | gladtex -d img -P - | pandoc -f json -o book.epub
Capitalised parameters should be replaced. This can be used with Markdown as input format, see previous section.
If you want to call Pandoc as a filter without the pipes, you can use the environment variable GLADTEX_ARGS:
GLADTEX_ARGS='-d img' pandoc -o BOOK.EPUB -F gladtex FILE.ext
LaTeX2E is not unicode aware. if you have any unicode (more precisely, non-ascii characters) signs in your documents, you have the choice to do one of the following:
PLEASE NOTE: It is impossible to use GladTeX with LuaLaTeX. At the time of writing, dvipng does not support the extended font features of the lualatex engine.
The project home is at <http://humenda.github.io/GladTeX>. The source can be found at <https://github.com/humenda/gladtex>.
Sebastian Humenda.
8th of September 2018 |