tingerrr / subpar

A typst package for creating sub figures.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

If inside the main figure's caption, don't prefix subfigure ref with figure ref

janosh opened this issue · comments

i'd like to not prefix the subfigure counter with the main figure when referencing from within the main figure's caption. in this example

#import "@preview/subpar:0.1.0"

#subpar.grid(
  figure(image("/assets/andromeda.jpg"), caption: [
    An image of the andromeda galaxy.
  ]), <a>,
  figure(image("/assets/mountains.jpg"), caption: [
    A sunset illuminating the sky above a mountain range.
  ]), <b>,
  columns: (1fr, 1fr),
  caption: [A figure composed of two sub figures, @a and @b],
  label: <full>,
)

i'm trying to get the caption

A figure composed of two sub figures, a) and b)

instead of

A figure composed of two sub figures, Figure 1a and Figure 1b

Related comment

That makes sense, I actually recently looked at the issue and thought about this. I'll see if this works nicely with the ref syntax, but assuming it does, there are two ways to go about this:

  • Use numbering-sub by default, in this example we'd get (a) since this is also the default for sub figure caption numbering.
  • Add a new numbering parameter which is auto by default and falls back to numbering-sub-caption then, but I am unsure how that could be named.

The latter would allow more flexibility, but add also complexity, especially because the name would likely be confusing without reading the docs closely. If you have suggestions, I'm all ears.

the behavior i'm suggesting seems like a sensible default to me so maybe no new numbering parameter needed.

I was trying to take a crack at this, but it seems harder to get right than I thought. It still needs some extra care when counter resets are done, which happens for chapter relative numbering of figures, but let's ignore that for a second.

Currently, when outlining a figure, which would reference its own sub figures in the caption, the caption would look different in the outline itself. However, I wonder if this is even a problem in practice. The screenshot shows what I mean:
image

My assumption is that someone who references sub figures in the caption is likely writing a large caption and has another shorter version for the outlined caption. So I wonder if it makes more sense to ignore this and slap a warning on it?

I don't think this is a problem but, as you mentioned, a caption referencing its sub figures may be too long for the outline. In that case, how can we overwrite the outlined caption?

In that case, how can we overwrite the outlined caption?

There's no built-in mechanism currently, but here's a de facto solution.