Written and maintained by CASRAI Editorial Board
Published · Last updated
On this page
In scientific publishing, open-access dissemination, and academic research workflows, converting LaTeX documents into web-accessible HTML5 is a frequent necessity. While PDF remains a dominant distribution medium for printed manuscripts, research institutions, digital repositories, and funding bodies increasingly require responsive, screen-reader-accessible web formats. Because LaTeX is a macro-driven, Turing-complete typesetting system rather than a structured tree markup language, translating scientific manuscripts with mathematical formulas, figures, cross-references, and BibTeX citations into clean HTML requires specialized conversion tools.
What it is used for in research
Researchers, academic publishers, and laboratory teams convert LaTeX to HTML across several key operational contexts:
- Digital Preprint and Open Access Publishing: Major scientific repositories, such as the arXiv mathematics preprint server through its HTML initiative (ar5iv), convert TeX manuscripts into accessible HTML5 to enable mobile-responsive reading and structured text mining.
- Web Accessibility Compliance: Under Section 508 of the Rehabilitation Act and W3C Web Content Accessibility Guidelines (WCAG 2.1 Level AA), federally funded research publications and university course materials must be accessible to assistive technologies. HTML5 paired with native MathML allows screen readers to traverse equations semantically.
- Integration with Reference and Writing Tools: Research groups authoring papers in collaborative environments, such as web-based LaTeX editors, frequently export web previews or documentation. These pipelines connect with bibliographical tools such as Zotero vs. JabRef for LaTeX to generate web bibliographies.
- Web-Embeddable Equation Rendering: When publishing research blogs, interactive software tutorials, or lab protocols, authors combine HTML conversion with LaTeX to SVG equation rendering or client-side libraries like MathJax.
- Institutional Repository Ingestion: Preserving technical reports in digital archives, such as the NIST Digital Library of Mathematical Functions (DLMF), requires semantic HTML with machine-parsable formula structures.
How to install or access it
The three authoritative, open-source command-line tools for converting LaTeX to HTML are Pandoc, make4ht (TeX4ht), and LaTeXML. Each can be installed from official package repositories and project releases:
- Pandoc: Official binaries and release packages are hosted on pandoc.org. On Debian/Ubuntu systems, install via
sudo apt-get install pandoc. On macOS with Homebrew, runbrew install pandoc. For Conda environments, useconda install -c conda-forge pandoc. - make4ht (TeX4ht): Bundled natively within standard TeX distributions including TeX Live and MiKTeX. If missing, install via the TeX Live package manager using
tlmgr install make4ht tex4ht, or download directly from the Comprehensive TeX Archive Network at CTAN make4ht. - LaTeXML: Maintained by the National Institute of Standards and Technology (NIST) at NIST LaTeXML. On Debian/Ubuntu, install via
sudo apt-get install latexml. On macOS, runbrew install latexml. It is also available via CPAN viacpanm LaTeXML.
Step-by-step task
Follow this numbered procedure to convert a research manuscript containing equations, citations, and figures from LaTeX into a standalone HTML5 document.
- Prepare and Clean the LaTeX Source: Ensure your main document (e.g.,
paper.tex) is UTF-8 encoded. Verify that all package dependencies in your preamble compile without errors in your standard LaTeX engine. Ensure graphics referenced by\includegraphicsexist in web-compatible formats (PNG, JPG, or SVG) alongside PDF/EPS files. - Select the Appropriate Conversion Engine:
- Use Pandoc if your manuscript uses standard LaTeX markup, minimal custom macros, or relies on Markdown integrations.
- Use make4ht if your document depends heavily on complex LaTeX packages (such as
amsmath,booktabs,cleveref, or custom.styfiles), because make4ht executes the actual TeX engine. - Use LaTeXML if your manuscript contains extensive advanced mathematics requiring strict semantic MathML compliance for digital publishing.
- Execute the Conversion Command:
- Pandoc (with MathJax and BibTeX): Run the command:
pandoc paper.tex -s --citeproc --bibliography=references.bib --mathjax -o paper.htmlTo output native W3C MathML instead of client-side MathJax, substitute the math flag:
pandoc paper.tex -s --citeproc --bibliography=references.bib --mathml -o paper.html - make4ht (with LuaTeX and MathJax): Run the command:
make4ht -u -l paper.tex "mathjax"For native MathML output with make4ht, use:
make4ht -u -l paper.tex "mathml" - LaTeXML (All-in-One CLI): Run the command:
latexmlc --dest=paper.html --format=html5 --mathml --bibliography=references.bib paper.tex
- Pandoc (with MathJax and BibTeX): Run the command:
- Convert Vector Graphics: Web browsers do not natively render PDF or EPS vector graphics referenced in LaTeX. Convert your vector figures to SVG or high-resolution PNG using command-line tools like
dvisvgm,inkscape, or ImageMagick, and ensure the relative paths in the output HTML point to the converted assets. - Verify Hyperlinks and Bibliographic Citations: Inspect in-text citation links (
\cite{...}) and internal cross-references (\ref{...}and\eqref{...}) to confirm that anchor links point to existing target IDs in the generated HTML. - Audit Visual and Accessibility Output: Open
paper.htmlin a standards-compliant web browser. Test mathematical formula display, verify that equation numbers align correctly, and check contrast and screen reader accessibility.
Output and how to read it
The generated HTML5 output contains structural, mathematical, and typographic elements that map directly from your LaTeX source:
- Semantic Document Hierarchy: LaTeX sectioning commands (
\section,\subsection,\subsubsection) map to HTML semantic elements (<h1>,<h2>,<h3>) or structured<section>blocks, maintaining document outline fidelity. - Mathematical Formula Elements:
- MathML: Formulas are rendered as semantic XML trees using
<math xmlns="http://www.w3.org/1998/Math/MathML">tags. Inline equations usedisplay="inline", while displayed equations usedisplay="block". Assistive screen readers interpret symbols such as α, β, σ, and integrals natively from these trees. - MathJax / KaTeX: Formulas appear as TeX markup wrapped in spans or script tags (e.g.,
<span class="math inline">\(x + y\)</span>), which client-side JavaScript renders dynamically into SVG or HTML-CSS in the browser viewport.
- MathML: Formulas are rendered as semantic XML trees using
- Cross-References and Numbering: Equations with
\label{eq:model}are assigned unique HTMLidattributes (such asid="eq:model"), allowing references created with\eqrefto function as clickable internal hyperlinks. - Reference Lists and Bibliographies: Citations are expanded into numbered or author-date links pointing to an end-of-document reference section wrapped in an ordered list or semantic
<div class="references">. - Companion Files: The conversion often generates auxiliary files in the output directory, including external CSS stylesheets (e.g.,
paper.css), generated SVG math snippets, and image subdirectories. These files must remain in their relative paths when uploading to a web server.
Troubleshooting
Scientific manuscripts frequently trigger conversion errors due to complex packages, custom TeX macros, or graphics. Address common failure modes using these documented remedies:
- Undefined Macro Errors in Pandoc: Because Pandoc parses LaTeX via an Abstract Syntax Tree (AST) rather than compiling with TeX, low-level TeX primitives (such as
\def,\let, or\expandafter) and unsupported packages will fail to render or be stripped.
Remedy: Store custom\newcommanddefinitions in an external file (e.g.,macros.tex) and include it using Pandoc’s--include-in-header=macros.texflag, or switch tomake4ht, which evaluates all TeX macros natively through the compiler. - TikZ Figures and PGF Plots Failing to Render: Pandoc cannot process inline TikZ environments.
Remedy: When usingmake4ht, pass the SVG driver configuration to convert TikZ environments automatically viadvisvgm. In Pandoc workflows, compile TikZ diagrams into standalone SVG files prior to document conversion. - Broken Cross-References and Equation Numbers: If equation numbers appear as empty brackets or question marks,
\labelcommands may be misplaced.
Remedy: Ensure that\labelis placed strictly inside the equation environment (such as\begin{equation} ... \label{...} \end{equation}) immediately following the mathematical content. When using MathJax in HTML, configure the MathJax script block withtex: { tags: 'ams' }to enable automatic numbering. - Unprocessed BibTeX Citation Keys: Citation keys appear literally in the output text (e.g., “[smith2024]”) without generating a formatted bibliography.
Remedy: In Pandoc, verify that the--citeprocflag and--bibliography=refs.bibpath are explicitly passed. Inmake4ht, ensure BibTeX is executed on the auxiliary file (e.g.,bibtex paper) before running the final make4ht pass. - Malformed Complex Tables: Packages such as
tabularx,multirow, orlongtablecan produce misaligned HTML table columns.
Remedy: Inmake4ht, configure table handling in a custom configuration file (.cfg) using\Configure{tabular}or simplify nested column specifications to standardtabularenvironments.
Free alternatives
Researchers can choose among several mature, free, and open-source tools for converting LaTeX to HTML. The following table compares their architectures, math handling, and optimal research use cases:
| Tool | Engine Architecture | Math Rendering | Package Support | Best Research Use Case |
|---|---|---|---|---|
| Pandoc | Haskell-based AST parser (no TeX engine) | MathML, MathJax, KaTeX, WebTeX | Moderate (standard packages; ignores low-level TeX primitives) | Standard articles, lecture notes, multi-format pipelines (Markdown/HTML/PDF) |
| make4ht (TeX4ht) | Native TeX compiler wrapper (LuaTeX / pdfTeX) | MathML, MathJax, SVG/PNG images | Very High (executes actual TeX code and custom packages) | Complex manuscripts with custom style files, extensive macros, and booktabs |
| LaTeXML | Perl-based TeX emulation and XML processor | High-fidelity semantic MathML, images | High (built-in bindings for standard science packages) | Heavy STEM manuscripts, institutional repositories, arXiv ar5iv publishing |
| lwarp | LaTeX package compiling via pdflatex / lualatex | MathML, MathJax, SVG images | High (runs within the native LaTeX compiler environment) | Multi-chapter academic books and long-form research monographs |
| plasTeX | Python-based LaTeX parser and DOM framework | MathML, MathJax, image fallbacks | Moderate (extensible via custom Python renderers) | Programmatic publishing pipelines and custom Python-driven web platforms |
FAQ
Which tool is best for converting arXiv preprints to HTML?
LaTeXML is the industry standard for arXiv preprints. It powers the official ar5iv project, translating high-level mathematical concepts and complex TeX structures into accessible HTML5 and semantic MathML.
What is the difference between MathML and MathJax in HTML output?
MathML is an open W3C standard representing mathematical notation as structured XML markup directly within HTML documents, enabling native screen-reader interpretation without external scripts. MathJax is a JavaScript display engine that renders LaTeX strings or MathML visually in the browser using SVG or HTML-CSS fonts.
Can Pandoc convert complex TikZ diagrams directly to HTML?
Pandoc cannot natively evaluate TikZ commands because it does not execute a TeX compiler. To convert TikZ diagrams, compile them to standalone SVG graphics prior to conversion, or use make4ht with the dvisvgm graphics driver.
How do I ensure converted HTML papers meet WCAG 2.1 accessibility standards?
Ensure the conversion tool generates native MathML (--mathml), provides meaningful alt text for all embedded figures, preserves a logical heading structure (<h1> through <h3>), and outputs valid semantic HTML5 markup.
Why do custom macros fail in Pandoc but work in make4ht?
Pandoc operates on an abstract syntax tree and only interprets a subset of common LaTeX macros. In contrast, make4ht compiles the document using the actual TeX engine (such as pdfTeX or LuaTeX), meaning all valid TeX macros and package definitions are fully evaluated before HTML nodes are produced.
Sources
All tool capabilities, command syntax, and engine specifications in this guide were verified against official documentation on 2026-11-10:
- Pandoc User’s Guide (Official Pandoc Documentation, verified 2026-11-10).
- TeX4ht: LaTeX and TeX for Hypertext (TeX Users Group, verified 2026-11-10).
- make4ht CTAN Package Documentation (Comprehensive TeX Archive Network, verified 2026-11-10).
- LaTeXML: A LaTeX to XML/HTML/ePub/MathML Converter (NIST Digital Library of Mathematical Functions, verified 2026-11-10).
- lwarp CTAN Package Documentation (Comprehensive TeX Archive Network, verified 2026-11-10).







