Skip to main content

Professional and Accessible: Ten Small Typst Partials for Quarto PDFs

Ten small Typst partials give a Quarto PDF a consistent, branded look, each one written with accessibility in mind. Each partial is a file that you can copy, edit or delete, and the demo builds as a tagged PDF/UA-1 file.

quarto
typst
pdf
accessibility
Author
Published

Monday, the 30th of November, 2026

A few weeks ago, I saw someone ask for resources to customise the cover page of a Quarto Typst book. Since Quarto 1.9, a Typst book uses the orange-book template by default, as the 1.9 changelog says. So the question is a fair one. I use a handful of Typst tricks in my Quarto Typst format extensions, so I thought I would share them.

In this post, I show ten of them as small partials. They give a PDF a consistent, branded look, and I wrote each one with accessibility in mind. Each one is a separate file that you can copy and edit. They work on any Quarto Typst document, but a book needs a few changes. Along the way, I highlight the accessibility choices in callouts titled “Accessibility”.

Social card for the post. On the left, the title "Professional and
Accessible PDFs" with the line "Ten small Typst partials tricks for
Quarto." On the right, two pages of a demo report: a cover with blue
gradient stripes at the top and a gradient band at the bottom, and a
body page with the same stripes, numbered headings, a striped table and
a footer band.

1 How Partials Work

Quarto builds a Typst PDF in two steps. First, it turns your document into a Typst source file. Then Typst compiles that file into the PDF.

A partial is a file that Quarto pastes into that Typst source. It holds a few lines of Typst, such as a set rule or a show rule. Quarto offers two ways to load one.

  • include-in-header adds your file to the top of the Typst source, after Quarto’s own setup. Your rules then apply to the whole document. The Typst format page describes this option.
  • template-partials replaces one of Quarto’s own partials with your file, under the same name. The custom Typst formats page lists which partials you can replace. The default partials are on GitHub. They are the best place to read what you are replacing.

All ten tricks load through include-in-header. The title block also needs template-partials. If you want to go further and package your partials as an extension, my post on the document dispatcher is the next step.

2 The Demo Project

Note

The demo builds with Quarto 1.11.9, the current stable release, which ships Typst 0.15.1. I rendered the screenshots with a development build of Quarto that ships the same Typst version.

The demo has no _quarto.yml. The demo is a short report, _report.qmd, whose front matter holds the title, subtitle, category, date, date-format, lang, region and number-sections keys. The leading underscore tells Quarto to skip the file when it renders this website, so the report does not become a page of the blog. In your own project, you can name it report.qmd. Add this format block to that front matter to build it with all ten partials, as they stand after the last trick.

format block of each step
format:
  typst:
1    pdf-standard: ua-1
2    include-in-header:
      - partials/1-tokens.typ
      - partials/2-header-footer.typ
      - partials/3-headings.typ
      - partials/4-code.typ
      - partials/5-tables.typ
      - partials/6-captions.typ
      - partials/7-title-block.typ
      - partials/8-page-stripes.typ
      - partials/9-cover.typ
      - partials/10-cover-decoration.typ
    template-partials:
      - typst-show.typ
1
Ask Typst for a tagged PDF that follows PDF/UA-1, with the pdf-standard option. The Typst accessibility guide explains what the standard asks for. Typst checks the PDF against the standard and tags it, and pdfinfo reports Tagged: yes for the final demo. For example, an image with no alt text stops the build with the error PDF/UA-1 error: missing alt text.
2
Load the partials in this order. Removing a line removes that trick, unless a later partial needs it.

Some partials need an earlier one. In the diagram, an arrow points from a partial to the one it needs.

Dependency diagram. Tokens is needed by every other partial. Page stripes needs header and footer. Cover needs the title block, and cover decoration needs the cover. The typst-show file needs the title block.

Dependency diagram. Tokens is needed by every other partial. Page stripes needs header and footer. Cover needs the title block, and cover decoration needs the cover. The typst-show file needs the title block.

Figure 1: The partials that need an earlier partial.

The heading numbers come from number-sections: true in the front matter of _report.qmd, because Quarto sets the numbering after the partials run. The report, the ten partials and typst-show.typ are in the post folder on GitHub.

3 Two Ways to Load a Partial

