Skip to main content

Touying 0.8.0

· 4 min read
OrangeX4
Zralokh

Touying 0.8.0 is a big release, and the first that requires Typst 0.15. The headline feature is article mode: one source file compiles either to slides or to a flowing prose document. And we have two new animation functions.

Article mode​

A handout deck written for projection rarely reads well as a prose document, and a document written for reading rarely projects well. Article mode lets one file be both. Compile with --input export-mode=article and the deck becomes a continuous document: no slide breaks, animations collapsed to their final state, images optionally floated to the side.

The interesting part is what happens where the two outputs should differ. #article-text[..] replaces the body of the slide it is written in, so a slide of bullet points can become a paragraph of prose:

== Results
- First point
- Second point

#article-text[
In the article this slide becomes a prose paragraph instead of bullets.
]

#article-only[..] and #slides-only[..] restrict content to one output, and config-article(..) covers the article side of the layout: wrap floats elements beside the text, linearize decides how much of the deck's structure comes apart — a composer's columns become flowing text, while a table with a header keeps its shape — and #article-linearize[..] / #article-keep-layout[..] override that per element. See Article Mode.

Two new animation functions​

#animate layers several effects on one piece of content, each over its own subslide range. A placement ("show", "cover", "remove" or swap(..)) decides whether the body appears; a styling function wraps whatever the placement left:

#animate(
[Photosynthesis],
effects: (
(effect: swap([Respiration], stretch: true), subslides: "2-"),
(effect: (body, self: none) => text(fill: red, body), subslides: "3-"),
),
)

#touying-render takes content held in a variable and renders it at a chosen stage, so an animated element can be shown mid-animation without writing it out again:

#let steps = [A #pause B #pause C]
#touying-render(steps, subslides: 2)

#touying-recall was extended from whole slides to any labelled element, and a #slide[..] can carry a label of its own, so several slides under one heading stay individually addressable.

Animations inside math​

#pause, #uncover, #only and #alternatives now work inside the math elements that keep their content in named fields — frac, mat, vec, cases, binom, root, attach, accent and the brace family. These used to abort the compile with Unsupported mark:

$ frac(a #pause + b, c) $

touying-equation is deprecated as a result; plain math is more capable than it ever was.

Things to watch when upgrading​

  • Typst 0.15 is required.
  • A #pause after uncover/only/alternatives no longer skips the subslides they reserve. v0.7.0 made a relative jump snap past any preceding wrapper, which was meant for item-by-item but caught the others too. If you relied on it, add the #pause yourself.
  • show-bibliography-as-footnote is a boolean now, and magic.bibliography() is gone — set the flag and put a real #bibliography(..) in the presentation.
  • semi-transparent-cover is deprecated in favour of alpha-changing-cover and color-changing-cover.
  • The speaker-note panel is a theme-supplied function via config-common(notes-fn: ..); the config-methods(show-only-notes: ..) renderer is gone.

The changelog has a full migration guide, and a separate one for theme authors at the end.

Also new​

  • .pdfpc files as bundle assets, written directly instead of through a separate typst query step.
  • touying-fn-wrapper-raw parses and nests its body, so #alert[.. #pause ..] works.
  • Overflow detection checks width as well as height, and detect-overflow defaults to auto, following breakable.
  • Internally, src/core.typ (6288 lines) was split into modules and the content handling was unified — most documentation pages were rewritten or corrected alongside it.