Chunk Options Reference

Options are written as YAML comments at the top of a chunk, one per line, prefixed with #|:

```{r}
#| label: my-chunk
#| echo: false
#| fig-width: 6
plot(1:10)
typst(current_plot())
```

Options can also be set globally in knot.toml under [chunk-defaults], [r-chunks], or [python-chunks]. Per-chunk options always override defaults.


Execution control

OptionTypeDefaultDescription
evalbooltrueIf false, the chunk is not executed and produces no output.
cachebooltrueIf false, the chunk always re-executes even if its hash has not changed.
freezelist[]Object names whose xxHash64 fingerprint must not change after this chunk. See The Freeze Contract.

Display control

OptionTypeDefaultDescription
showstring"both"What to display: "both", "code", "output", "none".
echobooltrueAlias for show: "output" when false. Kept for compatibility.

Labelling and captions

OptionTypeDefaultDescription
labelstringChunk identifier. Used as a Typst label (<label>) for cross-referencing.
fig-capstringCaption for the figure wrapper (enables Typst #figure).

Figure sizing

OptionTypeDefaultDescription
fig-widthnumber6Figure width in inches.
fig-heightnumber4Figure height in inches.
fig-dpinumber150Resolution in dots per inch (raster formats).
fig-formatstring"svg"Output format: "svg" or "png".

Warnings

OptionTypeDefaultDescription
warningbooltrueWhether to capture and display R/Python warnings.
warning-posstring"below"Where to show warnings: "above" or "below" the output.

Layout

OptionTypeDefaultDescription
layoutstring"vertical"How to arrange code and output: "vertical" or "horizontal".

Code styling (codly)

Options prefixed with codly- are passed directly to the codly Typst package for syntax highlighting customisation:

```{r}
#| codly-stroke: 2pt + red
#| codly-lang-radius: 8pt
x <- 1
```

Refer to the codly documentation for the full list of available options.

Dependencies

OptionTypeDefaultDescription
dependslist[]File paths that, when modified, invalidate this chunk's cache. Useful for chunks that read external files.

Example:

```{r}
#| depends: [data/raw.csv]
data <- read.csv("data/raw.csv")
```