Creating a PDF
To produce a PDF, specify an output file with a .pdf
extension:
pandoc test.txt -o test.pdf
By default, pandoc will use LaTeX to create the PDF, which requires that a LaTeX engine be installed (see --pdf-engine
below).
Alternatively, pandoc can use ConTeXt, pdfroff
, or any of the following HTML/CSS-to-PDF-engines, to create a PDF: wkhtmltopdf
, weasyprint
or prince
. To do this, specify an output file with a .pdf
extension, as before, but add the --pdf-engine
option or -t context
, -t html
, or -t ms
to the command line (-t html
defaults to --pdf-engine=wkhtmltopdf
).
PDF output uses variables for LaTeX (with a LaTeX engine); variables for ConTeXt (with ConTeXt); or variables for wkhtmltopdf
(an HTML/CSS-to-PDF engine; --css
also affects the output).
To debug the PDF creation, it can be useful to look at the intermediate representation: instead of -o test.pdf
, use for example -s -o test.tex
to output the generated LaTeX. You can then test it with pdflatex test.tex
.
When using LaTeX, the following packages need to be available (they are included with all recent versions of TeX Live): amsfonts
, amsmath
, lm
, unicode-math
, ifxetex
, ifluatex
, listings
(if the --listings
option is used), fancyvrb
, longtable
, booktabs
, graphicx
and grffile
(if the document contains images), hyperref
, xcolor
, ulem
, geometry
(with the geometry
variable set), setspace
(with linestretch
), and babel
(with lang
). The use of xelatex
or lualatex
as the PDF engine requires fontspec
. xelatex
uses polyglossia
(with lang
), xecjk
, and bidi
(with the dir
variable set). If the mathspec
variable is set, xelatex
will use mathspec
instead of unicode-math
. The upquote
and microtype
packages are used if available, and csquotes
will be used for typography if \usepackage{csquotes}
is present in the template or included via /H/--include-in-header
. The natbib
, biblatex
, bibtex
, and biber
packages can optionally be used for citation rendering. The following packages will be used to improve output quality if present, but pandoc does not require them to be present: upquote
(for straight quotes in verbatim environments), microtype
(for better spacing adjustments), parskip
(for better inter-paragraph spaces), xurl
(for better line breaks in URLs), bookmark
(for better PDF bookmarks), and footnotehyper
or footnote
(to allow footnotes in tables).