To get the expected result, you need to create a show rule for the headings and for the outline.
#show heading.where(level: 1): set heading(outlined: false, numbering: none)
#show outline.entry: it => context {
let el = it.element
if el.func() == heading [
#let c = counter(heading).at(el.location()).slice(1)
#numbering(el.numbering, ..c) #el.body #box(width: 1fr, it.fill) #it.page
] else{
it
}
}
#show heading: it => context {
if it.level != 1 and it.numbering != none [
#let c = counter(heading).at(here()).slice(1)
#numbering(heading.numbering, ..c) #it.body
] else {
it
}
}
#outline(indent: auto)
#set heading(numbering: "1.")
= Title
== Section 1
=== Subsection 1.1
=== Subsection 1.2
== Section 2
=== Subsection 2.1
Result
Notice how the auto indent is a little off, as a result maybe you could prefer another indentation.
Even though it is possible, I highly suggest to avoid this route. Everything would be so much easier if you just write Title with a bigger text size, and make every subheading 1 level higher. For a fully functional show rule you would need to handle the links in the outline, and maybe some other details that I’m not aware at this moment.
@Olaf glad you got an answer that worked for you! Could you maybe try to revise your post’s title so others can find it easier in the future? The question guidelines recommend a complete question:
Good titles are questions you would ask your friend about Typst.
While I’m here, I’d like to second that. The title is not really meant to be a heading, and making it one requires you to recreate some built-in stuff (more than the answer showed). So if it’s an option, just style the title. You can use set document(title: ...) if you want the title to be part of the PDF in a “structured” way:
FYI, you can get everything done without context and inside the heading numbering function, resulting in a more minimal solution.
Outline indentation is an implemented feature of outline.
It is as Anemona-Anonima said at the beginning. It is wrong to treat the title of the document as a heading. I did it this way because I know it from Markdown and AsciiDoc. If you don’t do that, all the problems disappear by themselves.