Convert HTML to LaTeX and generate a PDF
- Dashboard
- Documentation
- API
Why convert HTML to LaTeX?
Converting HTML to LaTeX lets you produce professional-quality PDFs from content already written on the web: CMS articles, auto-generated documentation, blog posts, wiki exports or notes taken in a WYSIWYG editor. Rather than redoing the layout manually, this HTML to LaTeX converter takes your HTML source and produces a .tex file that compiles to PDF.
Typical uses: turn a draft written in Notion or Markdown (exported to HTML) into a scientific article, turn a web page into a printable booklet, generate a letter or a CV from an HTML editor. HTML to LaTeX conversion avoids rewriting the layout and guarantees consistent typographic rendering.
Why LaTeX rather than a direct PDF export?
Printing an HTML page to PDF from the browser is quick, but the result is rarely up to the standard of a publication. Going through LaTeX brings several decisive benefits:
- Professional typography: kerning, hyphenation, justification, widows and orphans handled automatically, bibliography via BibTeX/BibLaTeX, consistent numbering of sections, figures and equations.
- Reproducible documents: the
.texis a versionable text file that recompiles identically. Ideal for research, software documentation or any workflow where reproducibility matters. - Academic standard: LaTeX remains the format expected by the majority of scientific journals, conferences and university theses.
- Fine editing possible: if the generated rendering does not suit you 100%, open the
.texin Overleaf, TeXstudio or VS Code and tweak. You keep control, unlike a frozen PDF.
Typical use cases
- Scientific articles: a draft written on the web, convert HTML to LaTeX, polish in Overleaf, submit to the journal.
- Letters and CVs: go from an HTML editor (rich, visual) to a LaTeX letter with impeccable rendering, ready to print.
- Technical documentation: generate a reference PDF from existing HTML docs (Sphinx, MkDocs, wiki), without duplicating the source.
- Notion / Markdown notes: export to HTML, then run through html2latex to get a structured printable document.
- Company reports: turn a report written in an internal CMS into a typeset PDF deliverable.
How does our HTML to LaTeX converter work?
The converter parses your HTML source, identifies each tag, and maps it to the equivalent LaTeX command. Concretely:
- Headings
<h1>,<h2>,<h3>become\section{},\subsection{},\subsubsection{}. - Inline formatting (
<strong>,<em>,<u>,<code>) is translated to\textbf{},\textit{},\underline{},\texttt{}. - Lists (
<ul>,<ol>) becomeitemizeandenumerateenvironments. - Links
<a href>are rendered with thehyperrefpackage. - Special LaTeX characters (
%,&,$,#,_,{,}) are automatically escaped.
You pick the output LaTeX class: article (default, for articles, short reports), letter (for correspondence) or book (for long documents with chapters). The preamble is generated with the useful packages: inputenc (UTF-8), babel, hyperref, amsmath, amssymb.
How to use the tool
Four steps to convert HTML to LaTeX:
- Paste your HTML code into the dedicated field.
- Pick the output document type (article, letter, book).
- Click the conversion button. The
.texfile and its PDF rendering are generated. - Download the
.texto edit in your LaTeX editor, or the PDF directly.
Key HTML to LaTeX mappings
| HTML | LaTeX | Notes |
|---|---|---|
<h1> |
\section{} |
Level 1 |
<h2> |
\subsection{} |
Level 2 |
<h3> |
\subsubsection{} |
Level 3 |
<strong> |
\textbf{} |
Bold |
<em> |
\textit{} |
Italic |
<u> |
\underline{} |
Underline |
<code> |
\texttt{} |
Monospace font |
<ul> |
\begin{itemize} |
Bulleted list |
<ol> |
\begin{enumerate} |
Numbered list |
<li> |
\item |
List item |
<a href="..."> |
\href{...}{...} |
Requires \usepackage{hyperref} |
<blockquote> |
\begin{quote} |
Quotation |
<p> |
paragraph | Empty line between paragraphs |
<br> |
\\ |
Line break |
HTML to LaTeX conversion example
HTML source:
<h1>Main Title</h1>
<p>This is a paragraph with <strong>some bold</strong> and <em>some italic</em>.</p>
<h2>Subsection</h2>
<ul>
<li>Item one</li>
<li>Item two with <a href="https://cdrn.fr">a link</a></li>
</ul>
LaTeX result:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\section{Main Title}
This is a paragraph with \textbf{some bold} and \textit{some italic}.
\subsection{Subsection}
\begin{itemize}
\item Item one
\item Item two with \href{https://cdrn.fr}{a link}
\end{itemize}
\end{document}
FAQ
Which LaTeX class to pick: article, letter or book?
article suits most cases (report, article, short memo). letter is dedicated to correspondence (header, signature, polite formulas). book structures long documents into chapters and includes a detailed table of contents. When in doubt, start with article.
Is the generated PDF guaranteed to compile?
For standard HTML (paragraphs, headings, lists, inline formatting, links), yes. If your HTML contains exotic tags, inline JavaScript or non-standard nested structures, manual adjustment of the .tex before compilation may be needed.
My HTML uses images: are they included?
<img> tags are converted to \includegraphics{} with the graphicx package, but the images themselves are not embedded in the .tex (LaTeX references local files). Download the images separately and place them next to the .tex before compilation.
Why not Markdown to LaTeX directly?
Pandoc does Markdown to LaTeX very well. Our converter specifically targets HTML, which covers sources Markdown does not reach: CMS exports, web pages, content written in WYSIWYG editors, output of documentation generators. If your source is already in Markdown, export it to HTML then come here, or use Pandoc directly.
Does the LaTeX rendering handle UTF-8 and accents?
Yes. The preamble includes \usepackage[utf8]{inputenc} and \usepackage[british]{babel}, which ensures the correct rendering of accents, cedillas and language-specific typographic rules.
And the reverse, LaTeX to HTML?
LaTeX to HTML conversion is a different exercise (LaTeX is far more expressive than HTML, especially for equations). For that direction, look at pandoc, htlatex or LaTeXML. This tool only does HTML to LaTeX, in a single direction.
Frequently asked questions
Which LaTeX class to pick: article, letter or book?
article suits most cases (short report, post, memo, scientific article). letter is dedicated to correspondence with header, signature and polite formulas built in. book structures long documents into chapters and includes a detailed table of contents. When in doubt, start with article: it is the most universal class.
Are accents and language-specific characters rendered correctly?
Yes. The generated preamble includes \usepackage[utf8]{inputenc} and \usepackage[british]{babel}, which ensures correct rendering of accents, cedillas and language-specific typographic rules: non-breaking spaces, quotation marks, correct hyphenation. No manual intervention is needed for normal text.
Are LaTeX special characters escaped automatically?
Yes. Characters with a special meaning in LaTeX (%, &, $, #, _, {, }, ~, ^, \) are automatically escaped during conversion. HTML text containing 50% discount or user_name translates correctly without breaking compilation.
My HTML uses images: are they included in the .tex?
<img> tags are converted to \includegraphics{} with the graphicx package, but the images themselves are not embedded in the .tex because LaTeX references local files. Download the images separately and place them next to the .tex before compilation, or adjust the path in \graphicspath.
How do I handle HTML with mathematical equations?
If your equations are already in MathML or inline LaTeX (for example $E = mc^2$), the converter forwards them almost as is to the output. Equations rendered as images (PNG, SVG) are not automatically re-converted to LaTeX. For impeccable mathematical rendering, write the formulas in LaTeX in the HTML source, the preamble already loads amsmath and amssymb.
Is the generated .tex guaranteed to compile?
For standard HTML (paragraphs, headings, lists, inline formatting, links, simple tables), yes. If your HTML contains exotic tags, inline JavaScript, complex CSS or non-standard nested structures, the .tex may need adjustment before compilation. Open it in Overleaf or TeXstudio to quickly spot any warnings.
Example request
curl -X POST https://cdrn.fr/api/v1/tools/html-to-latex-converter/execute \
-H "Content-Type: application/json" \
-d '{"content":"...","type":"letter","city":"...","object":"...","opening":"...","closing":"...","sender_address":"...","recipient_address":"...","recipient_name":"...","sender_name":"...","sender_phone":"...","sender_mail":"..."}'
Input schema
| Field | Type | Required | Default |
|---|---|---|---|
content |
string | ✓ | – |
type |
choice (letter, article) | ✓ | – |
city |
string | ✓ | – |
object |
string | ✓ | – |
opening |
string | ✓ | – |
closing |
string | ✓ | – |
sender_address |
text | ✓ | – |
recipient_address |
text | ✓ | – |
recipient_name |
string | ✓ | – |
sender_name |
string | ✓ | – |
sender_phone |
string | ✓ | – |
sender_mail |
string | ✓ | – |
Endpoints
GET https://cdrn.fr/api/v1/tools- lists every available toolGET https://cdrn.fr/api/v1/tools/html-to-latex-converter- returns the schema for this toolPOST https://cdrn.fr/api/v1/tools/html-to-latex-converter/execute- runs this tool with a JSON payload