Pandoc has an official Docker image pandoc/latex. I like to use the Eisvogel LaTeX template. Unfortunately, you cannot build PDFs from Markdown using this template with pandoc/latex. Some packages from TeX Live are missing.
Therefore, I created a Docker image based on pandoc/latex that can build PDFs using Eisvogel. You can find it on Docker Hub under rstropek/pandoc-latex.
The examples folder contains an example document (markdown content, YAML metadata) including the generated PDF document.
The following docker run
statement will generate mydoc.pdf from the markdown file mydoc.md with the YAML metadata in mydoc.yaml. Try to run the statement inside the example folder.
Several optional packages, mentioned by pandoc/latex, are preinstalled in the image.
That includes sectsty, for those who want to add line breaks before chapters without using the book property.
See this issue for more details.
Tested with Eisvogel LaTeX template 2.4.0.
docker run --rm \
-v `pwd`:/data \
-w /data \
rstropek/pandoc-latex \
-f markdown \
--template https://raw.githubusercontent.com/Wandmalfarbe/pandoc-latex-template/v2.4.0/eisvogel.tex \
-t latex \
-o mydoc.pdf \
--metadata-file=mydoc.yaml \
mydoc.md
docker run --rm ^
-v %cd%:/data ^
-w /data ^
rstropek/pandoc-latex ^
-f markdown ^
--template https://raw.githubusercontent.com/Wandmalfarbe/pandoc-latex-template/v2.4.0/eisvogel.tex ^
-t latex ^
-o mydoc.pdf ^
--metadata-file=mydoc.yaml ^
mydoc.md
# Use a significative tag
# (e.g. here, follow the version of pandoc/latex used as the basis in the Dockerfile).
docker build -t rstropek/pandoc-latex:latest .
Make sure you have BATS installed.
bats tests
To insert manual page breaks, download pagebreak.lua. In the docker run
statement shown above, you can reference it using the --lua-filter pagebreak.lua
switch (e.g. docker run ... rstropek/pandoc-latex -f markdown ... -t latex --lua-filter pagebreak.lua ...
). Once you did that, you can add page breaks in your .md files using \newpage
. Example:
# Chapter 1
Some text goes here.
\newpage
# Chapter 2
Additional text goes here.
You can read about citations in the Pandoc documentation. Here is a checklist for what you have to do:
- Find a citation style that you would like to use.
- Get the link to the CSL file (e.g. https://www.zotero.org/styles/ieee for citation style IEEE).
- Create a bibliography file. Example bib.yaml:
references:
- title: Azure Homepage
container-title: Microsoft Website
id: Azure-Homepage
author: Microsoft
URL: https://azure.microsoft.com
type: webpage
- Add references to markdown (e.g.
Bla bla [see @Azure-Homepage]. Bla bla.
). - Add the following options to the call to Pandoc:
--filter pandoc-citeproc --bibliography=bib.yaml --csl=https://www.zotero.org/styles/ieee