variables
// Content with markup inside
#let blind-text = [_Lorem ipsum_ dolor sit amet]
// Unformatted strings
#let funny-font = "MS Comic Sans"
// Absolute lengths (see also pt, in, ...)
#let mile = 160934cm
// Lengths relative to the font size
#let double-space = 2em
// Ratios
#let progress = 80%
// Integer numbers
#let answer = 42
// Booleans
#let truth = false
// Horizontal and vertical alignment
#let focus = center
// Functions
#let amazed(term, color: blue) = {
text(color, box[✨ #term ✨])
}
You are #amazed[beautiful]!
I am #amazed(color: purple)[amazed]!
templates
Templates work by wrapping our whole document in a custom function like amazed. But wrapping a whole document in a giant function call would be cumbersome! Instead, we can use an "everything" show rule to achieve the same with cleaner code. To write such a show rule, put a colon directly after the show keyword and then provide a function.
#show: amazed
I choose to focus on the good
in my life and let go of any
negative thoughts or beliefs.
In fact, I am amazing!
You can of course nest other set and show rules within your function:
#let template(doc) = [
#set text(font: "Inria Serif")
#show "something cool": [Typst]
#doc
]
#show: template
I am learning something cool today.
It's going great so far!
with named arguments
#show: doc => conf(
title: [
A Fluid Dynamic Model for
Glacier Flow
],
authors: (
(
name: "Theresa Tungsten",
affiliation: "Artos Institute",
email: "tung@artos.edu",
),
(
name: "Eugene Deklan",
affiliation: "Honduras State",
email: "e.deklan@hstate.hn",
),
),
abstract: lorem(80),
doc,
)