GLADTEX(1)
okay bestie, come sit with me, we're reading gladtex(1) together π it's giving "LaTeX in your HTML, but make it cute", and honestly? obsessed.
πΈ NAME πΈ
GladTeX β generate HTML with LaTeX formulas embedded as images. yep, that's the whole job description π
β¨ SYNOPSIS β¨
gladtex OPTIONS
π¦ DESCRIPTION π¦
GladTeX is a formula preprocessor for HTML files. it recognizes a special tag, <eq>...</eq>, that marks formulas for conversion. the converted vector images get integrated straight into the output HTML document. this eases the process of creating HTML documents (or web sites) containing formulas β no cap π«Ά
the generated images are saved in a cache so it doesn't 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. literally saving you time while you vibe π
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. accessibility? we love to see it π
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. iykyk β¨
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.
π OPTIONS π
INPUT FILE NAMEβ the input.htexfile with LaTeX formulas (if it's omitted or it's-, stdin will be read).-h,--helpβ show this help message and exit. short and sweet π-aβ save text alternatives for images which are too long for thealtattribute into a single separate file, and link images to it.-b BACKGROUND_COLORβ set the background color for the resulting images (default transparent). GladTeX understands colors as provided by thedvipsoption of thexcolorLaTeX package. alternatively, a 6-digit hexadecimal value can be provided (as used e.g. in HTML/CSS).-c FOREGROUND_COLORβ set the foreground color for the resulting images. see the option above for a more in-depth explanation.-d DIRECTORYβ the directory in which to store the generated images in (relative path).
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.
-e LATEX_MATHS_ENVβ set a custom maths environment to surround the formula (e.g.flalign).-E ENCODINGβ overwrite the encoding to use (defaultUTF-8).-f FONTSIZEβ overwrite the default font size of12pt.12ptis the default in most browsers, and hence changing this might lead to less-portable documents. π«£-i CLASSβ the CSS class to assign to inline math (default:inlinemath).-Kβ keep the LaTeX file(s) when converting formulas.
by default, the generated LaTeX document, containing the formula to be converted, is 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.
-l CLASSβ the CSS class to assign to block-level math (default:displaymath).-nβ purge unreadable caches along with alleqn*.pngfiles.
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.
-mβ print error output in machine-readable format (less concise, better parseable).
each line will start with a key, followed by a colon, followed by the value, i.e. line: 5.
-o FILENAMEβ set the output file name.-will print text to stdout. by default, the input file name is used and the.htexextension is replaced by.html.-p LATEX_STATEMENTβ add the given LaTeX code to the preamble of the document. that'll affect the conversion of every image.-Pβ act as a pandoc filter. in this mode, input is expected to be a Pandoc JSON AST and the output will be a modified AST, with all formulas replaced through HTML image tags. it makes sense to use-as the input file for this option.--pngβ switch from SVG to PNG as image output. this image has several known issues, one of them being that images won't resize when zooming into the document. it is also harder to work with for visually impaired users. π-r DPIβ set resolution (size of images) todpi(115by default). this is only available with the--pngoption. also see the-foption.-Rβ replace non-ascii (unicode) characters by LaTeX commands.
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 the alt text from the image is not exactly the same as 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.
-u URLβ base URL to image files (relative links are default).
π FILE FORMAT π
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>. periodt β¨
π ENVIRONMENT VARIABLES π
GladTeX can be customised by environment variables:
DEBUGβ if this is set to1, a full Python traceback, instead of a human-readable error message, will be displayed.GLADTEX_ARGSβ when this environment variable is set, GladTeX switches into pandoc filter mode: input is read from standard input, output written to standard output and the-Pswitch is assumed. the contents of this variable [are] parsed as command-line switches. see an example inOutput As EPUB#output-asepub).
π EXAMPLES π
Sample HTEX document
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. main character energy fr fr π₯
Markdown To HTML
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 -
Output as EPUB
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
π KNOWN LIMITATIONS π
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:
- look up the symbol in one of the many LaTeX formula listings and replace the symbol with the appropriate command.
- use the
-rswitch to let GladTeX replace the umlauts for you.
PLEASE NOTE: it is impossible to use GladTeX with LuaLaTeX. at the time of writing,dvipngdoes not support the extended font features of thelualatexengine. rip π
π§ PROJECT HOME π§
the project home is at <http://humenda.github.io/GladTeX>. the source can be found at <https://github.com/humenda/gladtex>.
π AUTHORS π
Sebastian Humenda.
and that's the whole page, bestie π«Ά this version of the gladtex(1) manual is dated the 8th of September 2018 β go forth and make formula-filled HTML, you absolute icon πβ¨
π¦ where this page comes from
- debian bookworm: gladtex 3.1.0-2 Β· LGPL-3.0-or-later
- debian trixie: gladtex 3.1.0-2 Β· LGPL-3.0-or-later
- ubuntu jammy: gladtex 3.1.0-2 Β· LGPL-3.0-or-later
- ubuntu noble: gladtex 3.1.0-2 Β· LGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms