4

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).

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
TomCho
  • 3,204
  • 6
  • 32
  • 83
  • There are some tips for precompiling the preamble as well, see [compiling - Speeding up LaTeX compilation - TeX - LaTeX Stack Exchange](https://tex.stackexchange.com/questions/8791/speeding-up-latex-compilation) – user202729 Oct 23 '21 at 14:22

1 Answers1

4

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)
mb21
  • 34,845
  • 8
  • 116
  • 142
  • Splitting out the call to pdflatex worked great for me. Even for a simple document, it reduced the compilation time from 4 seconds to 1 second. – ankh-morpork May 11 '19 at 19:24
  • Unfortunately html5 doesn't support much of TeX formulas? (besides, for preview you can also view the HTML directly) // I doubt that context or XeLaTeX is faster however. ____________________________________________________________________________________________ For the "call LaTeX only once" approach you need `--standalone` flag, see [pandoc manual](https://pandoc.org/MANUAL.html#using-pandoc) for more details. – user202729 Oct 24 '21 at 02:00