The demo uses include-in-header, but Quarto offers a second way. You list your own files under template-partials, and you call each one from a partial that you override, with $name.typ()$. It is the way that quarto-mcanouil loads the files of its library.

front matter
format:
  typst:
    template-partials:
      - typst-show.typ
      - partials/1-tokens.typ
      - partials/2-header-footer.typ
      - partials/3-headings.typ
typst-show.typ
$1-tokens.typ()$

$2-header-footer.typ()$

$3-headings.typ()$

#show: doc => article(
  title: [$title$],
  lang: "$if(lang)$$lang$$else$en$endif$",
$if(region)$  region: "$region$",
$endif$  sectionnumbering: $if(section-numbering)$"$section-numbering$"$else$none$endif$,
  doc,
)

Put each call on its own line and leave a blank line between two calls. Without the blank line, Pandoc glues the end of one partial to the start of the next, and Typst stops with an error.

include-in-header template-partials
Setup One line of YAML per file. One line of YAML per file, plus one $name.typ()$ call in a partial that you override.
Where the file lands After Quarto’s own Typst setup and before page.typ and typst-show.typ. Where you call it.
Pandoc variables No. The file is pasted as it is, and $category$ stays as text. Yes. $title$ or $if(category)$ work, so a partial can read the YAML.
What it replaces Nothing. The default partial that you override, here typst-show.typ.
In a book Works, as the book section shows. Overriding typst-show.typ removes the setup of orange-book.
In an extension The user has to list the files. The extension lists them once, and the format gets them with it.
Upkeep None. Quarto’s own partials keep working. You own the partial that you override. Compare it with Quarto’s default at every release, or you can miss its fixes and new features.
TipDecision

Start with include-in-header, because it replaces nothing. Switch to template-partials when a partial must read the YAML, or when you ship the partials with a format extension. Every Quarto partial that you override becomes yours to maintain, so keep those overrides few and small.

4 Tokens

Keep every colour and font in one place, so changing a value changes the whole document. This principle holds in every programming language, from CSS variables to constants in R, so it applies to Typst too.

Before After
The first page with Libertinus Serif everywhere The first page with Source Sans 3 body text, Inter headings and an underlined blue link
partials/1-tokens.typ
// 1. Tokens: change a value here, change the whole document.
#let ink = rgb("#1f2933")
#let accent = rgb("#0b6e99")
#let muted = rgb("#586270")
#let tint = rgb("#eef3f7")
#let font-body = ("Source Sans 3", "Libertinus Serif")
#let font-heading = ("Inter", "Libertinus Serif")
#let font-code = ("Fira Code", "DejaVu Sans Mono")

#set text(font: font-body, fill: ink)
#show heading: set text(font: font-heading)
#show raw: set text(font: font-code)
#show link: set text(fill: accent)
#show link: underline
NoteAccessibility: Contrast

I computed the WCAG 2.x contrast ratios of these colours with a short script.

  • Ink on white is 14.76:1.
  • Accent on white is 5.67:1, and so is white on accent.
  • Muted on white is 6.18:1, and muted on the tint is 5.54:1.

Body text needs at least 4.5:1, so every pair passes. Links are underlined, so they do not rely on colour alone.

To compute a ratio, use the WebAIM contrast checker or the Colour Contrast Analyser from TPGi. To pick a palette that stays readable for colour-blind people, try ColorBrewer and Viz Palette. The WCAG explanation of contrast gives the thresholds.

6 Headings

I colour the heading numbers and keep a heading from being stranded at the bottom of a page.

Before After
The second page with plain black heading numbers The second page with blue heading numbers set apart from the heading text
partials/3-headings.typ
// 3. Headings: coloured numbers, never stranded at the bottom of a page.
#show heading: it => block(sticky: true, above: 1.6em, below: 0.8em)[
  #if it.numbering != none {
    text(fill: accent, counter(heading).display(it.numbering))
    h(0.5em)
  }
  #it.body
]
NoteAccessibility: Real headings

The partial restyles real headings. It does not fake them with big text, so the PDF keeps its heading structure. The numbers come from number-sections: true, because Quarto’s article() sets the numbering after the partials run. The partial only styles the number.

7 Code

I show code in a calm light block that never splits across pages and never turns characters into symbols.

