How can I prevent level 1 headings from being numbered?

Hi there @ozzyc,

Two suggestions:

  1. You could use a numbering function:
#show heading.where(level: 1): set heading(numbering: none)
#set heading(numbering: (first, ..nums) => numbering("1.", ..nums))

  1. Or use the package numbly – Typst Universe with:
#import "@preview/numbly:0.1.0": numbly
#set heading(numbering: numbly(
  "",
  "{1}",
  "{1}.{2}",
  "{1}.{2}.{3}", // as needed
))

EDIT:

If we apply to your code (I have commented the font lines to be able to compile),

Your code
#show heading.where(level: 1): set heading(numbering: none)
#set heading(numbering: (chapter, ..n) => numbering("1.", ..n))

#show heading.where(
  level: 1
): it => block(width: 100%)[
  #set align(center)
  #set text(
    size: 20pt,
    weight: "bold",
  //  font: ("Poppins","Noto Serif CJK SC"),
  )
  //#counter(heading).display(it.numbering)
  #smallcaps(it.body)
]

#show heading.where(
  level: 2
): it => block(width: 100%, below: 1.0em)[
  #set align(left)
  #set text(
    size: 18pt,
    weight: "bold",
  //  font: ("Poppins","Noto Serif CJK SC"),
    fill: rgb("#045bac")
  )
  #counter(heading).display(it.numbering)
  #smallcaps(it.body)
]

#show heading.where(
  level: 3
): it => block(width: 100%, below: 1.2em)[
  #set align(left)
  #set text(
    size: 14pt,
    weight: "regular",
//    font: ("Poppins","Noto Serif CJK SC"),
    fill: rgb("#062f56")
  )
  #counter(heading).display(it.numbering)
  #smallcaps(it.body)
]
 
= Test
== Test
=== Test
==== Test
= Test
== Test
=== Test
==== Test

Edit2:
Following:

and with a bit of cleanup to reduce the usage of show rules (your should prioritize show-set rules):

#set heading(numbering: (first, ..nums) => numbering("1.", ..nums))
#show heading: smallcaps
#show heading: set align(left)
#show heading: set block(width: 100%)

#show heading.where(level: 1): set heading(numbering: none)
#show heading.where(level: 1): set align(center)
#show heading.where(level: 1): set text(
  size: 20pt,
  weight: "bold",
  //  font: ("Poppins","Noto Serif CJK SC"),
)

#show heading.where(level: 2): set block(below: 1.0em)
#show heading.where(level: 2): set text(
  size: 18pt,
  weight: "bold",
  //  font: ("Poppins","Noto Serif CJK SC"),
  fill: rgb("#045bac"),
)

#show heading.where(level: 3): set block(below: 1.2em)
#show heading.where(level: 3): set text(
  size: 14pt,
  weight: "regular",
  //  font: ("Poppins", "Noto Serif CJK SC"),
  fill: rgb("#062f56"),
)
3 Likes