Hi all,
I am writing a template for a book and I am facing an unexpected issue related to the numbering of the figures in a list of figures.
To clarify the actual problem, here is a very minimal template of the book :
#import "@preview/subpar:0.2.2"
// Wrapper of subpar.grid with dedicated numbering by section
#let subfigure = subpar.grid.with(
gap: 1em,
numbering: n => numbering("1.1", counter(heading).get().first() , n),
numbering-sub-ref: (m, n) => numbering("1.1a", counter(heading).get().first(), m, n),
supplement: [Figure]
)
// Definition of an outline for the list of figures
#let lof() = {
set outline.entry(fill: box(width: 1fr, repeat(gap: 0.25em)[.]))
outline(title: [List of Figures], target: figure.where(kind: image))
}
}
// Template
#let book(
title: "Title",
author: "Author Name",
body
) = {
let title-page = {
set align(center + horizon)
text(title, size: 32pt, weight: "bold")
v(2em)
text(author, size: 12pt, weight: "regular")
pagebreak()
}
title-page
// Figures
let numbering-fig = n => context {
let h1 = counter(heading).get().first()
numbering("1.1", h1, n)
}
show figure.where(kind: image): set figure(
supplement: [Figure],
numbering: numbering-fig,
gap: 1.5em
)
show figure: set figure.caption(separator: [ -- ])
set heading(numbering: "1.1.")
body
}
The main.typ is given below :
#import "book.typ": *
#show: book.with()
#lof()
= Part 1
#figure(
rect[Hello],
caption: [My caption]
)
#subfigure(
figure(rect[Good], caption: []),
figure(rect[Morning], caption: []), <b>,
columns: (1fr, 1fr),
caption: [(a) Left image and (b) Right image],
label: <fig:subfig>,
)
If you compile this MWE, you will see that the numbering of the figures works as expected (1.1, 1.2). However, this numbering is not properly reflected in the list of figures, since normal figures are referred to as Figure 0.1 instead of Figure 1.1
I have inspected the problem a bit the outline entry. It comes that the prefix for the subpar figure is:
sequence([Figure], [ ], context())
while for the subpar figure it is:
sequence([Figure], [ ], [1.2])
Is there a workaround to properly reference the figures in the list of figures.
Thank you