How to define a new highest header while keeping the others the same?

I asked the same question 17 days ago, unfortunately I got sick and totally forgot about it by the time a user noticed me that my explanation wasn’t that clear. I decided to open a new post before rewriting entirely the question.

So, what I’m trying to do is to create a new header for chapters, which I want to place the highest on the header’s hierarchy but without getting rid of any of the default ones.

Right now my workaround is a function that draws the title of the chapter and somehow manages to place it on the index.

let chapter(title: "No title", body) = {
  counter(heading).update(0)
  show figure: set place(center+horizon)
  show figure.caption: strong
  show figure.caption: set text(40pt)
  set figure.caption(position: top)
  pagebreak(weak: true)
  place(center+horizon)[#figure(
    kind: "chapter",
    numbering: "I",
    supplement: "Chapter",
    outlined: true,
    placement: bottom,
    gap: 150pt,
    caption: [\ #title],
    [#body]
  )]
  pagebreak(weak: true)
}

My problem with it is that the webapp UI doesn’t detect it as a proper header, hence it doesn’t show it on the outline (left panel).

I had the idea that if I could somehow move every header one spot down in the hierarchy, I could redefine the first one (=) as my personalized chapter header.

Does anyone know a better way to do it than manually reformatting every header?

// What I've got
= Header 1
== Header 2
=== Header 3
==== Header 4
...

// What I'd like
= Chapter Header
== Header 1
=== Header 2
==== Header 3
===== Header 4
...

PS: Is it me or preformatted text isn’t Typst?

Hey @Alberto , as in the previous post, I’ll ask you to ensure your title complies with our question post guidelines: How to post in the Questions category

I’ve updated your post title for you; next time, please make sure your title is a question you’d ask to a friend about Typst. :wink:

You can use ```typ instead of ``` for code blocks to ensure proper syntax highlighting in the forum.

1 Like

You can use #set heading(offset: 1) to “bump” all headings by one level, as follows:

#let chapter = heading.with(level: 1, numbering: n => [Chapter #n.])  // <--- override level calculation
#set heading(offset: 1)  // <--- heading level by default is depth (amount of '=') + offset (default zero)
#set heading(numbering: (chapter, ..n) => numbering("1.", ..n))  // <--- omit chapter number from heading number

#outline()

#chapter[Origins]

= Title

== Subtitle

=== Subsubtitle

#chapter[Epilogue]

= Title

1 Like

Thank you for the information. Next time I’ll write a proper title.

Your answer works, it shows in the outline

1 Like