Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple and fast PDF compilation with Pandoc

I am writing a document using Pandoc and I'm visualizing it by compiling to PDF, since that's the end format that the document is going to have.

When the file was small it was very fast, but now that I have several figures, a lot of text, bibliography, etc., the compilation takes about 5 to 7 seconds every time. Is there a way to speed up that process?

Some thoughts:

  • I have already created a fast.latex template that I'm using with as few options/packages as possible
  • Every time Pandoc compiles the PDF, I believe it's actually calling pdflatex twice and also bibtex, which sometimes is not necessary.

So if speeding up a "full" compilation isn't possible, at least there should be a way to tell Pandoc to use only one pdflatex for times you don't change anything but some text (I think).

like image 344
TomCho Avatar asked Oct 16 '25 22:10

TomCho


1 Answers

I can think of a few things:

  • Create a minimal latex template (you already did that)
  • To call latex only once: write a bash script with pandoc -o out.tex && pdflatex out.tex
  • maybe another pdf generator is faster than pdflatex:
    • wkhtmltopdf: pandoc -t html5 -o out.pdf
    • ConTeXt: pandoc -t context -o out.pdf
    • or even xelatex: pandoc --latex-engine xelatex
  • Turn off images / toc generations etc. in latex if you don't need it to preview. Try pdflatex -draftmode or outputting to dvi. (see Speeding up LaTeX compilation)
like image 79
mb21 Avatar answered Oct 19 '25 03:10

mb21



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!