I would like to use custom counters to number different “types” of headings (for example “Schedule” and “Lab”). But I cannot figure out how to reference these headings.
I have used a previous question to get it working with the following code:
#let schedule-counter = counter("schedule")
#let lab-counter = counter("lab")
#let lab-header(title) = {
lab-counter.step()
context {
heading(supplement: "Lab", [#lab-counter.display(). #title])
}
}
#let schedule-header(title) = {
schedule-counter.step()
context {
heading(supplement: "Schedule", [Schedule #schedule-counter.display(): #title])
}
}
#outline()
#schedule-header([My First Schedule]) <schedule:a>
#schedule-header([My Second Schedule]) <schedule:b>
#schedule-header([My Third Schedule]) <schedule:c>
#lab-header([My First Lab]) <lab:a>
#lab-header([My Second Lab]) <lab:b>
#lab-header([My Third Lab]) <lab:c>
It is working perfectly and everything is display exactly how I want it - the headings themselves as well as how they appear in the outline:
Contents
Schedule 1: My First Schedule ....... 1
Schedule 2: My Second Schedule ...... 1
Schedule 3: My Third Schedule ....... 1
1. My First Lab ..................... 1
2. My Second Lab .................... 1
3. My Third Lab ..................... 1
Schedule 1: My First Schedule
Schedule 2: My Second Schedule
Schedule 3: My Third Schedule
1. My First Lab
2. My Second Lab
3. My Third Lab
But how can I now reference them?
Testing @schedule:a and @schedule:b and @schedule:c and @lab:a and @lab:b and @lab:c.
I get “cannot reference sequence” errors. I have already added the supplement in the heading in anticipation.
If I try to create a label near where heading is called, I get “cannot join content with label”. If possible, I would like to keep #schedule-header([My First Schedule]) <schedule:a> syntax of defining headings and labels.