Search code examples
rstudiorenderingquartoxelatex

Quarto rendering pdf (running xelatex) faster in Rstudio


I am wondering if it is possible to render quarto document faster.

When I render my document I get these messages in the "Background Jobs" window:

running xelatex - 1
  This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode
  
running xelatex - 2
  This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode
  
running xelatex - 3
  This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

All the way until:

running xelatex - 10
  This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode
  
WARNING: maximum number of runs (9) reached

Output created:

Does anyone know what those 10 "running xelatex mean ? Is there a way to decrease this number of runs and what is the impact on the final rendering ?


Solution

  • Quarto generates PDF via LaTeX by default. The LaTeX processors sometimes require multiple runs, as they step through the document sequentially and need a another run to, for example, update the table of contents after seeing another heading. Usually two runs are enough, but some LaTeX packages require more runs to get the correct output. Ten runs is quite unusual though, there might be something wrong elsewhere.

    Quarto uses a heuristic to determine if it needs to run the LaTeX engine once more. Quarto also installs any missing LaTeX packages automatically. However, the tool latexmk is probably better in determining when to do additional calls to xelatex. You can use this tool with Quarto:

    ---
    format:
      pdf:
        pdf-engine: latexmk
        pdf-engine-opt: -xelatex
    ---
    

    If the document still requires 10 runs, then there might be an issue with a LaTeX package somewhere.