I use the following code to make the outline in bold style and S “*Figure S1 * The first curious figure” in the outline in the previous version of typst.
How to update it to the newest typst 0.13?
// from: https://github.com/typst/typst/discussions/4515
#show outline.entry: it=> if <no-prefix> != it.fields().at(
default: {},
"label",
) [
#outline.entry(
it.level,
it.element,
{
[*#it.element.caption.supplement S*]
[*#numbering(
it.element.numbering,
..it.element.counter.at(it.element.location()),
)*]
[*.* ]
// figure.caption.separator
it.element.caption.body
},
it.fill,
[#it.page]
)<no-prefix>] else {it}
The complete code here:
#set page("a4", margin: auto)
// Modify bold "Figure S1 in the outline
// from: https://github.com/typst/typst/discussions/4515
#show outline.entry: it=> if <no-prefix> != it.fields().at(
default: {},
"label",
) [
#outline.entry(
it.level,
it.element,
{
[*#it.element.caption.supplement S*]
[*#numbering(
it.element.numbering,
..it.element.counter.at(it.element.location()),
)*]
[*.* ]
// figure.caption.separator
it.element.caption.body
},
it.fill,
[#it.page]
)<no-prefix>] else {it}
// 表格标题粗体
#show figure.caption: it => context[
*#it.supplement~S#it.counter.display().*~#it.body
]
// Long and short captions for the outline
#let in-outline = state("in-outline", false)
#show outline: it => {
in-outline.update(true)
it
in-outline.update(false)
}
#let ffcaption(long, short) = context if in-outline.get() { short } else { long }
#outline(
title: text(size: 1.2em)[Contents#v(1em)],
target: figure.where(kind: image).or(figure.where(kind: table)),
)
= Red Pic
#figure(
rect(height:6cm, width: 11cm, fill: red),
caption: ffcaption([The fisrt curious figure.], [Short1]),
) <fig1>
#figure(
rect(height:10cm, width: 5cm, fill: red),
caption: ffcaption([The second curious figure.], [Short2]),
) <fig2>
= Blue Pic
#figure(
rect(height:2cm, width: 8cm, fill: blue),
caption: ffcaption([The third curious figure.], [Short3]),
) <fig3>