How do let all headings what level >2 don't be outlined

#let annex_template(doc) = {
  show heading: it => {
    if it.level >= 2 and it.outlined {
      let fields = it.fields()
      fields.remove("body")
      it = heading(it.body, ..fields, outlined: false)
    }
    it
  }
  doc
}
#show: annex_template
#set heading(numbering: "1")
#outline()

= A

#heading([B], outlined: false, level: 2)

== C

I want heading A be outlined, B and C not.

Same concept as in How to create a show rule for table cells other than the first row? - #2 by Andrew and How to avoid ghost numbering in headers? - #5 by Andrew :

#let annex-template(doc) = {
  set heading(numbering: "1.")
  show heading: set heading(outlined: false)
  show heading.where(level: 1, outlined: true): set heading(outlined: true)
  doc
}

#show: annex-template

#outline()

= A

#heading(outlined: false, level: 2)[B]

== C

=== 3rd level

maybe I’m missing something going on here, but couldn’t

show heading: set heading(outlined: false)
show heading.where(level: 1, outlined: true): set heading(outlined: true)

be simplified to

set heading(outlined: false)
show heading.where(level: 1): set heading(outlined: true)

?

1 Like

You are missing something. The reason is in the linked How to avoid ghost numbering in headers? - #5 by Andrew.