How to remove certain level 3 headings from outline?

I’m having difficulty finding the right syntax for this. I have some sections of my document that I want to suppress certain heading levels from the outline, and I thought the outlined parameter would be the one to use.

Basically, my intent is something like set heading(outlined: false).where(level: 3). I know this isn’t valid, but just an example.

For example, I have a block that I want everything inside to suppress level 3 heading:

#let suppress_lvl_3(doc) = {
    // Insert suppression logic here
    doc
}

I thought this would work:

#let suppress_lvl_3(doc) = {
    show heading.where(level: 3):it => {
        set heading(outlined: false)
        it
    }
    doc
}

But it doesn’t seem to have an effect.

I know there is a way to set conditionally using a syntax that looks like #set heading(outlined: false) if CONDITION HERE, but I don’t know what condition would work for this. Any idea on the simplest way to do this?

Hello! I suppose you are using your function like this: show: suppress_lvl_3? or suppress_lvl_3[content]? Without knowing more about your document, it’s difficult to tell why it’s not working.

Alternatively, just write a show-set rule!

show heading.where(level: 3): set heading(outlined: false) // turn it off
[suppressed section]
show heading.where(level: 3): set heading(outlined: true) // turn it on
2 Likes

Depending on your structure, you might want to select the headings that should be excluded:

#show <not-outlined>: set heading(outlined: false)

#outline()

= Level 1
== Level 2
=== Level 3 <not-outlined>
= Level 1
== Level 2
=== Level 3 <not-outlined>
3 Likes

Wow, I can’t believe it was that simple! Thanks a lot!

But why wasn’t this working:

#show heading.where(level: 3):it => {
        set heading(outlined: false)
        it
}

Your solution looks quite similar, so I’m struggling to see how they differ at a fundamental level, but I’m not fully familiar with the syntax. Could you explain a bit of the differences between this and your solution in terms on why mine was not working?

Ahh interesting! I didn’t know labels could be used like this. Thanks for the tip!

1 Like

I have to correct myself. The reason why your set instruction is not working is because it is inside your heading already.

As we cannot modify elements yet, but assume it is possible, the “correct” way would be

#show heading.where(level: 3): it => {
    it.outlined = false
    it
}

The heading already exists at the point the show rule is in place, so your rule is essentially ignored.

1 Like

Or you can just define a custom heading function:

#let heading3 = heading.with(outlined: false)

#outline()

= Level 1
== Level 2
#heading3[Level 3]
= Level 1
== Level 2
#heading3[Level 3]
2 Likes

You say “yet”, does it mean that this is in the pipeline to be implemented in the future?

A lot of stuff now is immutable. I don’t know if there will be a possibility to edit elements in-place, but there are a ton of things to do now, so maybe one day, but not anywhere soon.

2 Likes