#let exclude-heading(content) = context {
set heading(outlined: false, bookmarked: false)
let original_nr = counter(heading).get()
{
show heading: it => {
it.numbering + [ ] + it.body + linebreak()
}
content
}
counter(heading).update(original_nr)
}
#set heading(numbering: "1.")
#outline(indent: 16pt)
= Donkey
== Dog
#exclude-heading[
= Lorem Stone
#lorem(5)
]
=== Cat
#exclude-heading[
= Epsum lorem
== Lorem Epsum
#lorem(5)
]
= Donkey
== Dog
=== Cat
I am trying to include a bunch of documents (represented by the exclude-heading here), but I do not want any of the headings of these documents to actually be outlined or bookmarked. For all intends and purposes, they should be just be seen as regular text (the style should stay identical, though!).
I sort of managed to bodge my way around this by resetting the counter and adding a show rule. This fixes the outline numbering and displaying (numberings are broken but the numberings don’t matter for me luckily).
However, the bookmarks are incorrect, I am expecting a bookmark structure in the form of:
Donkey
Dog
Cat
But instead I am getting:
Donkey
Dog
Cat
This is probably due to the fact that Cat is internally still counted as 2.1.1, and not 1.1.1; even if the outline properly reflects the count.
Is there anything I can do to bypass this issue? Is this a bug (specifically, the bookmark and outline counters not matching)?
See the picture below for the output of the code and the mismatched bookmarks (to be clear, this is not a PDF reader issue, as it gives the same output on Chrome/Firefox)
I don’t think it’s related to that issue. The problem is rather in the hierarchy of your headings: the level 3 section “Cat” is not under the level 2 section “Dog”, it’s under the level 1 section “Lorem Stone”. Excluding the heading from the outline doesn’t change that.
A hack to work around this issue is to put these headings at a high level that you normally don’t use, for example with offset 10 (so headings will start at 11). Then we have to manually increase the text size to have levels 11 and 12 look like level 1 or 2.
There’s also the problem that you update the state in the context block based on its own value. This triggers new iterations so if you use exclude-heading a few more times you will have a convergence failure.
To avoid this issue, instead of states we can simply disable numbering for these special headings:
#let exclude-heading(content) = context {
let n = heading.numbering
set heading(outlined: false, numbering: none, offset: 10)
show heading.where(level: 11): set text(1.4em)
show heading.where(level: 12): set text(1.2em)
show heading: it => {
n + [ ] + it.body + linebreak()
}
content
}
This shows the actual numbering value (always 1) as in your example. I don’t know if that’s actually what you want.
Sorry for the late reply, thank you very much for your answer!
I was indeed mistaken to refer to that issue, I think I got tripped up by the fact that the bookmark of Cat is level one (and not three), so I assumed it has something to do with counters.
A hack to work around this issue is to put these headings at a high level that you normally don’t use, for example with offset 10 (so headings will start at 11). Then we have to manually increase the text size to have levels 11 and 12 look like level 1 or 2.
This is a fantastic & elegant solution, and does minimally conflicts with the content I’m trying to handle.
There’s also the problem that you update the state in the context block based on its own value. This triggers new iterations so if you use exclude-heading a few more times you will have a convergence failure.
Thanks for bringing that up! I’ll need to brush up on state/counter management (again).
This shows the actual numbering value (always 1) as in your example. I don’t know if that’s actually what you want.
Yeah, that is not entirely what I wanted, but I managed to find a fix quickly enough by reconstructing the numbering (see below).
set heading(outlined: false, numbering: none, offset: 10)
show heading.where(level: 11): set text(1.4em)
show heading.where(level: 12): set text(1.2em)
show heading: it => {
if it.numbering != none { numbering("1.", ..counter(heading).get().slice(10)) } + [ ] + it.body + linebreak()
}
Thank you again for your solution! I appreciate it!