#Numbering by section
5 messages · Page 1 of 1 (latest)
?render
#set heading(numbering: "1.1")
#show heading.where(level: 1).or(heading.where(level: 2)): it => {
context counter(figure.where(kind: table)).update(0)
context counter(figure.where(kind: image)).update(0)
context counter(figure.where(kind: raw)).update(0)
it
}
#set figure(numbering: (..num) => {
numbering(
heading.numbering,
..(..counter(heading).get(), 0, 0).flatten().slice(0, 2),
..num,
)
})
- Top fig: #text(green)[@top]
- Sub fig: #text(green)[@sub]
- Subsub fig: #text(green)[@subsub]
- Appendix fig: #text(red)[@app]
#figure(
rect[Test],
caption: "Test",
) <top>
= Sec
#figure(
rect[Test],
caption: "Test",
)
== Subsec
#figure(
rect[Test],
caption: "Test",
) <sub>
=== Subsubsec
#figure(
rect[Test],
caption: "Test",
) <subsub>
#set heading(numbering: "A.1")
#counter(heading).update(0)
= Appendix
- Top fig: #text(red)[@top]
- Sub fig: #text(red)[@sub]
- Subsub fig: #text(red)[@subsub]
- Appendix fig: #text(green)[@app]
#figure(
rect[Test],
caption: "Test",
) <app>
(red is wrong, green is right)
@primal crater I think what you've discovered is neatly discussed in https://forum.typst.app/t/how-to-counter-display-at-location-or-get-remote-context/5096
What the perfect solution is, is still under active discussion.
I assume you've already stumbled on these issues:
I've also submitted a proposal to add an optional level field to the figure element (see https://github.com/typst/typst/issues/6767 and https://github.com/typst/typst/pull/6768)
However, the right course forward is yet to be determined.
Of course, we'd love to invite you to the discussion and find a good approach for how to handle multi-level numberings in a clean and consistent manner ❤️
Cheerful regards,
Robin
How to display the value of a counter at a given location? Note that the numbering may have changed or depend on the context. Therefore, it looks like that I need the remote context or to time travel. I know I can achieve it for counters and states, but is it possible for context? To be specific, how to get the original figure.numbering at <fi...
Description I suggested this change a while back on Discord. The idea is to have numbering patterns that depend on other counters, like equations being numbered per chapter (1.1), (1.2), (2.1), ......
This adds a new hierarchical count() function which will both enable dependent counters and simplify the Rust code for counters at the same time.
I propose that this mechanism will replace the coun...