1= Styling2
3Typst uses set rules and show rules to customize appearance.4
5== Set rules6
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 styling16
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 rules26
27Show rules transform how elements are displayed:28
29// Custom heading style30#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.body37 #v(-0.4em)38 #line(length: 100%, stroke: 0.5pt + eastern)39]40
41== Styled heading42
43This heading has a colored underline thanks to the show rule above.44
45== Another styled heading46
47The show rule applies to all level-2 headings automatically.48
49== Colors50
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 decorations62
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 rules70
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 #body80]81
82#note[This is a custom note block created with a function. Reuse it throughout your document.] v1
commit f02dfc6
message create styling.typ via macOS
author anton
date Apr 18, 2026
size 1.9 KB