5.4 Use a custom Pandoc LaTeX template
Pandoc converts Markdown to LaTeX through a template. The template is a LaTeX file containing Pandoc variables, and Pandoc will replace these variables with their values. Below is a simple template that only contains a single variable
The value of
$body$ is the LaTeX code generated from the body of the Markdown document. For example, if the body text is
Hello **world**! in Markdown, the value of
$body$ will be
If the LaTeX customization methods in Sections 5.1 and 5.3 are not enough for you, you may try to use a custom template instead. A template allows you to use arbitrary LaTeX code in it, hence is much more flexible. To use a template, include the path of the template in the
template option of
If you want to use Pandoc’s own LaTeX template, set
template: null. The default LaTeX template in the rmarkdown package is a customized version of Pandoc’s LaTeX template.
For the full list of Pandoc variables and their meanings, see Pandoc’s manual at https://pandoc.org/MANUAL.html#templates.