Before After
The second page where Fira Code draws the pipe and arrow operators as symbols The second page where the same code shows plain characters in a light grey block
partials/4-code.typ
// 4. Code: 9.5 pt, no ligatures, no page break inside a block, light background.
#show raw: set text(size: 9.5pt, ligatures: false, features: ("calt": 0))
#show raw.where(block: true): set block(
  width: 100%, fill: tint, inset: 0.8em, radius: 4pt, breakable: false,
)
NoteAccessibility: Size, ligatures and page breaks

Code that looks different from what you typed is hard to read. With only ligatures: false, Fira Code still drew |> as a triangle, so I also turn off the calt feature with features: ("calt": 0). The symbols !=, <- and >= then show as typed. The breakable: false setting keeps a block on one page. This matters most in teaching materials, where learners must see exactly the characters they have to type. The partial sets the code text to 9.5 pt, because the default 0.8em of the body is 8.8 pt, a little under 9 pt. I use points there, because an em value would apply to the already reduced size.

8 Tables

I give tables a filled header and light stripes. These rules are plain Typst and need no library such as gt or great_tables, so every table gets the style, including a simple Markdown table in Quarto, and not only the tables that R or Python produce. My post on branded figures and tables covers those libraries.

Before After
The second page with a plain table that has a thin rule under its header The second page with a table that has a blue header with white text and light stripes
partials/5-tables.typ
// 5. Tables: filled header, zebra stripes.
#set table(
  fill: (_, y) => if y == 0 { accent } else if calc.odd(y) { tint },
  stroke: none,
  inset: 0.6em,
)
#show table.cell.where(y: 0): set text(fill: white, weight: "bold")
#show table: set text(size: 0.9em)
NoteAccessibility: Header row

The partial styles the header row. It does not replace it, so the table keeps its real header row. Tagged PDFs rely on table.header to tell readers and screen readers which cells are headings. The stripes only help the eye, because the header carries the meaning and colour is never the only signal.

9 Captions

I make captions small and muted, with the label in bold. This one is a matter of taste. I find it easier to read when “Table 1” and the caption text look different, so the label stays bold and the caption is smaller and muted.

Before After
The first page with plain captions in body text size The first page with small muted captions and a bold Table 1 label
partials/6-captions.typ
// 6. Captions: small, muted, with the label in bold when the figure is numbered.
#show figure.caption: set text(size: 0.85em, fill: muted)
#show figure.caption: it => {
  if it.numbering != none and it.supplement != none {
    strong(it.supplement + [ ] + context it.counter.display(it.numbering))
    [. ]
  }
  it.body
}
NoteWhat I left out

You do not need a partial for justified text or for the language. Quarto justifies text by default. Set lang: en-GB in the YAML and Typst uses it for hyphenation.

10 Title Block

I replace the default title with a title, a subtitle, a line that holds the category and the date, and a thin rule under them.

Before After
The first page with a centred title, subtitle and date The first page with a left-aligned title, the subtitle, a muted line with Finance and the date, and a thin grey rule under them
partials/7-title-block.typ
// 7. Title block: title, subtitle, category and date, then a hairline.
#let title-block(title: none, category: none, subtitle: none, date: none) = {
  text(font: font-heading, size: 2em, weight: "bold", title)
  if subtitle != none { v(0.4em); text(size: 1.15em, fill: muted, subtitle); v(0.2em) }
  let meta = (category, date).filter(item => item != none)
  if meta.len() > 0 { text(size: 0.85em, fill: muted, meta.join([ · ])) }
  v(0.8em)
  pdf.artifact(line(length: 100%, stroke: 0.5pt + muted.lighten(60%)))
  v(1em)
}

This one needs a second file, because Quarto decides what it passes to the title block in typst-show.typ. Quarto loads that file with template-partials.

typst-show.typ
#show: doc => article(
  lang: "$if(lang)$$lang$$else$en$endif$",
$if(region)$  region: "$region$",
$endif$  sectionnumbering: $if(section-numbering)$"$section-numbering$"$else$none$endif$,
  doc,
)
#set document(title: [$title$])
#title-block(
  title: [$title$],
$if(category)$  category: [$category$],
$endif$$if(subtitle)$  subtitle: [$subtitle$],
$endif$$if(date)$  date: [$date$],
$endif$)
WarningThe typst-show.typ of the demo

