In December 2023 arXiv began publishing an HTML version of the papers it receives. After more than thirty years of PDF only, the reason for the change was accessibility, and the converter doing the work is LaTeXML. There are other ways to turn LaTeX into HTML — make4ht (tex4ht), lwarp, pandoc — and the choice really comes down to a single question: does the tool run a real TeX engine, or does it parse LaTeX by itself? Answer that and everything else follows: whether your custom macros survive, whether mathematics arrives as MathML or as pictures, and what becomes of your TikZ figures.
There are only two families of LaTeX-to-HTML converter
One family runs TeX: tex4ht (driven through the front-end make4ht) and lwarp belong here. The other parses LaTeX itself: that is LaTeXML and pandoc. The distinction is not a matter of implementation taste; it decides the quality of the conversion. The TeX-running side lets TeX itself expand the \newcommands you wrote, so custom macros and obscure packages generally come through. The price is a conspicuous trick — watching the typesetting from the side and assembling HTML out of it — and a heavy toolchain. The self-parsing side is fast, produces tidy output and is good at semantic markup, but what it does not know, it does not know. arXiv chose LaTeXML because it wanted the semantic structure of submitted LaTeX — theorems, references, the structure of formulas — carried into HTML and MathML; reproducing the visual page was never the goal.
| Tool | Runs TeX? | Math by default | Where it comes from |
|---|---|---|---|
make4ht | yes, via htlatex | inline as HTML, display as an SVG image | ships with TeX Live |
lwarp | yes, two parallel pdflatex builds | SVG images; MathJax with the mathjax option | ships with TeX Live |
latexml | no — a Perl parser | MathML | a Perl program; not part of TeX Live |
pandoc | no — it lowers LaTeX into its own AST | chosen with --mathml or --mathjax | a Haskell program; not part of TeX Live |
make4ht and tex4ht: the trick of watching TeX from the side
If you have a document in front of you and simply want HTML, the right first move is make4ht file.tex. Nothing extra to install: it comes with TeX Live. The mechanism is audacious. tex4ht lets TeX typeset the document normally while hooks smuggled into the DVI stream emit HTML tags along the way. So a document that compiles usually converts — including the commands you defined yourself with \newcommand, because TeX expands them and the converter never needs to know they existed. Running a test file that defined \newcommand{\stress}[1]{\textbf{\itshape #1}}, the HTML came out with a correctly bold-italic span. tex4ht was written by Eitan Gurari (1947–2009) at Ohio State University, who nursed it alone from 1996. After his sudden death in 2009 Michal Hoftich, Karl Berry and others took it over. The README shipped in TeX Live 2024 still says the documentation was written by Gurari, the original author, and has only been lightly updated since his passing.
# the friendly front-end: HTML5 by default, no options needed
make4ht file.tex
# the classic driver, still what make4ht calls underneath
htlatex file.tex "html5,charset=utf-8" " -cunihtf -utf8"Calling htlatex directly turns up in a lot of older write-ups, but the modern default is make4ht. It is a Lua build front-end by Michal Hoftich: HTML5 out of the box, and a single command that also runs bibtex or makeindex, post-processes the generated HTML and converts images, with a Lua build file for finer control. Even so, tex4ht output can read less like HTML than like a sketch of the typeset page in HTML. By default TeX font names become CSS classes — you will see cmr-12, cmmi-10 and their relatives on individual runs of text — so if the page is going on the web, plan on replacing doc.css or layering your own stylesheet over it. The per-package conversion rules live in .4ht configuration files; tex4ht in TeX Live 2024 ships 496 of them.
Math as MathML, as images, or as MathJax
Plain make4ht file.tex turns inline math into HTML text and display math into an SVG image. Tried on TeX Live 2024, $f\colon \R \to \R$ came out as ordinary text containing ℝ, while the body of \begin{equation} became an image called doc0x.svg whose alt attribute held an ASCII-art approximation of the formula. That default is readable, but it pixelates when enlarged, cannot be copied and will not be found by search. For a document where the mathematics is the point, change the output with an option. make4ht -u file.tex "mathml" produced MathML for display equations too, leaving only the TikZ figure as an image. make4ht -u file.tex "mathjax" leaves the math as LaTeX inside the HTML and puts a window.MathJax configuration plus the MathJax 3 loader in the head.
# display math as an SVG image (the default)
make4ht file.tex
# display math as MathML — only TikZ pictures stay images
make4ht -u file.tex "mathml"
# leave the math as LaTeX and let MathJax 3 render it in the browser
make4ht -u file.tex "mathjax"Here is the trap that only catches people who pick mathjax: your own macros are not expanded. MathML and images are what TeX produced, so \newcommand has of course already been applied; but mathjax mode writes the mathematics out as source. In the test, a document defining \newcommand{\R}{\mathbb{R}} produced HTML containing a literal \(f\colon \R \to \R \), and not one of the \newcommand definitions was emitted alongside it. MathJax in the browser has never heard of \R, so that formula alone turns into a red undefined-macro error. The fix is to repeat the macros in the MathJax configuration (tex.macros inside window.MathJax). Put the other way round: for a document leaning heavily on custom macros, mathml is the safer choice — and for accessibility too, since a screen reader can read MathML but not a picture.
lwarp: typeset the HTML into a PDF, then read it back out
lwarp, by Brian Dunn, attacks the same problem from a completely different angle. It uses LaTeX's own output machinery: pdflatex is made to typeset the HTML source as if it were body text, and pdftotext then pulls that text back out of the resulting PDF into a .html file. That really is the mechanism — read lwarpmk.lua as shipped in TeX Live and you will find the line that calls pdftotext -enc UTF-8 -nopgbrk -layout. For a four-section test document here, the intermediate PDF used for HTML generation ran to 16 pages. There is a reason for the detour: it lets LaTeX's cross-referencing, tables of contents, indexes and bibliographies work exactly as they always do. lwarp carries an HTML-side reimplementation for each package it supports, and TeX Live 2024 ships 593 lwarp-*.sty files.
% lwarp must be loaded BEFORE anything that pulls in color, graphics or hyperref
\documentclass{article}
\usepackage{lwarp}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usepackage{hyperref}
% repeat your own macros for MathJax mode:
% \CustomizeMathJax{\newcommand{\R}{\mathbb{R}}}pdflatex doc.tex # first pass writes lwarpmk.conf and doc_html.tex
lwarpmk html # build the HTML
lwarpmk limages # render the math and picture imagesThe first thing you hit when you actually run it is load order. Putting \usepackage{lwarp} after tikz stopped the build with ! Package lwarp Error: Package color, or one which uses color, must be loaded after Lwarp. lwarp has to be loaded before almost everything else — which is the main obstacle to bolting it onto an existing document. Math becomes SVG images by default, but the alt attribute carries the LaTeX source verbatim and the element gets role="math" (switch to MathJax with \usepackage[mathjax]{lwarp}, and supply your own macros through \CustomizeMathJax). The images are produced by a separate step, lwarpmk limages, which internally runs pdfseparate, then pdfcrop, then pdftocairo -svg — the very pipeline described on this site's page about exporting figures as images.
LaTeXML and the arXiv HTML route
LaTeXML is a Perl converter written by Bruce Miller at the US National Institute of Standards and Technology (NIST). It lowers LaTeX into semantic XML first, then writes HTML5 with MathML, ePub, JATS and more. The work is done in two stages: latexml builds the XML and latexmlpost turns it into HTML. That division separates parsing from presentation, so one XML file can yield several output formats. arXiv's HTML editions, live since December 2023, grew out of the same lineage — the earlier arXivLabs project ar5iv had already been converting the whole corpus with LaTeXML. For math-heavy work where semantics and accessibility matter, it is the first candidate. LaTeXML is not part of TeX Live, however. It has to be installed separately as a Perl distribution; latexml was not present on the machine used for this article, so the two-stage description above follows the official documentation rather than a local run.
# LaTeXML is a separate Perl install, not part of TeX Live
latexml --dest=file.xml file.tex
latexmlpost --dest=file.html file.xml # HTML5 + MathMLHow far do custom macros and TikZ actually get?
Honestly: a document that leans on custom macros and TikZ will not convert cleanly. For custom macros the TeX-running family (tex4ht, lwarp) has the advantage — TeX expands them, so the converter never even sees the original command. But what expansion leaves behind is visual instruction, bold or italic, not meaning, so no semantic HTML tag appears. \newcommand{\keyterm}[1]{\textbf{#1}} will give you the equivalent of <b>, never <dfn>. TikZ demands a plainer compromise: both tex4ht and lwarp reach the same conclusion and paste the picture in as an image. In the experiment here, the TikZ graph became a single SVG named doc0x.svg whose alt text was nothing but the node labels strung together. If you want a figure that means something in HTML, the faster road is not to hope for it from the converter but to export the figure separately and write the alt text yourself.
Which one to choose, by what you are doing
- You just want HTML and no new toolchain →
make4ht file.tex. It ships with TeX Live and runs without touching the document. - You want MathML (better for screen readers, search and zooming) →
make4ht -u file.tex "mathml", or LaTeXML. - You need a serious web edition that keeps LaTeX's features →
lwarp— but only for a document where\usepackage{lwarp}can go first. - You want an arXiv-style semantic HTML paper →
LaTeXML(Perl; installed separately from TeX Live). - The source is Markdown and light output is fine →
pandoc(Haskell; installed separately from TeX Live). Its LaTeX input support is partial. - TikZ figures are the point → do not delegate them: export each figure on its own as SVG and write the
alttext yourself.