If you start your code block with ```typst then it will have proper syntax highlighting. So the following block
```typst
#set text(weight: "bold")
This text is bold
```
will be rendered as
#set text(weight: "bold")
This text is bold
EDIT
At a second glance I figure you used a quote instead of a codeblock. Please prefer code blocks for actual code as it makes it easier for people to read. Especially if you use some indents for blocks of code.
Hi Yoonghm, thanks for sharing your code. I’m targeting Heading Level 2, so changed it for that (shown below). I’m going to try to reset the counters for figures after each new Heading 2, but realised the Outline isn’t honouring the new numbering (e.g. 1.1, 1.2, 3.3) but instead showing 0.1, 0.2, 0.3 - obvs incrementing the Figure number, and ignoring the Heading prefix. Have you needed to overcome this yourself?
Hi @Hi.as.MyKite, could I ask you to post this as a new question? I think there have been some relevant changes in Typst since this showcase, and a new post will give your issue more visibility.
One thing I can tell you though:
counter(heading.where(level: 2))
There is only the counter(heading), and that counter counts all levels of heading. This is probably the immediate reason why you always get zeros instead of the number you want: the counter you use is not used anywhere else.
Yes, I will - hadn’t realised the orig post was under showcase. I found an updated method on the forum, which was very simple to implement and control - I’ll update the posts once back at my laptop.
Just chiming in to mention that this topic was discussed in the (currently open) GitHub issue #1896.
There, a comment posted what is, in my opinion, the best solution:
// show chapter on figure numbering
#set figure(numbering: (..num) =>
numbering("1.1", counter(heading).get().first(), num.pos().first())
)
// show chapter on equation numbering
#set math.equation(numbering: (..num) =>
numbering("(1.1)", counter(heading).get().first(), num.pos().first())
)
#show heading.where(level: 1): it => {
// reset figure counters so they are counted per chapter
counter(math.equation).update(0)
counter(figure.where(kind: image)).update(0)
counter(figure.where(kind: table)).update(0)
counter(figure.where(kind: raw)).update(0)
// ...
}
Also mention that there is the i-figured package does the same thing, and gives you more options and a cleaner configuration syntax, but uses custom i-figured figures, which may clash with the rest of the config you have for figures.