The outline always uses the value of the labCounter
in the current context. Since the outline is located before any of the lab slides, the counter will just be 0.
If you place the entire heading()
into the context
, the heading titles are displayed correctly in the outline.
#set heading(numbering: "1.1")
#let lab-counter = counter("lab")
#let lab-slide(title) = {
lab-counter.step()
context { heading(level: 2, [Lab #lab-counter.display(): #title]) }
}
#outline(indent: auto)
= foo
#lab-slide("fizz")
#lab-slide("buzz")
#lab-slide("fizzbuzz")
= bar
#lab-slide("blafoo")
#lab-slide("foobla")
I am not sure about the technical reasons for this behavior. The outline just seems to grab all the headings and it does not care if the function heading()
was called in a specific context? I created a minimal example project to show this behavior here. If you hover over the it
inside the show rule for the outline entries, the context()
is not mentioned anywhere. In your case the entry.heading.body
would be sequence([Lab], [ ], context(), [:], [ ], [fizz])
.