This file replaces Quarto’s default typst-show.typ, so it drops what the default does. That includes fonts, the table of contents and brand settings. Read the default before you copy mine, and keep what you need.

$title$ and $category$ are Pandoc variables. Pandoc fills them from the YAML, and category is a custom field that I added to the document. My file does not pass the title to article(), which then sets the document title to nothing. So I set it below the article() call with #set document(title: [$title$]). The PDF then keeps its title for screen readers and for the running header. The thin rule under the title block is wrapped in pdf.artifact() to state that it is decoration. Typst already treats a line as an artifact, so the wrapper is optional here.

11 Page Stripes

The decoration of this demo is a thick and a thin stripe at the top and a gradient band at the bottom, all in the accent colour. This trick puts them on every page, with the band behind the footer. The cover reuses the same style later in the post.

Before After
The second page with a plain top and bottom edge The second page with two blue gradient stripes at the top and a dark blue gradient band behind the footer with a white page number
partials/8-page-stripes.typ
// 8. Recurring decoration: stripes at the top, a gradient band behind the footer.
#let band-gradient = gradient.linear(accent, accent.darken(55%), angle: 135deg)
1#footer-ink.update(white)

#set page(background: pdf.artifact({
  place(top, dy: 8mm, rect(width: 100%, height: 4mm, fill: band-gradient, stroke: none))
  place(top, dy: 14mm, rect(width: 100%, height: 1mm, fill: band-gradient, stroke: none))
  place(bottom, rect(width: 100%, height: 1.25in, fill: band-gradient, stroke: none))
}))
1
Turns the footer text white, through the slot of Header and Footer.
NoteAccessibility: Decoration and contrast

Screen readers should skip decoration. Typst already marks page backgrounds and shapes as artifacts, so it skips the stripes and the band. I still wrap them in pdf.artifact() to say so. The band is dark, so the footer text turns white, which is 5.67:1 on the lightest end of the gradient. Text on a band needs its contrast checked again.

12 Cover Page

I give the title block a page of its own, centred vertically, with no header or footer.

Before After
The first page with the title block above the first section and stripes at the top and bottom A cover page with only the title, subtitle, category and date, centred vertically on a white page
partials/9-cover.typ
// 9. Cover page: the title block gets a page of its own.
1#let cover-art = state("cover-art", none)

#let title-block = {
  let block-on-page = title-block
  (..args) => page(
    header: none,
    footer: none,
    background: context cover-art.get(),
    align(horizon, block-on-page(..args)),
  )
}
1
A slot for the cover decoration. It stays empty until Cover Decoration fills it.
NoteWhy cover-art is a state

A Typst closure captures the variables it uses when you define it. A later #let cannot change a function that already exists. A state is read when the page is built, so Cover Decoration can fill the slot after this partial has run.

13 Cover Decoration

I fill the cover slot with a gradient band at the bottom and two stripes at the top.

Before After
The cover page with only text on a white page The cover page with a thick and a thin gradient stripe at the top and a dark blue gradient band over the bottom third
partials/10-cover-decoration.typ
// 10. Cover decoration: a gradient band at the bottom, two stripes at the top.
#let cover-gradient = gradient.linear(accent, accent.darken(55%), angle: 135deg)

1#cover-art.update(pdf.artifact({
  place(bottom, rect(width: 100%, height: 35%, fill: cover-gradient, stroke: none))
  place(top, dy: 12mm, rect(width: 100%, height: 10mm, fill: cover-gradient, stroke: none))
  place(top, dy: 26mm, rect(width: 100%, height: 2mm, fill: cover-gradient, stroke: none))
}))
1
Fills the slot of Cover Page.
NoteAccessibility: No text in the art

The decoration is only shapes and it sits behind the content. The title is dark ink on white, and the gradient band at the bottom holds nothing, so the cover text keeps its contrast.

14 Using the Tricks in a Quarto Book

A book gets only some of the tricks, because its template draws the cover and the title itself. A Quarto book project with format: typst uses the orange-book extension, which Quarto bundles since 1.9. It wraps the orange-book Typst package by Flavio Barisi, which is based on his original template. The package draws the cover and the chapter headings itself, and the typst-show.typ of the extension sets it up. I tested the partials in a book made with quarto create project book, with Quarto 1.11.9 and orange-book 0.7.1, and pdf-standard: ua-1 still gave a tagged PDF. The outline of orange-book stops the build with PDF/UA-1 error: invalid document structure when it lists subsections, so set toc-depth: 1 in the typst format.

