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
