Quarto Extension
A simple Typst block rendered as an image:
Use comment+pipe syntax (//| key: value) at the top of the code block to set per-block options.
Control the width, height, and margin of the rendered image page. These options set the Typst page dimensions for image compilation. With output: asis, width and height are ignored; margin is applied as block inset.
Set the output image format and resolution:
Set text and page fill colours for rendered images. Values can be Typst colour literals, CSS hex strings (converted automatically), or auto (reads from _brand.yml).
Control horizontal alignment of the rendered image block.
Use //| label: and //| cap: for Quarto cross-references. Generic cap and alt options work with any label prefix. Prefix-specific variants (e.g., fig-cap, tbl-alt) override the generic options when the label matches. Any Quarto cross-reference type is supported (fig-, tbl-, lst-, etc.), including custom types.
See Figure 1 for a captioned figure.
```{typst}
//| label: fig-typst-shapes
//| cap: "A simple Typst diagram with shapes."
//| alt: "A blue circle and orange rectangle arranged horizontally."
#set text(size: 12pt)
#align(center)[
#stack(dir: ltr, spacing: 1em)[
#circle(radius: 1cm, fill: blue.lighten(60%))
][
#rect(width: 2cm, height: 2cm, fill: orange.lighten(60%))
]
]
```Figure 1: A simple Typst diagram with shapes.
The echo and eval options control whether source code is displayed and whether the block is compiled.
Show the source code followed by the rendered output with echo: true:
Use echo: fenced to display source code wrapped in fenced code block markers (```{typst}), including any comment+pipe options (except echo itself). This mirrors Quarto’s native echo: fenced behaviour for computational cells.
Display the source code without compiling with eval: false:
With eval: true (the default), the block is compiled:
Setting eval: false and echo: false hides the block entirely. Nothing is rendered.
Setting include: false suppresses all output (both source and rendered image). The block is completely hidden from the document, regardless of other options.
Setting output: false skips compilation and suppresses the rendered image. When combined with echo: true, only the source code is shown.
Setting output: asis passes the Typst code through natively when the output format is Typst. For all other formats, output: asis behaves the same as output: true (compiles to an image).
The output-location option controls where rendered output appears in Reveal.js presentations.
Pass key-value pairs to Typst code via sys.inputs. Global inputs are set in YAML; per-block inputs override them using comma-separated syntax.
When Typst produces multiple pages, all pages are included by default. Use pages to select specific pages and layout-ncol to arrange them in columns.
Render an external .typ file instead of inline code:
By default, compiled images are only stored in the internal cache directory (.quarto/typst-render/) with auto-generated filenames. Set output-directory to also save copies to a predictable location. Use output-filename to override the auto-generated filename.
Paths follow Quarto conventions: a leading / is relative to the project root, otherwise relative to the document directory.
When output-directory is set and no output-filename is given, the filename is auto-generated from the block label (e.g., fig-diagram.png) or block counter (e.g., typst-block-1.png).
When a label is present, the filename is derived from the label:
Figure 2: A block saved with an auto-generated filename.
Render Typst expressions inline using backtick code with the typst class. The rendered image scales to match the surrounding text size.
Here is a red word {typst} #text(red)[hello] in the middle of a sentence.
Inline maths: {typst} $ x^2 + y^2 = z^2 $ renders as a formula image.
Inline with explicit alt text: {typst} $pi r^2$ for the area of a circle.
Escaped inline code is not evaluated: `{typst} #text(red)[hello]`.
Social Card
A repository social card built entirely in Typst, rendered as a high-resolution PNG.