patrick-kidger / patrick-kidger/patstdlib

enable-referable-subfigures`: cross-references to a subfigure's `ref` supplement hardcode "Panel" and omit the parent figure number

Open
#1 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Typst
Stars
13
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Description

When referencing a subfigure (created via subfigure(...) inside enable-referable-subfigures) from a context other than plain in-line body text, specifically, from inside the caption: of a different figure, the rendered reference does not match the normal in-body behavior.

Expected: referencing a subfigure prints something like Figure 6(a), combining the parent figure's number with the subfigure's letter (as it does when referenced from ordinary paragraph text).

Actual: the reference instead prints Panel (a) — a hardcoded "Panel" supplement, with no parent figure number at all.

Minimal reproduction

#import "@preview/patstdlib:0.3.3": enable-referable-subfigures, subfigure
#show: enable-referable-subfigures

#figure(
  grid(
    columns: 2,
    subfigure(image("a.png"), caption: [], label: <fig:main_a>),
    subfigure(image("b.png"), caption: [], label: <fig:main_b>),
  ),
  caption: [Main figure],
) <fig:main>

#figure(
  image("c.png"),
  caption: [
    Compare with the structure shown in @fig:main_a.
  ],
)

In the second figure's caption, @fig:main_a renders as Panel (a) rather than Figure 1(a).

Additional note

The supplement appears to use a non-breaking space between "Panel" and "(a)" rather than a regular space, which also makes it hard to str.replace/regex out as a workaround (had to match \s rather than a literal " ").

Ask

Either fix the reference resolution so it's consistent regardless of the caller's location (matching in-body behavior), or document the limitation and expose a supported way to override the supplement / get the combined "Figure N(letter)" form manually (e.g. a helper function), since #ref(label, supplement: ...) currently appears to be ignored for subfigures.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal reproduction and trace the enable-referable-subfigures, subfigure, and #ref behavior when a subfigure label is referenced inside another figure's caption. Done means the caption reference resolves consistently with body text as Figure N(letter), or the documented supported override/helper produces that form.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.