Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a title page, page headers and footers using Pandoc

Tags:

pandoc

How do you specify that Pandoc should use a specific header and footer when generating a PDF from Markdown?

Currently I use the following to create my doc from the command line:

pandoc -s -V geometry:margin=1in --number-sections -o doc.pdf doc.mkd

This gives a lovely result with numbered sections.

What I would like to do, is to include a header and footer on each page. How do I go about it?

The extensions mechanism, e.g. pandoc_title_block may hold the key, but how do you use it?

Lastly (as a bonus), is there some way to create a title page for a document using pandoc?

like image 437
Jack Avatar asked Oct 16 '13 07:10

Jack


People also ask

How do you add a header in Markdown?

We can insert headings and subheadings in R Markdown using the pound sign # . There are six heading/subheading sizes in R Markdown. The number of pound signs before your line of text determines the heading size, 1 being the largest heading and 6 being the smallest.

How do I use pandoc Markdown PDF?

There are actually two steps involved in converting a Markdown file to a PDF file: The Markdown source file is converted to a LaTeX source file. Pandoc invokes the pdflatex or xelatex or other TeX command and converts the . tex source file to a PDF file.


1 Answers

When using the -s (--standalone) argument for the generation of PDFs, Pandoc uses a specific LateX template.

You can look at the template with pandoc -D latex and notice that there are many variables that you can set (the same way you did you with -V geometry:margin=1in in your command).

In order to add a specific header/footer, you can modify this template and use the --template argument in the command line.

You can get more information here Pandoc demo templates

like image 158
garnierclement Avatar answered Sep 20 '22 12:09

garnierclement