How to disable or modify indent in outline while using custom numbering?

I have some custom numbering to have appendices numbered as Appendix A, Appendix B, etc.

This is working great, except that the outline is really indented for the other normal headings because it tries to put every title on the same indent. This is a minimal working example of my template where you can see that the chapters Introduction and Continuation are indented to the same level as the Appendix Data, which looks really weird:

#outline()

= List of Figures

= List of Abbreviations

#set heading(numbering: "1.1")

= Introduction

== Motivation

== Objective

= Continuation

#set heading(numbering: none)

= Bibliography

#counter(heading).update(0)
#set heading(supplement: [appendix],
    numbering: (..nums) => {
      let numbers = nums.pos()
      // level 1 heading is Appendix A:, Appendix B:, ... 
      if numbers.len() == 1 {
        "Appendix " + numbering("A", ..numbers) + ": "
      } else {
        // other headings A.1, A.2, B.1, B.2, ...
        numbering("A.1", ..numbers) 
      }
    }
  )

= Data

= Code

Hello @Heyooooooo ,

This seems to be a duplicate of:
Relevant posts:

I don’t think so, my issue is specifically with the indents in the outline. I already have it working to have the headings numbered with Appendix A, etc. which is what that post is explaining. I’ve attached a screenshot that shows the indentation of the two normal headers “Introduction” and “Continuation”

Cant you just disable the indent?
Outline Function – Typst Documentation

#outline(indent: 0pt)

Oops, sorry yeah that worked, don’t know how I hadn’t tried that. Thank you!

This gets rid of the auto indent for the whole outline. You could still set it manually, but what is the point?

  1. Perhaps this will ensure what you really want, as it will keep a consistent indent throughout the outline levels:
#outline(indent: 2em)

  1. Another way is to display both parts of the outline separately.
#outline(target: heading.where(supplement: [Section]))
#outline(target: heading.where(supplement: [Appendix]), title: none)

This prevents the longer indent for the beginning of the outline and keeps it for the second part (mainly if you have level 2, which you have numbering set for.

Full code
#let appendix(body) = {
  set heading(supplement: [Appendix], numbering: (..nums) => {
    let numbers = nums.pos()
    // level 1 heading is Appendix A:, Appendix B:, ...
    if numbers.len() == 1 {
      "Appendix " + numbering("A", ..numbers) + ": "
    } else {
      // other headings A.1, A.2, B.1, B.2, ...
      numbering("A.1", ..numbers)
    }
  })
  counter(heading).update(0)
  body
}

#outline(target: heading.where(supplement: [Section]))
#outline(target: heading.where(supplement: [Appendix]), title: none)

= List of Figures

= List of Abbreviations

#set heading(numbering: "1.1")

= Introduction

== Motivation

== Objective

= Continuation

#set heading(numbering: none)

= Bibliography

#show: appendix

= Data

== Sub Data

== Sub Data

= Code

== Sub Code

== Sub Code