Hi all, I am attempting to write an academic paper in Typst, but I have hit some formatting issues.
The paper I am writing is composed of a main section, as well as a supplement. I would like to number headings, figures, tables and equations in the main section like “1” etc, but in the supplement I would like to number them like “S1” etc.
Since there is no way to cross reference a separate document in Typst I am just including the supplement at the end of the main document. This is necessary, as I refer to supplementary sections from the main paper.
Based on a similar question I have created a MWE for the main paper:
#let supplement(content) = {
set heading(numbering: "S1")
set math.equation(numbering: "(S1)") // this is not changing the formating...
counter(heading).update(0)
counter(figure).update(0) // why is this not updating?
counter(math.equation).update(1) // this seems to work?
state("supplement").update(true)
content
}
#set figure(numbering: n => {
let appx = state("supplement", false).get()
let format = if appx {
"S 1"
} else {
"1"
}
numbering(format, n)
})
#set math.equation(numbering: n=> { // why does this not do anything?
let appx = state("supplement", false).get()
let format = if appx {
"S 1"
} else {
"1"
}
numbering(format, n)
})
#set heading(numbering: "1")
#set math.equation(numbering: "(1)")
#let testfig(caption) = {
figure(box(width:3cm, height:1cm, stroke: 1pt), caption: caption)
}
#set page(width: auto, height: auto, margin: 2em)
= Start
<sec1>
In @sec1 Citing the figures in order @first, @second, and @third.
#testfig[First Box] <first>
Let us cite @eq1 as well.
$
2+2
$ <eq1>
Use a table here called @tab which is different to @stab.
#figure(
table(
columns: 2,
[blah], [blah]
),
caption: [A table]
) <tab>
= Next
#lorem(10)
#testfig[Second Box] <second>
Supplementary citations include: @s_sec and @a_eq but these don't display...
#show: supplement
#include "supp.typ"
and another MWE for the supplement:
#let testfig(caption) = {
figure(box(width:3cm, height:1cm, stroke: 1pt), caption: caption)
}
#set page(width: auto, height: auto, margin: 2em)
= Supplement
<s_sec>
#lorem(10)
#testfig[Third Box] <third>
Some more text...
#figure(
table(
columns: 2,
[blah], [blah]
),
caption: [A table]
) <stab>
$1 + 1$ <a_eq>
Unfortunately, this solution does not work because:
- the figure and table counters do not reset (but the header, and maybe the equation?, does weirdly enough…)
- the math equation in the supplement does not display its numbering next to its definition
- The heading and math references in the supplement do not display the “S1” style formatting
If anyone has any fixes, I would really appreciate it! I am at a loss of what to do now