Skip to main content

Pandoc cheat sheet

Summary

Cheat sheet for Pandoc, the versatile free-software document converter, to convert files from one markup format into another. Pandoc is widely used for publishing workflows.

Introduction #

Pandoc is a versatile document conversion tool that allows you to convert files between various markup formats. Here are some of the most common Pandoc commands:

Basic Conversions #

Markdown to Word #

Converts input.md to output.docx Word document:

pandoc input.md -o output.docx

Markdown to PDF #

Convert input.md to output.pdf:

pandoc input.md -o output.pdf

HTML to PDF #

Convert input.html to output.pdf:

pandoc input.html -o output.pdf

Markdown to EPUB #

Convert input.md to output.epub ebook format:

pandoc input.md -o output.epub

Working with Multiple Files #

Concatination #

Combines (concatinates) multiple input files, e.g. file1.txt and file2.txt, into a single output.pdf file:

pandoc file1.txt file2.txt -o output.pdf

Custom styling #

Specifying Output Template #

Applies a custom, e.g. LaTeX template, to PDF output:

pandoc input.md -o output.pdf --template=mytemplate.tex

Custom CSS Styles #

Applies custom CSS styles from mystyles.css to the HTML output:

pandoc input.md -o output.html --css=mystyles.css

Syntax Highlighting #

Enables syntax highlighting using Pygments for HTML output:

pandoc input.md -o output.html --syntax-highlight=pygments

Custom elements #

Including table of contents #

To add a table of contents to the output PDF (requires, e.g. input.md to make use of heading levels).

pandoc input.md -o output.pdf --toc

Setting Metadata #

Set custom document metadata, such as title:

pandoc input.md -o output.pdf --metadata title="My Document"

Numbered Sections #

Numbers the sections in the output document:

pandoc input.md -o output.pdf --number-sections

Usage format #

Converting to Slides #

Converts ‘input.md’ to a output.pdf Beamer presentation in PDF format:

pandoc input.md -t beamer -o output.pdf

These are just a few examples, and Pandoc supports many more options and formats. You can refer to the official documentation for a comprehensive list of commands and options.


Further readings #

Sources and recommended, further resources on the topic:

Author

Jonas Jared Jacek • J15k

Jonas Jared Jacek (J15k)

Jonas works as project manager, web designer, and web developer since 2001. On top of that, he is a Linux system administrator with a broad interest in things related to programming, architecture, and design. See: https://www.j15k.com/

License

License: Pandoc cheat sheet by Jonas Jared Jacek is licensed under CC BY-SA 4.0.

This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only. To give credit, provide a link back to the original source, the author, and the license e.g. like this:

<p xmlns:cc="http://creativecommons.org/ns#" xmlns:dct="http://purl.org/dc/terms/"><a property="dct:title" rel="cc:attributionURL" href="https://www.ditig.com/publications/pandoc-cheat-sheet">Pandoc cheat sheet</a> by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://www.j15k.com/">Jonas Jared Jacek</a> is licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="license noopener noreferrer">CC BY-SA 4.0</a>.</p>

For more information see the DITig legal page.


“Less is more.”

Ludwig Mies van der Rohe, German architect and designerWord of mouth, - IT quotes