How to remove numbering from outline?

I am trying to remove the Appendix numbering at the starting in the outline, and here is what I have

#show outline.entry.where(level: 1): it => {
  v(12pt, weak: true)
  strong(it)
}

#outline(title: [Table of Contents #v(1.5em)], depth: 4, indent: auto)

#show heading.where(level: 1): it => {

  if it.at("label", default: none) != <bibliography> {
    counter(heading).display(it => text(1em, weight: 700, block([Chapter #it])))
  }

  text(1em, weight: 700, block([#it.body]))
}

#set heading(numbering: "1.1")

= Introduction

== Introduction

This is the introduction.

= Background

== Background

This is the background.

#show heading.where(level: 1): it => {
    // Create the heading numbering.
    let number = if it.numbering != none {
      counter(heading).display(it.numbering)
      h(7pt, weak: true)
    }
    text(block([Appendix #number]))
  }

#set heading(numbering: "A.1")

= Apendix A: Code Snippets

== Code Snippet 1: some Code

/```py
print("Hello World")
/```

= Appendix B: Additional Information

== Additional Information 1: some Information

This is some additional information.

Which renders as

How should I change the C Appendix A: Code Snippets to Appendix A: Code Snippets? I want to remove the appendix numbering in the outline.

Problems

There are several problems in the code you provided:

  1. The numbering function is ambigous: The level: 1 numbering is set to "A.1." but it seems that "Chapter 1." or "Appendix" is expected here.
  2. The numbering part Appendix A should not appear in the title content

Solutions

Step 1. Setup heading numbering properly

First of all, I recommend using the numbly package to construct numbering functions in a convenient way. Here we can still construct it manually:

#set heading(numbering: (..ns) => {
  let ns = ns.pos()
  if ns.len() == 1 {
    return "Chapter " + numbering("1.", ..ns)
  }
  return numbering("1.", ..ns)
})

Put this code at the begining, and replace "Chapter " + numbering("1.", ..ns) with "Appendix " + numbering("A.", ..ns) and return numbering("1.", ..ns) with return numbering("A.1.", ..ns) and place it before the appendix. Then remove all the former #set heading(numbering: "x.x"). Now you can remove the Appendix A from your appendix heading.

Step 2. Fix the counter

You will notice that the Appendix now starts from C in the example document. You can reset the heading counter by adding the following row before the appendix:

#counter(heading).update(0)

Step 3. Misc.

The custom heading counter(heading).display(it => text(1em, weight: 700, block([Chapter #it]))) can be replaved with a simple counter(heading).display(). If the font weight or size setting is not working properly, I recommend using set text instead of text(...)

Setting outline.indent to auto would make the next level heading align to the end of the numbering, which might be a bit annoying, so you may set it to 1em or some other value you like.

Modified Example

In case that you wish to use it just by doing copy-paste :slight_smile:

#show outline.entry.where(level: 1): it => {
  v(12pt, weak: true)
  strong(it)
}

#outline(title: [Table of Contents #v(1.5em)], depth: 4, indent: 1em)


#show heading.where(level: 1): it => {

  if it.at("label", default: none) != <bibliography> {
    context counter(heading).display()
    h(7pt, weak: true)
  }

  text(1em, weight: 700, block([#it.body]))
}

#set heading(numbering: (..ns) => {
  let ns = ns.pos()
  if ns.len() == 1 {
    return "Chapter " + numbering("A.", ..ns)
  }
  return numbering("1.", ..ns)
})

= Introduction

== Introduction

This is the introduction.

= Background

== Background

This is the background.

#counter(heading).update(0)
#set heading(numbering: (..ns) => {
  let ns = ns.pos()
  if ns.len() == 1 {
    return "Appendix " + numbering("A.", ..ns)
  }
  return numbering("A.1.", ..ns)
})

= Code Snippets

== Code Snippet 1: some Code

```py
print("Hello World")
```

= Additional Information

== Additional Information 1: some Information

This is some additional information.
1 Like

I’ve gone ahead and fixed the formatting you mentioned in your edit, you can see how I’m the edit history :)