How can I hide heading numbers but retain their numbering, while not shifting layout?

Hi,

I’m trying to remove the 1 from this:

image

Right now it’s structured as:

#show heading: it => {
  if it.level == 1 {
    pagebreak(weak: true)
    v(32pt)

    if counter(heading).get().first() > 0 {
      [
        Chapter #counter(heading).display()
      ]
    }
    
    text(size: 20pt)[#it]
    v(16pt)
  } else if it.level >= 2 {
    v(8pt)
    it
    v(8pt)
  } else {
    it
  }
}

= Introduction

Crucially, I have a paragraph indent:

#set par(first-line-indent: 1.5em, leading: 1.3em)

Which leads me to be unable to use #it.body, since it then turns relevant text into paragraphs and causes unnecessary indenting.

I still would like to retain that numbering for things like #outline() and in-text references.

Would appreciate any help!

Hi, welcome to the Typst forum! I think you can use #it.body inside a block, e.g. block(text(size: 20pt)[#it.body]) or more idiomatic:

block({
  set text(20pt)
  it.body
})

This way the heading body will not make a paragraph.

1 Like