### Discussed in https://github.com/quarto-dev/quarto-cli/discussions/3517

<div type='discussions-op-text'>

<sup>Originally posted by **jpatteet** November 30, 2022</sup>
I asked a question on stackoverflow and got an answer that resolved the problem. I am posting both here, maybe it is worth some modifications in quarto or not, let me know what you think.

**Question:**

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 ?

**Answer:**

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.

**Comment:**

I added pdf-engine: latexmk and pdf-engine-opt: -xelatex and now it does not even tell me running xelatex and renders the document very quickly </div>
dragonstyle
2022-11-30T10:31:28Z
jpatteet
v1.4
closed
Quarto rendering pdf, running xelatex 10 times
https://github.com/quarto-dev/quarto-cli/issues/3518