Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
janosh opened this issue May 19, 2024 · 5 comments · May be fixed by #13
Open

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

janosh opened this issue May 19, 2024 · 5 comments · May be fixed by #13

Comments

@janosh
Copy link

janosh commented May 19, 2024

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

@tingerrr
Copy link
Owner

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.

@janosh
Copy link
Author

janosh commented May 20, 2024

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

@tingerrr
Copy link
Owner

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?

tingerrr added a commit that referenced this issue Jul 11, 2024
- Ensure super captions referencing their own sub figures only use sub numbering
@tingerrr tingerrr linked a pull request Jul 11, 2024 that will close this issue
@AlbertoFabbri93
Copy link

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?

@tingerrr
Copy link
Owner

tingerrr commented Jul 11, 2024

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants