When I started using the show method in Typst, I lost the heading numbering. How can i get it back?
#show heading: it => [
#block(fill:white, outset: 5pt, radius: 20%,
underline(stroke: rgb(39, 174, 96) + 1.5pt, offset: 1.75pt)[#it.body])
]
Your show
function uses it.body
, so only the heading text (body) is showing. You can fix this by displaying it
instead of it.body
, which contains information about the numbering:
#set heading(numbering: "1.")
#show heading: it => [
#block(fill:white, outset: 5pt, radius: 20%,
underline(stroke: rgb(39, 174, 96) + 1.5pt, offset: 1.75pt)[#it])
]
= Heading
If you want to also underline the whitespace between the number and heading, you can explicitly display the heading number and body separately:
#set heading(numbering: "1.")
#show heading: it => [
#block(
fill: white,
outset: 5pt,
radius: 20%,
underline(stroke: rgb(39, 174, 96) + 1.5pt, offset: 1.75pt)[
#counter(heading).display() #it.body
],
)
]
= Heading