Trick In a book
Tokens, Headings, Code, Tables, Captions Work as in a document, and the caption number follows the chapter, as in “Table 1.1”.
Header and Footer The footer works. The orange-book header stays, because the template sets it after your partial.
Page Stripes Works on every page, cover included. Load the footer partial before it, because that one holds the footer-ink state. Without it, the build stops with unknown variable: footer-ink.
Title Block, Cover Page, Cover Decoration Do not use them. They replace typst-show.typ, which holds the setup of orange-book, and the book then renders as a single page.

The tricks style the pages of a book, and Page Stripes also paints the cover, but none of them changes the layout of the cover. Four routes change the cover, from the lightest to the heaviest.

14.1 Change the Cover with a Brand File

The supported way to change the cover is a brand file, written in the brand.yml format. The extension passes color.primary as the main colour, and the title box uses it lightened by 70%. It also passes logo.medium, which the package puts at the top of the cover, 3 cm wide.

14.2 Decorate the Cover Page

The tricks do not target the cover, because orange-book draws it as the first page. To decorate that page alone, a partial has to target it. This partial paints the stripes and the band on page 1 only, in the same way as the cover of the demo. It overrides nothing, so it is the lighter option.

Before After
The cover of a default Quarto Typst book: a light blue box with the title and the author on a white page The same cover with two gradient stripes at the top and a dark blue gradient band at the bottom
book-cover.typ
// Book cover: decorate page 1 only, because orange-book draws the cover itself. Needs 1-tokens.typ for `accent`.
#let band = gradient.linear(accent, accent.darken(55%), angle: 135deg)
#set page(background: context if here().page() == 1 {
  pdf.artifact({
    place(bottom, rect(width: 100%, height: 35%, fill: band, stroke: none))
    place(top, dy: 12mm, rect(width: 100%, height: 10mm, fill: band, stroke: none))
    place(top, dy: 26mm, rect(width: 100%, height: 2mm, fill: band, stroke: none))
  })
})

Load it after 1-tokens.typ, because it reads accent from there.

NoteAccessibility: Check the cover contrast

The title box of orange-book stays in the middle of the page, away from the gradient, so its text keeps its contrast. If you move the band under the box, check the contrast again, as for any text on a band.

14.3 Add Cover Options with a typst-show.typ Override

The package has other cover options, such as cover, cover-background and copyright, but the extension does not read them from the YAML. I proposed a cover key for them in a pull request. The wider request, to expose more options of the package in the YAML, is quarto-cli issue 14270. Until it is merged, you can add the keys yourself. Copy the typst-show.typ of the extension, add these lines after its main-color line, and list the file under template-partials. You then maintain that copy at every Quarto release.

added to typst-show.typ
$if(cover.background)$
  cover-background: {
    let name = "$cover.background$"
    if name == "none" { none } else { brand-color.at(name) }
  },
$endif$
$if(cover.image)$
  cover: image("$cover.image$"$if(cover.alt)$, alt: "$cover.alt$"$endif$),
$endif$
$if(cover.copyright)$
  copyright: [$cover.copyright$],
$endif$
_quarto.yml
format:
  typst:
    template-partials:
      - typst-show.typ
    cover:
      background: secondary
      image: cover.png
      alt: A description of the image.
      copyright: Copyright 2026 Jane Smith.

background is the name of a colour of the brand file, because Pandoc escapes the # of a hex value. The name none drops the light box behind the title, which suits a cover that you decorate yourself. Without alt, pdf-standard: ua-1 stops the build, so the image always has a description.

A book cover with no box behind the title: the title and the author sit on a white page between gradient stripes at the top and a gradient band at the bottom

A book cover with no box behind the title: the title and the author sit on a white page between gradient stripes at the top and a gradient band at the bottom

This cover combines background: none with book-cover.typ.

This is the file of Quarto 1.11.9 with the lines above added.

typst-show.typ
#import "@preview/orange-book:0.7.1": book, part, chapter, appendices

#show: book.with(
$if(title)$
  title: [$title$],
$endif$
$if(subtitle)$
  subtitle: [$subtitle$],
