I’ve been working with Typst a little bit recently and one of the problems I’ve had is when to use what construct for modifying things, and how to combine them however I want.

Here’s how I built up the knowledge to understand what was going on. This page is mostly a restatement of the Typst docs, but the order and emphasis is a little different.


Typst has functions.

Interestingly enough, page, text, heading, par, raw, and other identifiers that you use to mark different types of text are functions. These are known as element functions.

set rules

set rules…


#set text(
  font: "Concourse"

Only this list is affected: #[
  #set list(marker: [--])
  - Dash

show rules

The most basic of these is a show-set rule:

#show «selector»: set «element function»(·)

More concretely:

#let usualLeading = 0.65em
#show par: set block(spacing: 1.0em - (1.0em - usualLeading));

For full power, write a show rule:

#set heading(numbering: "(I)")
#show heading: it => [
  #set align(center)
  #set text(font: "Inria Serif")
  \~ #emph(it.body)
     #counter(heading).display() \~

In the above anonymous function, it is a variable containing the contents of whatever was passed into that function. For example, if you didn’t want to italicize anything in your heading, you would write:

#show heading: it => [
  #set align(center)
  #set text(font: "Inria Serif")

Defining your own functions

This is a thing you can do.

#let task(body, critical: false) = {
  set text(red) if critical
  [- #body]

#task(critical: true)[Food today?]
#task(critical: false)[Work deadline]

I’m not sure why this uses braces when normally I would expect brackets (for a block).