# Pandoc: minimal headers for LaTeX output

I'm taking mediawiki text and trying to convert it to latex in Pandoc. All seems to be reasonably well.

However, I had to make sure to use:

\documentclass{book}
\usepackage{hyperref}
\begin{document}
... pandoc output ...
\end{document}


to get LaTeX to work at all - specifically, importing hyperref wasn't particularly intuitive.

Is there a canonical list of packages I should be importing to handle any output from pandoc -f latex ? Or even just a list of "you should import this to cover this use-case".

(I ask because I have further problems deep inside my document, and suspect this is the cause instead of Pandoc producing malformed LaTeX.)

GarethJones is absolutely right; using -s (--standalone) gets you the headers for free, and was exactly what I needed.

I also needed to use xelatex rather than latex in order to properly support unicode in order to parse some of the odder unicode characters (left-to-right direction marks, amongst others) and to ensure it output the correct ligatures (fl was being converted to Æ rather than ﬂ)

• Were you using the -s (--standalone) option? (Just a thought, having read the manual yesterday to determine if PanDoc could solve a problem I had. It couldn’t, but for some reason that option stuck in my memory. As far as I can tell, with the -s option, it should output the LaTeX preamble itself.) – Gareth Jones Jun 25 '13 at 14:39
• This is totally the answer I needed, thank you. Would you like to make it a question so you can get a big tick? :) – Dragon Jul 18 '13 at 17:34
• You can also use a template – henrique Jul 18 '13 at 18:43
• You shouldn't edit your question to ask a new one. Anyway, check slightly above pandoc.org/README.html#citation-rendering, --latex-engine=xelatex, but this only matters if you output to pdf directly, otherwise you just run whatever LaTeX-engine you want on the .tex file generated – Tobias Kienzler Dec 11 '15 at 10:58

First of all, since you seem to use pandoc to generate a .tex-file – which as Gareth commented, needs the additional option -s or --standalone if you want a fully compileable file instead of a snippet that you could \include yourself in another TeX-file – it would be your choice afterwards to run xelatex instead of pdflatex.

However, if you want to obtain a pdf directly (e.g. via pandoc -t somefile.pdf ...), then indeed you can choose xelatex (or lualatex) instead of the default pdflatex via --latex-engine=pdflatex|lualatex|xelatex. Note that in this case, the -s switch is implicitly active and doesn't need to be specified (though it doesn't harm).

(note that in pandoc 2.0 and higher, the command-line argument --latex-engine has changed to --pdf-engine.)

A bit of searching for latex on the pandoc site shows

Production of a PDF requires that a LaTeX engine be installed (see --latex-engine, below), and assumes that the following LaTeX packages are available: amssymb, amsmath, ifxetex, ifluatex, listings (if the --listings option is used), fancyvrb, longtable, url, graphicx, hyperref, ulem, babel (if the lang variable is set), fontspec (if xelatex or lualatex is used as the LaTeX engine), xltxtra and xunicode (if xelatex is used).