Hello,
I have a rather large document and would like to introduce section specific outlines rather than one huge outline at the beginning.
To fix ideas, imagine a book divided in sections each containing chapters. I would like the top-level outline to list all sections, and have an additional outline for each section listing all the chapters in the current section.
So far, my solution is:
#set heading(numbering: "1.")
#outline(depth: 1, title: "Table of Contents")
// Global outline
#show outline.entry.where(level: 1): it => {
show repeat: none
}
#show outline.entry.where(level: 2): it => {
context {
// let nbr = heading.numbering
let n = counter(heading).get().first()
let i = it.prefix()
let j = i.text.first()
if j == numbering("1", n) {
link(it.element.location(), it.indented(i, it.inner()))
}
}
}
// Show rules for subsequent outlines
= First heading
#outline(depth: 2, title: [Section content])
== Subheading 1
== Subheading 2
=== Subsection
= Second heading
#outline(depth: 2, title: [Section content])
== Subheading 1
== Subheading 2
While this is somewhat functional, I have some issues with it. First and foremost, this solution requires some numbering for headings. This is because I was not able to identify the current heading other than using the counter. Second, the numbering scheme must be known and used in the function definition. I tried to play around with context heading.numbering
, but could not make it work. Last, I would like to fix the alignment (it still indents the first level even though it is not displayed). I also tried something like this:
#show outline.entry.where(level: 1): it => {
link(it.element.location(), it.indented([], [], gap: 0em))
}
This does fix the indentation problem but now there is a (vertical) gap between the outline title and the first displayed entries (I assume this is where the H1 should be). I tried setting the size to 0 but to no avail.
I would love to hear any idea you may have on how to achieve the desired behavior (does not matter to me if it is completely different from what I tried).
Many thanks.