Markdown to PDF with Pandoc

Requirement

apt install pandoc lmodern texlive-latex-base texlive-fonts-recommended pandoc-citeproc
apt install texlive-xetex texlive-lang-cyrillic
apt install texlive-plain-generic #ulem.py

PDF documents and slides

We’re using a combination of command line arguments and a LaTeX preamble.

Command lines:

https://pub.nethence.com/bin/pandocument.bash.txt

https://pub.nethence.com/bin/pandocslides.bash.txt

Preambles:

https://pub.nethence.com/bin/preamble.tex.txt

https://pub.nethence.com/bin/preamble.slides.tex.txt

Tips & tricks

Given input markdown as such

some title
http://some-link/

this regex makes the trick to happend the links after a carriage return on the resulting PDF

sed -r 's@^([^#h$-].+)@\1 \\@' links.md > linksfix.md
pandocument.bash linksfix.md

Troubleshooting

! Package graphics Error: Division by 0.

==> Latex needs headers. It does not matter whether the image is online or local. Its size does not matter either.

Graphics division by zero https://texfaq.org/FAQ-divzero

Pandoc-generated PDF contains large images, how can I make them fit into the page? https://tex.stackexchange.com/questions/159948/pandoc-generated-pdf-contains-large-images-how-can-i-make-them-fit-into-the-pag

[WARNING] Missing character: There is no я in font [lmroman10-regular]:mapping=tex-text;!

==> use an appropriate font as shown above.

Resources

Pandoc User’s Guide https://pandoc.org/MANUAL.html

Installing pandoc http://pandoc.org/installing.html

Index of /demo http://pandoc.org/demo/

Tutorial 17.3 - Markdown and Pandoc https://www.flutterbys.com.au/stats/tut/tut17.3.html

Academic Pandoc template https://maehr.github.io/academic-pandoc-template/markdown.html

Easy LaTeX with Markdown and Pandoc http://tech.lauritz.me/easy-latex-with-markdown-pandoc/

pandoc: Conversion between markup formats https://hackage.haskell.org/package/pandoc

enable citations https://gist.github.com/maxogden/97190db73ac19fc6c1d9beee1a6e4fc8

margins https://pandoc.org/faqs.html#how-do-i-change-the-margins-in-pdf-output

beamer https://andrewgoldstone.com/blog/2014/12/24/slides/ http://nval.andreasherten.de/2016/01/26/latex-beamer-with-markdown.html https://andrewgoldstone.com/blog/2014/12/24/slides/

alternative with Markdown -> HTML -> PDF https://github.com/cwjohan/markdown-to-html https://julien.ponge.org/blog/exporting-html-slides-in-markdown-to-pdf/

tweaks

How to remove figure label? https://tex.stackexchange.com/questions/21795/how-to-remove-figure-label

utf8

Cyrillic in (La)TeX https://tex.stackexchange.com/questions/816/cyrillic-in-latex

pdflatex and some fonts https://gist.github.com/rain1024/98dd5e2c6c8c28f9ea9d

line breaks

Preserve line breaks in title using pandoc https://stackoverflow.com/questions/28283008/preserve-line-breaks-in-title-using-pandoc

Allow multiline Markdown headers #82 https://github.com/jgm/pandoc/issues/82

Multi line titles with pandoc https://tex.stackexchange.com/questions/502581/multi-line-titles-with-pandoc

Preserve line breaks in title using pandoc https://stackoverflow.com/questions/28283008/preserve-line-breaks-in-title-using-pandoc

Extension: escaped_line_breaks https://pandoc.org/MANUAL.html#extension-escaped_line_breaks