Let
X
Journal

From Markdown to LaTeX: Convert & Publish Sci Docs

SPECIMEN IDLETX-SPEC-MARK
DATE RECORDEDMay 20, 2026
READING COMPLEXITY2 min read
TAG INDEX
latexmarkdownpandocworkflow
Document Abstract

Convert Markdown to LaTeX with Pandoc using pandoc -o out.tex in.md, then refine and compile to a polished PDF. Full command reference and workflow inside.

To convert Markdown to LaTeX, use Pandoc: pandoc paper.md -o paper.tex produces a .tex file you can refine and compile to a polished PDF. Pandoc passes through LaTeX math, converts tables and footnotes, and even handles citations from a .bib file. This lets you draft quickly in Markdown and finish with LaTeX-quality typesetting. Here is the workflow.

1. The core conversion

# Markdown to LaTeX source (then edit + compile)
pandoc paper.md -o paper.tex

# Markdown straight to PDF (needs a LaTeX engine)
pandoc paper.md -o paper.pdf

The two-step path (.md → .tex → PDF) is best when you want to fine-tune layout; the direct path is fastest for a quick draft.

2. Command reference

| Goal | Command | |---|---| | Standalone document (with preamble) | pandoc -s in.md -o out.tex | | Choose PDF engine | pandoc in.md --pdf-engine=xelatex -o out.pdf | | Use a custom template | pandoc in.md --template=mytemplate.tex -o out.tex | | Add a title/author | YAML block at top of the .md | | Table of contents | pandoc --toc -s in.md -o out.tex |

3. Math transfers cleanly

Write math in TeX syntax inside your Markdown and Pandoc passes it through untouched:

Inline $E = mc^2$ and a displayed equation:

$$\int_0^\infty e^{-x}\,dx = 1$$

This becomes proper LaTeX math in the output — see the math equations guide for the syntax.

4. Citations from a .bib

pandoc paper.md --citeproc --bibliography=refs.bib -o paper.tex

Write [@vaswani2017] in Markdown and Pandoc formats the citation and reference list. Pair it with your Zotero export and see citations in LaTeX.

5. When to convert vs write LaTeX directly

Convert when a co-author drafted prose in Markdown or Word; write LaTeX directly for math- and table-heavy sections where you want full control — the trade-off mirrors LaTeX vs Word. After converting, refine the .tex and compile in LetX for an instant PDF, no install.

→ Paste your converted .tex into LetX and publish a polished PDF in seconds.


Written by Shihab Shahriar Antor — AI Engineer & Founder of Shahriar Labs, maker of LetX.

Frequently Asked Questions

Can Pandoc convert Markdown directly to PDF?

Yes. pandoc in.md -o out.pdf converts Markdown to PDF, but it does so by generating LaTeX internally and compiling it, so you need a LaTeX engine installed (or use --pdf-engine to pick one). If you want to refine the typesetting, convert to .tex first with pandoc in.md -o out.tex, then edit and compile the LaTeX yourself. This two-step path gives you full control over the final layout.

How are equations handled when converting Markdown to LaTeX?

Pandoc reads LaTeX math written inside dollar signs in your Markdown — $E=mc^2$ for inline and $$...$$ for display — and passes it through to the LaTeX output unchanged. So if you already write math in TeX syntax in your Markdown, it transfers perfectly. Tables, code blocks, footnotes, and citations also convert, making Pandoc Markdown a viable lightweight front end for LaTeX documents.

Can Pandoc handle citations from a .bib file?

Yes, with the --citeproc flag and a bibliography. Write citations as [@key] in Markdown, point Pandoc at your references with --bibliography=refs.bib, and it formats them using a CSL style or passes them to BibLaTeX. This lets you draft in plain Markdown with simple [@author2024] citations and still produce a properly formatted reference list in the LaTeX or PDF output.