A collection of sample class notes converted from LaTeX to HTML.
Conversion Workflow: LaTeX to HTML
Overview
This workflow uses LaTeXML and latexmk
to convert LaTeX documents into responsive, styled HTML pages with mathematical equations,
proofs, and a toggle for LaTeX.css styling.
Prerequisites
- LaTeXML - for converting LaTeX to HTML5
brew install latexml # macOS # or apt-get install latexml # Linux - latexmk - for building PDFs alongside HTML
brew install latexmk # macOS or included with LaTeX distributions - Python 3.12+ - for post-processing scripts
- BeautifulSoup4 - Python HTML parser
pip install beautifulsoup4
Step-by-Step Process
-
Convert LaTeX to HTML with LaTeXML
The
main.pyscript runs LaTeXML with HTML5 format to convert your .tex file:latexmlc --format=html5 --includestyles --destination='html_out/filename/index.html' 'tex_src/filename.tex'This generates semantically correct HTML with MathML equations and proper document structure.
-
Build PDF with latexmk
Simultaneously, PDFs are generated for reference:
latexmk -auxdir=build/filename -outdir=html_out/filename -pdflua -silent 'tex_src/filename.tex' -
Post-Process HTML
The
main.pyscript performs these transformations on the generated HTML:- QED Symbol Replacement — Converts LaTeX QED (∎) to an accessible HTML version with aria-labels
- Proof Element Enhancement — Adds CSS classes to proof environments for styling
- Resource Injection — Injects custom resources into the document head:
-
Generate Index Page
The
create_main_index.pyscript auto-discovers all converted documents and generates this index page with links and PDF references.
Usage
Convert one or more LaTeX files:
python3 main.py tex_src/equivalence.tex tex_src/Lp.tex
View the conversion steps without executing (dry-run):
python3 main.py -n tex_src/equivalence.tex
Regenerate the index page:
python3 create_main_index.py
Preview locally with HTTPS:
python3 https_server.py # Serves at https://kn-mb-2411.local:4444
Key Features
- Responsive Design - Works on desktop, tablet, and mobile devices
- LaTeX.css Theme - Professional styling for academic documents with easy toggle
- Accessible QED Symbols - Screen-reader friendly proof completion markers
- MathJax Integration - Advanced mathematical equation rendering
- PDF Links - Direct access to PDF versions of documents
- Automatic Indexing - Auto-discover and link all converted documents