How can I customize entries in the figure outline?

Hi all!
I’ve got maybe a bit of a silly question that I’ve been having a hard time searching for solutions. I’d like to customize the entries of my list of figures so that it lists the number of the figure, so “1” not “Figure 1”.
Something like the following image:


Best,
Adrian

Could you format your title as a question you would ask a friend? Also, it helps speed up answering if you post the code that produced the image you shared.
See How to post in the Questions category for more tips and info. Using these suggestions honestly does improve the chance that your question will get answered.

As for the answer to your question, one way to achieve this is to simply blank out the supplement (“Figure” in English) using a show rule:

#show outline.entry: it => {
  show it.element.caption.at("supplement").text: none
  it
}

#outline(target: figure)

#figure(
  box(stroke: 1pt, fill: red, width: 3em, height: 1em),
  caption: [Red Box]
)
#figure(
  box(stroke: 1pt, fill: blue, width: 3em, height: 1em),
  caption: [Blue Box]
)

Edit:
Y.D.X’s solution is much more robust and complete than this one. Removing the leading spacing of this solution is simple though:

Updated Show Rule
#show outline.entry: it => {
  let supplement-text = it.element.caption.at("supplement").text
  let pattern = "\s*" + supplement-text + "\s*"
  show regex(pattern): none
  it
}
1 Like

Here’s a better approach (in my opition). It removes the leading spaces in gezepi’s version, and allows adding dots after numbers.

See https://typst.app/docs/reference/model/outline/#building-an-entry for more info.

#{
  show outline.entry: it => link(
    it.element.location(),
    it.indented(
      // Rewrite it.prefix()
      context numbering("1.", ..it.element.counter.at(
        it.element.location(),
      )),
      it.inner(),
    ),
  )
  outline(
    title: [List of Figures],
    target: figure.where(kind: image),
  )
}

= Heading

#figure(
  rect[Image],
  caption: [Experiment results],
)

2 Likes

My apologies, bit of a late night last night and I missed that pinned post. I could have formatted the question better.
Thanks to you and @Y.D.X, you’ve both taught me more about how show rules work!

2 Likes