You’ve written a beautiful document. Now you need to get it into the world: as a PDF for sharing, HTML for the web, EPUB for e-readers, or a submission to a journal or arXiv. This chapter covers the export pipeline and the practical concerns of each output format.
The Publishing Pipeline
Your .tex file is the single source of truth. From it, you can produce:
- PDF — direct compilation (the primary output)
- HTML — via
tex4ht,LaTeXML, orpandoc - EPUB — via
pandocortex4ht - DOCX — via
pandoc(for collaborators who need Word) - Markdown — via
pandoc(for web publishing)
PDF Output
PDF is the native output of LaTeX and where it excels. Some tips for production-quality PDFs:
PDF Metadata
\usepackage{hyperref}
\hypersetup{
pdftitle={LaTeX for Students},
pdfauthor={Gaurav Tiwari},
pdfsubject={A Practical Guide},
pdfkeywords={LaTeX, math, typesetting},
pdfcreator={XeLaTeX}
}
PDF/A for Archival
Some institutions require PDF/A (archival format). Use the pdfx package:
\usepackage[a-2b]{pdfx}
Compressing PDFs
# Ghostscript compression
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH \
-sOutputFile=output.pdf input.pdf
/ebook produces reasonable quality at small file size. Use /prepress for print quality.
HTML Export
Pandoc
Pandoc is the Swiss Army knife of document conversion:
# Basic HTML
pandoc input.tex -o output.html --standalone
# With KaTeX math
pandoc input.tex -o output.html --katex --standalone
# With MathJax
pandoc input.tex -o output.html --mathjax --standalone
# With native MathML
pandoc input.tex -o output.html --mathml --standalone
Tip: Pandoc handles 80% of conversions well. For complex documents with custom LaTeX commands, some manual cleanup may be needed. Define a pandoc filter or Lua filter to handle custom commands.
LaTeXML
LaTeXML is the most faithful LaTeX-to-HTML converter. It parses LaTeX at a deep level:
latexml input.tex --dest=input.xml
latexmlpost input.xml --dest=output.html \
--format=html5
arXiv uses LaTeXML to generate HTML versions of papers.
tex4ht (make4ht)
Part of TeX Live, tex4ht converts LaTeX to HTML, XHTML, or EPUB:
make4ht input.tex "html5+mathml"
EPUB Export
EPUB is the standard e-book format. Two main approaches:
# Via pandoc (simplest)
pandoc input.tex -o output.epub --mathml
# Via tex4ht
make4ht input.tex "xhtml,epub3" -e build.mk4
EPUB uses XHTML internally, so math must be MathML (which is part of the EPUB3 spec). Not all e-readers render MathML well. Test on your target devices.
DOCX Export
When collaborators need Word format:
pandoc input.tex -o output.docx
Equations are converted to Word’s native equation format. Most simple equations convert cleanly; complex custom environments may need manual adjustment.
Accessibility
Accessible documents ensure everyone can read your work:
- Tagged PDF: Use
\usepackage{accessibility}(experimental) or thetagpdfpackage to produce tagged PDFs where screen readers can navigate the structure. - Alt text for images: Provide descriptive text via
\Descriptionor figure captions. - MathML output: For HTML, use MathML so screen readers can interpret equations.
- Document structure: Proper use of
\chapter,\section, etc., creates a navigable document tree. - Color contrast: Ensure text and background colors meet WCAG AA contrast ratios (4.5:1 for body text).
Important: PDF accessibility is an active area of development in the LaTeX world. The LaTeX Project’s tagged PDF initiative aims to make all LaTeX output accessible by default. In the meantime, HTML output (via pandoc or LaTeXML with MathML) is the most accessible format for mathematical content.
arXiv Submission
arXiv (https://arxiv.org) is the primary preprint server for mathematics, physics, and computer science.
Preparing Your Submission
- Use
pdflatexorxelatex. arXiv supports both, butpdflatexhas broader compatibility. - Flatten your project. If you use
\input/\include, either flatten to a single file or include all files in your upload. - Include all custom files: style files (
.sty), bibliography (.bbl), and figures. - Don’t include generated files: no
.aux,.log,.pdf, or.synctex.gz. - Use
.bblnot.bib: Run BibTeX/Biber locally and upload the.bblfile.
# 1. Compile locally to generate .bbl
xelatex paper.tex
bibtex paper
xelatex paper.tex
xelatex paper.tex
# 2. Create submission archive
tar czf submission.tar.gz \
paper.tex paper.bbl \
figures/ custom.sty
Warning: arXiv recompiles your source on their servers. If your document uses system fonts (via
fontspec), it may fail on arXiv’s TeX Live installation. Either embed fonts or stick topdflatexwith standard font packages for arXiv submissions.
Journal Submission
Most journals provide LaTeX templates (class files or style files):
- Download the journal’s template from their website.
- Replace the sample content with yours.
- Follow their formatting guidelines exactly (font, margins, citation style).
- Submit via the journal’s online system (typically as a
.ziparchive).
Common journal classes: revtex4-2 (APS journals), amsart (AMS journals), elsarticle (Elsevier), IEEEtran (IEEE), svjour3 (Springer).
Self-Publishing
If you’re publishing a book (like this one), your options:
- Platform: Amazon KDP | Notes: PDF upload. Interior + cover PDF. ISBN optional.
- Platform: Lulu | Notes: PDF or EPUB. Print-on-demand. Better paper options.
- Platform: IngramSpark | Notes: Widest print distribution. Requires ISBN.
- Platform: Gumroad/Lemon Squeezy | Notes: Digital-only (PDF/EPUB). Direct sales.
- Platform: Your own website | Notes: Full control. Sell via WooCommerce, Stripe, etc.
Print-Ready PDFs
For print-on-demand services:
- Set the correct paper size (usually US Letter or A5 with bleed).
- Use CMYK colors for print (RGB for screen).
- Embed all fonts (default with
xelatex). - Export at 300 DPI for any raster images.
- Include crop marks if required (
geometryoptionshowframe).
Git for LaTeX
Since .tex files are plain text, Git is the ideal version control system:
# LaTeX generated files
*.aux
*.log
*.out
*.toc
*.lof
*.lot
*.fls
*.fdb_latexmk
*.synctex.gz
*.bbl
*.blg
*.idx
*.ilg
*.ind
# Output
*.pdf
Tip: Use meaningful commit messages tied to content changes: “Add Chapter 5: Advanced Math” not “update.” For co-authored papers, each author works on their own branch and merges via pull requests. Conflicts in
.texfiles are easy to resolve because it’s plain text.
Exercises
- Convert one of your LaTeX documents to HTML using pandoc with KaTeX. Open it in a browser and verify all equations render correctly.
- Export the same document to EPUB and open it in an e-reader application. Note which elements converted well and which didn’t.
- Set up a Git repository for a LaTeX project with the
.gitignorefrom above. Make three commits with meaningful messages.- Download a journal template (e.g.,
IEEEtran) and format a one-page abstract with title, author, and one equation.- If you have content on arXiv, check whether the HTML version (generated by LaTeXML) renders your equations correctly. Note any discrepancies.