When the -s/--standalone
option is used, pandoc
uses a template to add header and footer material that is needed for
a self-standing document. To see the default template that is used,
just type
pandoc -D FORMAT
where FORMAT
is the name of the output format. A
custom template can be specified using the
--template
option. You can also override the
system default templates for a given output format
FORMAT
by putting a file
templates/default.FORMAT
in the user data
directory (see --data-dir
, above).
Exceptions: For odt
output,
customize the default.opendocument
template. For
pdf
output, customize the
default.latex
template.
Templates may contain variables. Variable names
are sequences of alphanumerics, -
, and
_
, starting with a letter. A variable name
surrounded by $
signs will be replaced by its
value. For example, the string $title$
in
<title>$title$</title>
will be replaced by the document title.
To write a literal $
in a template, use
$$
.
Some variables are set automatically by pandoc. These vary somewhat
depending on the output format, but include metadata fields (such as
title
, author
, and
date
) as well as the following:
header-includes
contents specified by
-H/--include-in-header
(may have multiple
values)
toc
non-null value if --toc/--table-of-contents
was specified
include-before
contents specified by
-B/--include-before-body
(may have multiple
values)
include-after
contents specified by
-A/--include-after-body
(may have multiple
values)
body
body of document
lang
language code for HTML or LaTeX documents
slidy-url
base URL for Slidy documents (defaults to
http://www.w3.org/Talks/Tools/Slidy2
)
slideous-url
base URL for Slideous documents (defaults to
slideous
)
s5-url
base URL for S5 documents (defaults to
s5/default
)
revealjs-url
base URL for reveal.js documents (defaults to
reveal.js
)
theme
reveal.js or LaTeX beamer theme
transition
reveal.js transition
fontsize
font size (10pt, 11pt, 12pt) for LaTeX documents
documentclass
document class for LaTeX documents
classoption
option for LaTeX documentclass, e.g.
oneside
; may be repeated for multiple
options
geometry
options for LaTeX geometry
class, e.g.
margin=1in
; may be repeated for multiple
options
linestretch
adjusts line spacing (requires the setspace
package)
fontfamily
font package to use for LaTeX documents (with pdflatex):
TeXLive has bookman
(Bookman),
utopia
or fourier
(Utopia), fouriernc
(New Century
Schoolbook), times
or
txfonts
(Times),
mathpazo
or pxfonts
or
mathpple
(Palatino),
libertine
(Linux Libertine),
arev
(Arev Sans), and the default
lmodern
, among others.
mainfont
, sansfont
,
monofont
, mathfont
fonts for LaTeX documents (works only with xelatex and lualatex)
colortheme
colortheme for LaTeX beamer documents
fonttheme
fonttheme for LaTeX beamer documents
linkcolor
color for internal links in LaTeX documents
(red
, green
,
magenta
, cyan
,
blue
, black
)
urlcolor
color for external links in LaTeX documents
citecolor
color for citation links in LaTeX documents
links-as-notes
causes links to be printed as footnotes in LaTeX documents
toc
include table of contents in LaTeX documents
toc-depth
level of section to include in table of contents in LaTeX documents
lof
include list of figures in LaTeX documents
lot
include list of tables in LaTeX documents
biblio-style
bibliography style in LaTeX, when used with
--natbib
biblio-files
bibliography files to use in LaTeX, with
--natbib
or --biblatex
section
section number in man pages
header
header in man pages
footer
footer in man pages
Variables may be set at the command line using the
-V/--variable
option. Variables set in this way
override metadata fields with the same name.
Templates may contain conditionals. The syntax is as follows:
$if(variable)$ X $else$ Y $endif$
This will include X
in the template if
variable
has a non-null value; otherwise it will
include Y
. X
and
Y
are placeholders for any valid template text,
and may include interpolated variables or other conditionals. The
$else$
section may be omitted.
When variables can have multiple values (for example,
author
in a multi-author document), you can use
the $for$
keyword:
$for(author)$ <meta name="author" content="$author$" /> $endfor$
You can optionally specify a separator to be used between consecutive items:
$for(author)$$author$$sep$, $endfor$
A dot can be used to select a field of a variable that takes an object as its value. So, for example:
$author.name$ ($author.affiliation$)
If you use custom templates, you may need to revise them as pandoc changes. We recommend tracking the changes in the default templates, and modifying your custom templates accordingly. An easy way to do this is to fork the pandoc-templates repository (http://github.com/jgm/pandoc-templates) and merge in changes after each pandoc release.