\begin{article}
Convert Markdown and HTML to LaTeX — latex-convert Skill
Convert any Markdown, HTML, or plain text to clean compilable LaTeX — with proper element mapping, special character escaping, and package declarations.

You have a Markdown README, an HTML article, or a plain text document — and you need a LaTeX version. Maybe you are preparing a technical report, a research paper submission, or building a PDF generation pipeline. Whatever the reason, the conversion is never as simple as it sounds. Headings need to become \section{} commands. Tables need tabular environments. Code blocks need verbatim or listings. Every %, &, _, #, and $ in the source content needs escaping or the compiler will choke. Math expressions need $ delimiters and the right packages declared. Do this manually once and you will spend thirty minutes hunting down a single unescaped ampersand in a URL.
The latex-convert Claude Code skill eliminates this entirely. Drop any Markdown, HTML, or plain text content into a conversation with Claude Code, invoke the skill, and get back clean, compilable LaTeX with all the structural mappings handled, all special characters escaped, and all required \usepackage{} declarations included at the top. This post covers how it works, how to install it, and where it fits in a real PDF generation workflow.
The Problem with Manual Markdown-to-LaTeX Conversion
Developers who work with LaTeX regularly know the friction. Content lives in Markdown — documentation, README files, blog posts, internal wikis. LaTeX is what your journal submission system, your PDF report template, or your FormatEx-powered compilation pipeline actually needs.
Pandoc handles some of this, but it produces generic output that often needs significant cleanup. It does not know your package preferences, does not handle all Markdown extensions consistently, and produces verbose output that is hard to read or maintain. For one-off conversions it is fine. For iterative work — where you are refining content and re-compiling often — you want something that understands context and produces idiomatic LaTeX you would actually write yourself.
That is what latex-convert does inside Claude Code. It is not a dumb text transform. It reasons about the content structure and produces LaTeX that matches standard conventions.
How to Install latex-convert
The skill lives in the FormatEx latex-skills GitHub repository. You have four install options depending on how much of the skill set you want.
Install just this skill:
cp -r skills/latex-convert ~/.claude/skills/Install the latex meta-skill (a curated bundle of core LaTeX skills including convert, fix, write, and more):
cp -r skills/latex ~/.claude/skills/Install the formatex meta-skill (latex skills plus FormatEx API integration for compiling directly to PDF):
cp -r skills/formatex ~/.claude/skills/Install everything:
cp -r skills/latex-full ~/.claude/skills/After copying, the skill is immediately available in any Claude Code session. No configuration required. Invoke it by typing /latex-convert in your conversation.
What latex-convert Does
The skill performs a structured, element-aware conversion from Markdown, HTML, or plain text to LaTeX. Here is what it maps:
Headings — Markdown #, ##, ### and HTML <h1>-<h6> become \section{}, \subsection{}, \subsubsection{}, and so on, matching the document hierarchy.
Lists — Unordered lists become itemize environments. Ordered lists become enumerate. Nested lists produce nested environments with correct indentation.
Tables — Markdown pipe tables and HTML <table> elements become tabular environments with appropriate column specifiers. The skill adds \usepackage{booktabs} and uses \toprule, \midrule, \bottomrule for professional-looking tables.
Emphasis and strong — *italic* and **bold** become \textit{} and \textbf{}. HTML <em> and <strong> are handled the same way.
Links — Hyperlinks become \href{}{} commands with \usepackage{hyperref} declared automatically.
Code blocks — Fenced code blocks and inline code become lstlisting environments and \lstinline{} respectively. If a language identifier is present, the skill sets language= in the listing options. \usepackage{listings} is added.
Math — Inline math in $...$ or \(...\) is preserved. Display math in $$...$$ or \[...\] becomes a proper equation or align environment. If you need more control over math typesetting, the latex-math-equations skill handles complex equation work as a follow-up step.
Special character escaping — Every %, &, $, #, _, {, }, ~, ^, and \ in literal text content is escaped correctly. This is the step that breaks most naive converters. The skill distinguishes between structural uses of these characters (LaTeX commands) and literal content uses (which must be escaped).
Package declarations — Rather than dumping a generic preamble, the skill only declares packages that are actually needed by the converted content. If there are no tables, booktabs is not included. If there are no links, hyperref is not included. The output compiles without modification.
Before and After: A Real Example
Before — the manual process:
You have a Markdown document for a technical specification. It has headings, a comparison table, some inline code, a code block with a bash example, and a few URLs. To convert it manually you would:
- Replace every
#heading with the correct\sectionlevel - Convert the table to
tabular, figure out column widths, add\hlineor booktabs commands - Wrap every code block in
\begin{lstlisting}and\end{lstlisting} - Hunt through every line for
%characters in comments,&in URLs,_in variable names,#in hex colors or shell commands - Add the right
\usepackagedeclarations based on what you used - Try to compile, read the error, find the missed escape, fix, repeat
For a 500-word document this takes 20-40 minutes and requires careful attention to avoid missing a single problematic character. The latex-fix-errors skill exists for exactly the repair work that follows when something is missed.
After — using latex-convert:
Paste the Markdown into your Claude Code session and run /latex-convert. You get back a complete LaTeX document fragment with all elements mapped, all characters escaped, and all packages declared. Feed it directly into your template or pipe it to the FormatEx API for compilation. The whole process takes under a minute.
Common Use Cases
1. Converting documentation to PDF reports
Engineering teams maintain documentation in Markdown. When a client needs a formal PDF deliverable, latex-convert turns the Markdown source into compilable LaTeX in one step. Combine with a custom document template and the latex-document-structure skill to apply consistent formatting, then compile via FormatEx.
2. Journal and conference paper submission
You drafted your paper in a lightweight Markdown format or pulled content from an HTML export. The submission system needs LaTeX. latex-convert handles the structural conversion; the latex-citations-bibliography skill handles the reference list separately.
3. Building PDF generation pipelines
If you are building an application that generates PDFs from user-supplied content — reports, invoices, certificates, documentation exports — your users provide input in Markdown or rich text (HTML). latex-convert is the conversion layer before you call the FormatEx API to compile. See the Go client guide, PHP/Laravel integration, or Ruby on Rails integration for how to wire up the compilation side.
4. Serverless document generation
In a serverless architecture, you cannot run a TeX Live installation. The pattern is: convert Markdown to LaTeX with latex-convert, POST the LaTeX to the FormatEx API from a Lambda or similar function, stream back the PDF. The serverless AWS Lambda guide walks through the full setup.
5. Migrating content between formats
Legacy HTML content — old blog posts, internal wikis, exported CMS content — needs to move into a LaTeX document archive or book manuscript. latex-convert handles the HTML input path just as well as Markdown, stripping tags and mapping semantic structure to the correct LaTeX commands.
Tips for Best Results
Give the skill context about the target document class. If you are targeting \documentclass{article} versus \documentclass{book}, the heading hierarchy maps differently. Mention it upfront.
For content with complex math, let latex-convert handle the surrounding text and structural elements, then use the latex-math-equations skill to clean up or expand the mathematical content specifically.
If the converted output has anything unexpected, the latex-explain-commands skill can walk you through what each generated command does — useful when you are less familiar with a particular LaTeX package or environment that the skill introduced.
For writing new LaTeX content from scratch rather than converting existing content, the latex-write-markup skill is the better starting point.
Related Skills
- latex-fix-errors — Diagnose and fix LaTeX compilation errors
- latex-write-markup — Write LaTeX markup from scratch or from a description
- latex-math-equations — Typeset complex mathematical expressions correctly
- latex-document-structure — Structure and organize LaTeX documents
- latex-citations-bibliography — Handle references, citations, and bibliography management
- latex-explain-commands — Explain what LaTeX commands and environments do
Get Started
The latex-convert skill is available now in the FormatEx latex-skills repository. Install it with a single cp command and it is ready in Claude Code immediately.
If you are building a PDF generation system and need a reliable LaTeX compilation backend, FormatEx provides a REST API that handles TeX Live infrastructure for you — no installation, no maintenance, no TeX Live version conflicts. The getting started guide covers everything from your first API call to production deployment.
\end{article}
\related{posts}




