b059f10 ←dfd90b7antonApr 18, 2026 api

create styling.typ via macOS

A /docs/undefined +82 -0
A /docs/undefined +82 -0
1= Styling
2
3Typst uses set rules and show rules to customize appearance.
4
5== Set rules
6
7Set rules change default properties for elements:
8
9#set text(size: 11pt)
10#set par(justify: true, leading: 0.8em)
11#set heading(numbering: "1.1")
12
13These set rules apply to all content below: 11pt justified text with numbered headings.
14
15== Text styling
16
17#text(fill: blue)[Blue text] and #text(fill: red, weight: "bold")[bold red text].
18
19#text(size: 14pt)[Larger text] and #text(size: 8pt)[smaller text].
20
21#text(font: "Courier New")[Monospace font] for a different look.
22
23Subscript: H#sub[2]O. Superscript: E = mc#super[2].
24
25== Show rules
26
27Show rules transform how elements are displayed:
28
29// Custom heading style
30#show heading.where(level: 2): it => block(
31 width: 100%,
32 below: 0.8em,
33 above: 1.2em,
34)[
35 #set text(weight: "bold", fill: eastern)
36 #it.body
37 #v(-0.4em)
38 #line(length: 100%, stroke: 0.5pt + eastern)
39]
40
41== Styled heading
42
43This heading has a colored underline thanks to the show rule above.
44
45== Another styled heading
46
47The show rule applies to all level-2 headings automatically.
48
49== Colors
50
51Typst has named colors and custom color support:
52
53#let colors = (red, blue, green, orange, purple, eastern, maroon, olive, navy, teal)
54#for c in colors {
55 box(width: 20pt, height: 20pt, fill: c)
56 h(4pt)
57}
58
59Custom colors: #text(fill: rgb("#e74c3c"))[hex red], #text(fill: rgb(46, 204, 113))[rgb green], #text(fill: luma(128))[50% gray].
60
61== Highlights and decorations
62
63#highlight[Highlighted text] for emphasis.
64
65#underline[Underlined text] and #strike[strikethrough text].
66
67#overline[Overlined text] works too.
68
69== Custom blocks with show rules
70
71#let note(body) = block(
72 width: 100%,
73 fill: rgb("#e8f4f8"),
74 stroke: rgb("#2196f3") + 1pt,
75 inset: 12pt,
76 radius: 4pt,
77)[
78 #text(weight: "bold", fill: rgb("#2196f3"))[Note: ]
79 #body
80]
81
82#note[This is a custom note block created with a function. Reuse it throughout your document.]