Pandoc
Convert documents with Pandoc
Use pandoc (Pandoc's CLI tool) to convert between document formats. The format is inferred from file extensions.
pandoc input.md -o output.docxForce the input/output format explicitly with -f (from) and -t (to):
pandoc -f markdown -t html input.md -o output.htmlMarkdown to PDF
Requires a LaTeX engine (tectonic, xelatex, or pdflatex).
pandoc input.md -o output.pdf --pdf-engine=tectonicFor non-Latin scripts or custom fonts, use XeLaTeX and set a Unicode font:
pandoc input.md -o output.pdf --pdf-engine=xelatex -V mainfont="EB Garamond"Markdown to Word (and back)
pandoc input.md -o output.docx
pandoc input.docx -o output.mdMatch your organisation's styling by supplying a reference document:
pandoc input.md -o output.docx --reference-doc=template.docxGenerate the reference template to edit, then reuse it:
pandoc -o template.docx --print-default-data-file reference.docxStandalone HTML
-s produces a full document (with <head>), not just a fragment. --toc adds a table of contents.
pandoc input.md -s --toc -o output.htmlEmbed all images, CSS, and fonts into a single self-contained file:
pandoc input.md -s --embed-resources -o output.htmlTable of contents, sections, and metadata
pandoc input.md -s --toc --toc-depth=2 -o output.htmlSet title, author, and date without editing the source:
pandoc input.md -s -M title="Report" -M author="Stathis" -o output.htmlCitations and bibliographies
Use --citeproc with a .bib file and an optional CSL style:
pandoc input.md --citeproc --bibliography=refs.bib --csl=ieee.csl -o output.pdfSyntax highlighting
List available themes, then apply one:
pandoc --list-highlight-styles
pandoc input.md -s --highlight-style=github -o output.htmlSlides
Pandoc builds reveal.js (HTML) or Beamer (PDF) slide decks. Split slides with ## headings or ---.
pandoc slides.md -t revealjs -s -o slides.html
pandoc slides.md -t beamer -o slides.pdfUseful 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/.pptxoutput from a template.--embed-resources— inline images/CSS/fonts into a single HTML file.--citeproc— process citations via--bibliographyand--csl.-V key=value— set template variables (e.g.mainfont,geometry).
List every supported format:
pandoc --list-input-formats
pandoc --list-output-formats