Options

Every option the engine understands, in one table. Cell options are #| comments at the top of a cell; document options go under pari-gp: in the front matter. The five marked both are set document-wide and overridden per cell.

Option Scope Default Effect
eval both true Run the cell. false shows the code without running it.
echo both true Show the source.
output both true Show what gp printed. asis inserts it as raw markdown.
error both false true renders gp errors into the document; false stops the render.
include both true false drops the cell from the output entirely — it still runs.
classes cell Extra CSS classes for the code block.
filename cell Filename label above the code block.
label cell Cell label; fig-… makes a figure cross-referenceable.
fig-cap cell Figure caption.
fig-alt cell Accessible description of a figure.
fig-width cell CSS width for an inline SVG figure.
path document gp The gp executable, if it is not on PATH.
args document [] Extra arguments passed to gp, after -q -f.
stacksize document gp’s own parisize, as gp writes it: 32M, 1G.
primelimit document gp’s own primelimit, the precomputed prime table.
precision document gp’s own realprecision, in decimal digits.
bitprecision document gp’s own realbitprecision, instead of precision.
seriesprecision document gp’s own seriesprecision.
timeout document 300 Seconds before the render gives up on gp.
prelude document gp code run once, before the first cell.
highlight document true Inject the syntax definition into Pandoc.

“gp’s own” means the engine sets nothing and you get whatever the interpreter defaults to, which is what gp would do at the prompt.

Cell options

Written as #| comments at the top of a cell.

echo: false

Run it, show only the result:

The code that produced this line is hidden.

eval: false

Show it without running it — useful for code that is slow or needs data you do not ship:

\\ This never runs.
forprime(p = 2, 10^12, if (p % 4 == 1, print(p)))

output: asis

The output is inserted as markdown rather than wrapped in a code block, so gp can generate document structure:

  • 3! = 6
  • 4! = 24
  • 5! = 120

include: false

The cell runs — so later cells can use what it defines — but nothing appears:

secret
1729

Document options

Everything under pari-gp: in the front matter, all optional:

---
engine: pari-gp
pari-gp:
  path: gp              # gp executable, if it is not on PATH
  args: []              # extra arguments passed to gp
  stacksize: 32M        # parisize
  primelimit: 500000    # primelimit
  precision: 50         # realprecision, in decimal digits
  bitprecision: 128     # realbitprecision (alternative to precision)
  seriesprecision: 16   # seriesprecision
  timeout: 300          # seconds before the render gives up
  highlight: true       # inject the syntax definition automatically
  prelude: |            # gp code run once, before the first cell
    default(output, 0);
    read("mylib.gp");
  echo: true            # defaults for every cell in the document
  output: true
  error: false
---

echo, output, error, eval and include set the default for every cell; a cell option overrides it.

prelude

Useful for loading a library of your own, or changing how gp formats results. This page sets nothing, so matrices print in gp’s usual style:

factor(360)
[2 3]

[3 2]

[5 1]

Caching

Rendering re-runs every cell. For a document with a slow computation, let Quarto cache the result:

---
engine: pari-gp
freeze: auto      # re-run only when the document itself changes
---

freeze: true never re-runs, freeze: auto re-runs when the source changes. The cache lives in _freeze/ and is meant to be committed, so collaborators and CI reuse it rather than needing PARI/GP installed. What the engine stores there is relative to the document, so the cache replays on any machine.

Errors

By default a PARI/GP error stops the render, naming the cell and the message. When the error is the point, ask for it:

1/0
  ***   at top-level: 1/0
  ***                  ^--
  *** _/_: impossible inverse in gdiv: 0.

The session survives either way — gp keeps reading, so later cells still run:

6 * 7
42

gp’s *** Warning: lines are warnings, not errors: they are shown, but never stop a render.