Repository navigation
Description
Description
In a Typst book project with a _brand.yml that sets a bright primary color (and a separate foreground for body text), the bundled orange-book extension applies brand.primary as the text fill for:
- TOC entries (chapter and section names, plus chapter/section numbers)
- All links
- Heading numbers for level 2+ headings (e.g.
1.1) - Citations
These elements become unreadable when primary is a bright color, even though foreground is set to a readable text color and is correctly applied to body text and chapter heading titles.
Body text and chapter heading titles (level 1) are correct — they pick up brand.foreground via the #set text(fill: brand-color.foreground) rule and the #show heading: set text(fill: foreground) rule emitted by typst-brand-yaml.lua. The unreadable elements bypass that wiring and read main-color directly.
Reproduction
_quarto.yml:
project:
type: book
brand: _brand.yml
book:
title: "Reproduction"
chapters:
- index.qmd
- chapter1.qmd
format:
typst: default_brand.yml — bright yellow primary, dark foreground on cream background:
color:
palette:
sw-yellow: "#FFE81F"
sw-black: "#0B0B0F"
sw-cream: "#F5F0E1"
primary: sw-yellow
foreground: sw-black
background: sw-creamindex.qmd:
# Preface {.unnumbered}
This contains a [link to Quarto](https://quarto.org).chapter1.qmd:
# First chapter
A paragraph with a [link](https://quarto.org).
## A sub-section
Body text.Render with quarto render. The cover renders correctly (pale yellow band with dark title), but on subsequent pages every TOC entry and every link renders in yellow on the cream page background, and the 1.1 heading number renders in yellow.
Three layers involved
To make the discussion concrete, three layers of code participate:
-
The Lua filter
typst-brand-yaml.luareads_brand.ymland emits the Typst header that declares#let brand-color = (...),#set text(fill: brand-color.foreground), and the#show linkrule. -
Quarto's orange-book wrapper (
typst-show.typundersrc/resources/extension-subtrees/orange-book/_extensions/orange-book/) is Quarto-controlled Typst code that consumesbrand-colorand calls into the upstream package. This is the natural place for any Quarto-specific brand wiring. -
The upstream Typst package
@preview/orange-book:0.7.1is vendored atsrc/resources/extension-subtrees/orange-book/_extensions/orange-book/typst/packages/preview/orange-book/0.7.1/. The bundled copy can be modified, but doing so diverges from the published package ontypst.app/universe; any later update of the vendored copy would have to re-apply local patches (or have them upstreamed).
Where main-color is read in the upstream package
Layer 2 — Quarto's wrapper — wires a single main-color parameter from brand.primary:
quarto-cli/src/resources/extension-subtrees/orange-book/_extensions/orange-book/typst-show.typ
Line 19 in 4ed3ffb
| main-color: brand-color.at("primary", default: blue), |
Inside layer 3 — the bundled book() function — main-color is used for both decorative roles (cover tint, heading box strokes, theorem strokes, exercise box borders, lighten() backgrounds) and text-fill roles. There is no separate parameter for text fill:
Line 311 in 4ed3ffb
| #let book(title: "", subtitle: "", date: "", author: (), paper-size: "a4", width: none, height: none, margin: (x: 3cm, bottom: 2.5cm, top: 3cm), logo: none, cover: none, cover-background: auto, image-index:none, body, main-color: blue, copyright: [], lang: "en", list-of-figure-title: none, list-of-table-title: none, supplement-chapter: "Chapter", supplement-part: "Part", font-size: 10pt, part-style: 0, part-font-size: auto, lowercase-references: false, padded-heading-number: true, outline-font-size: auto, outline-small-depth: 2, outline-small-width: 9.5cm, heading-style: 0, first-line-indent: true, outline-depth: 3) = { |
Text-fill uses of main-color in the upstream package:
-
TOC entries:
textColor: main-color
Line 49 in 4ed3ffb
box(width: 1.1cm, fill: main-color.lighten(80%), inset: 5pt, align(center, text(size: textSize1, weight: "bold", fill: main-color.lighten(30%), numbering("I",part-counter.first())))) -
Heading number text for level 2–3:
set text(fill: main-color) if it.level < 4
Line 537 in 4ed3ffb
set text(fill: main-color) if it.level < 4 -
Link text:
show link: set text(fill: main-color)
Line 638 in 4ed3ffb
show link: set text(fill: main-color) -
Citation text:
show cite: it => { show regex("[\w\W]"): set text(main-color); it }
Line 405 in 4ed3ffb
show regex("[\w\W]"): set text(main-color)
The upstream book() already has a cover-background: auto parameter that decouples the cover tint from main-color, but typst-show.typ does not set it and no equivalent parameter exists for text fills.
Why this is hard to work around
Users cannot redefine brand-color before the orange-book template reads it. The Quarto-generated header places user include-in-header content before the brand-color let declaration emitted by typst-brand-yaml.lua, so a user document has no entry point to override main-color.
The only known workaround is to ship a local override extension that replaces the bundled typst-show.typ (using the local extension override added in #14332) and passes a different main-color. That requires the user to know about the bundled extension's existence.
Where the fix can live
Two options, in order of how much they touch layer 3 (the vendored upstream package):
Option 1 — Layer 2 only (Quarto wrapper). Change typst-show.typ to pass main-color: brand-color.at("foreground", default: black) and explicitly pass cover-background: brand-color.at("primary", default: blue).lighten(70%) to preserve the cover tint. Pure layer-2 change, no divergence from upstream. Trade-off: every other use of main-color (heading box strokes, theorem strokes, exercise borders, line() stroke under heading-style 2) becomes the foreground color — the brand accent is lost for those decorative elements.
Option 2 — Layer 2 plus layer 3. Add a text-color parameter to book() (defaulting to main-color for backward compatibility) and route the text-fill uses (TOC entries, heading numbers, link text, citation text) through it. Pass text-color: brand-color.at("foreground", default: black) from typst-show.typ. Result: text becomes readable, decorative uses keep the brand accent.
Option 2 means modifying book() in lib.typ (and the corresponding signatures in my-outline.typ). That change has to land somewhere — and there are two non-exclusive ways to ship it:
- Patch the vendored copy of the package at
src/resources/extension-subtrees/orange-book/_extensions/orange-book/typst/packages/preview/orange-book/0.7.1/. Fix ships in the next Quarto release; the local copy diverges from upstream until the vendored version is bumped to one that incorporates the change. - Contribute the parameter upstream at https://github.com/flavio20002/typst-orange-template and wait for a published version that includes it. No local divergence, but the fix waits on upstream's release cadence (last push 2026-01-30, so the repo is active but not on a fast cadence).
The two are compatible: patch the vendored copy now to unblock users, contribute upstream in parallel, drop the local patch when the vendored version is bumped.
Option 1 is purely a Quarto-side change and may be acceptable as an interim mitigation, but Option 2 produces the cleanest visual outcome.
Related
- Callout colours inconsistent between HTML and Typst when using brand.yml #14092 — callout colors with brand.yml, same family of issue (decorative vs readable text use of brand colors).
- Expose more Typst orange book variables to YAML (Pandoc template) #14270 — exposing more orange-book variables to YAML (separate concern, but same surface area).
- Typst Books #13950 — original orange-book bundling PR.
Activity
gordonwoodhull commentedon May 13, 2026
I think we should contribute a fix upstream (option 3). If the maintainer doesn't want it, we can also fork the Typst package and import it
@local.There are a few other changes in this category, like a11y and integration with Marginalia. Let's plan on making changes to the template in the Quarto 1.10 timeframe, one way or the other.
As discussed, although this would technically work, it is not the proper way to use typst-gather:
Instead, fork the typst template and import it as
@localinstead of@preview(using a distinct version number for good measure). Declare it intypst-gather.ymlso that it's picked up from your local copy.Otherwise you are implying that orange-book@0.7.1 on Typst Preview has content which is different from what is published.
cderv commentedon May 13, 2026
Ok I understand what you mean. I need to experiment it to really get to the bottom of it. But this is clearer. Thank you !