$endif$
$if(by-author)$
  author: "$for(by-author)$$it.name.literal$$sep$, $endfor$",
$endif$
$if(date)$
  date: "$date$",
$endif$
$if(lang)$
  lang: "$lang$",
$endif$
  main-color: brand-color.at("primary", default: blue),
$if(cover.background)$
  cover-background: {
    let name = "$cover.background$"
    if name == "none" { none } else { brand-color.at(name) }
  },
$endif$
$if(cover.image)$
  cover: image("$cover.image$"$if(cover.alt)$, alt: "$cover.alt$"$endif$),
$endif$
$if(cover.copyright)$
  copyright: [$cover.copyright$],
$endif$
  logo: {
    let logo-info = brand-logo.at("medium", default: none)
    if logo-info != none { image(logo-info.path, alt: logo-info.at("alt", default: none)) }
  },
$if(toc-depth)$
  outline-depth: $toc-depth$,
$endif$
$if(lof)$
$if(crossref.lof-title)$
  list-of-figure-title: "$crossref.lof-title$",
$else$
$if(quarto.language.crossref-lof-title)$
  list-of-figure-title: "$quarto.language.crossref-lof-title$",
$endif$
$endif$
$endif$
$if(lot)$
$if(crossref.lot-title)$
  list-of-table-title: "$crossref.lot-title$",
$else$
$if(quarto.language.crossref-lot-title)$
  list-of-table-title: "$quarto.language.crossref-lot-title$",
$endif$
$endif$
$endif$
$if(quarto.language.crossref-ch-prefix)$
  supplement-chapter: "$quarto.language.crossref-ch-prefix$",
$endif$
$if(margin-geometry)$
  padded-heading-number: false,
$endif$
)

$if(margin-geometry)$
// Configure marginalia page geometry for book context
// Geometry computed by Quarto's meta.lua filter (typstGeometryFromPaperWidth)
// IMPORTANT: This must come AFTER book.with() to override the book format's margin settings
#import "@preview/marginalia:0.3.1" as marginalia

#show: marginalia.setup.with(
  inner: (
    far: $margin-geometry.inner.far$,
    width: $margin-geometry.inner.width$,
    sep: $margin-geometry.inner.separation$,
  ),
  outer: (
    far: $margin-geometry.outer.far$,
    width: $margin-geometry.outer.width$,
    sep: $margin-geometry.outer.separation$,
  ),
  top: $if(margin.top)$$margin.top$$else$1.25in$endif$,
  bottom: $if(margin.bottom)$$margin.bottom$$else$1.25in$endif$,
  // CRITICAL: Enable book mode for recto/verso awareness
  book: true,
  clearance: $margin-geometry.clearance$,
)
$endif$

14.4 Write Your Own Format

When the book needs more, write your own Typst format and use it for books. My clinical study report does this: one format extension renders both a Quarto book and a single document, and a profile picks between them. It is described in A Clinical Study Report in Quarto, End to End.

15 The Final PDFs

Here are the two PDFs that I build from the demo, both tagged PDF/UA-1 files. The first is the report with all ten partials.

The second is the same report as a book, and it does not carry all ten tricks. It loads Tokens, Header and Footer, Headings, Code, Tables and Captions, as the table in the book section says. It leaves out Title Block, Cover Page and Cover Decoration, which do not work in a book. The cover comes from book-cover.typ in place of Page Stripes, and from the typst-show.typ override of Add Cover Options. Its source is in the _book folder next to the report.

Open them full size: report, book.

16 Where to Go Next

If you try these partials, I would like to hear how it goes. Drop a comment in the form below.

Back to top

Reuse

Citation

BibTeX citation:
@misc{canouil2026,
  author = {CANOUIL, Mickaël},
  title = {Professional and {Accessible:} {Ten} {Small} {Typst}
    {Partials} for {Quarto} {PDFs}},
  date = {2026-11-30},
  url = {https://mickael.canouil.fr/posts/2026-11-30-typst-partials-tricks/},
  langid = {en-GB}
}
For attribution, please cite this work as:
CANOUIL, M. (2026-11-30). Professional and Accessible: Ten Small Typst Partials for Quarto PDFs. Mickael.canouil.fr. https://mickael.canouil.fr/posts/2026-11-30-typst-partials-tricks/