LCM Logo
Documents & Publishing

Pandoc

Convert documents with Pandoc

Use pandoc (Pandoc's CLI tool) to convert between document formats. The format is inferred from file extensions.

shell
pandoc input.md -o output.docx

Force the input/output format explicitly with -f (from) and -t (to):

shell
pandoc -f markdown -t html input.md -o output.html

Markdown to PDF

Requires a LaTeX engine (tectonic, xelatex, or pdflatex).

shell
pandoc input.md -o output.pdf --pdf-engine=tectonic

For non-Latin scripts or custom fonts, use XeLaTeX and set a Unicode font:

shell
pandoc input.md -o output.pdf --pdf-engine=xelatex -V mainfont="EB Garamond"

Markdown to Word (and back)

shell
pandoc input.md -o output.docx
pandoc input.docx -o output.md

Match your organisation's styling by supplying a reference document:

shell
pandoc input.md -o output.docx --reference-doc=template.docx

Generate the reference template to edit, then reuse it:

shell
pandoc -o template.docx --print-default-data-file reference.docx

Standalone HTML

-s produces a full document (with <head>), not just a fragment. --toc adds a table of contents.

shell
pandoc input.md -s --toc -o output.html

Embed all images, CSS, and fonts into a single self-contained file:

shell
pandoc input.md -s --embed-resources -o output.html

Table of contents, sections, and metadata

shell
pandoc input.md -s --toc --toc-depth=2 -o output.html

Set title, author, and date without editing the source:

shell
pandoc input.md -s -M title="Report" -M author="Stathis" -o output.html

Citations and bibliographies

Use --citeproc with a .bib file and an optional CSL style:

shell
pandoc input.md --citeproc --bibliography=refs.bib --csl=ieee.csl -o output.pdf

Syntax highlighting

List available themes, then apply one:

shell
pandoc --list-highlight-styles
pandoc input.md -s --highlight-style=github -o output.html

Slides

Pandoc builds reveal.js (HTML) or Beamer (PDF) slide decks. Split slides with ## headings or ---.

shell
pandoc slides.md -t revealjs -s -o slides.html
pandoc slides.md -t beamer -o slides.pdf

Useful flags

  • -s / --standalone — emit a complete document rather than a fragment.
  • --toc — insert a table of contents; pair with --toc-depth=N.
  • --pdf-engine=ENGINE — choose the PDF backend (tectonic, xelatex, pdflatex, weasyprint).
  • --reference-doc=FILE — style .docx/.pptx output from a template.
  • --embed-resources — inline images/CSS/fonts into a single HTML file.
  • --citeproc — process citations via --bibliography and --csl.
  • -V key=value — set template variables (e.g. mainfont, geometry).

List every supported format:

shell
pandoc --list-input-formats
pandoc --list-output-formats

On this page