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

id-less typst figures get numbered inside other figures #9857

Closed
gordonwoodhull opened this issue Jun 3, 2024 · 2 comments · Fixed by #10098
Closed

id-less typst figures get numbered inside other figures #9857

gordonwoodhull opened this issue Jun 3, 2024 · 2 comments · Fixed by #10098
Assignees
Labels
bug Something isn't working crossref typst
Milestone

Comments

@gordonwoodhull
Copy link
Contributor

gordonwoodhull commented Jun 3, 2024

And wrongness of numbering ensues.

image

Same example as #9854

---
title: "Typst messy subnumbering"
format:
  typst:
    keep-typ: true
---


::: {#fig-panel2 layout-ncol=2}

![Placeholder](pl200.png)

![Placeholder](pl200.png)

Panels

:::
  1. There should not be supplements and numbering for figures without ids
  2. However, Typst has defined a figure as something that is cross-referenceable, so
  3. It gets automatically upgraded on rendering
  4. But it wasn't a FloatRefTarget so has_subfloats is false.

Note that plain

![Placeholder](pl200.png)

by itself also gets printed as a figure with supplement and numbering.

We seem to be stuck with that for now, unless we wanted to not use Typst figure for these cases, or number them in a void context and strip the text out in post, yuck.

So it seems we should detect this case, and transform these captioned, no-id figures as subfloats so they get lettered appropriately instead of numbered inappropriately.

@gordonwoodhull gordonwoodhull self-assigned this Jun 3, 2024
@gordonwoodhull gordonwoodhull mentioned this issue Jun 3, 2024
3 tasks
@gordonwoodhull gordonwoodhull changed the title id-less figures get numbered inside other figures id-less typst figures get numbered inside other figures Jun 3, 2024
@cscheid
Copy link
Collaborator

cscheid commented Jun 3, 2024

by itself also gets printed as a figure with supplement and numbering.

We seem to be stuck with that for now, unless we wanted to not use Typst figure for these cases, or number them in a void context and strip the text out in post, yuck.

Agreed. Just to reiterate, this is the same situation as in LaTeX. An image with a caption and without a fig- label still becomes a default float (Figure):

---
format: pdf
---

Hi.

![A caption]({{< placeholder >}})

Hi.
image

So it seems we should detect this case, and transform these captioned, no-id figures as subfloats so they get lettered appropriately instead of numbered inappropriately.

Exactly. Ideally we'd do the same thing in LaTeX, but I just realized that the following causes a LaTeX bug:

::: {#fig-1}

![An inner caption]({{< placeholder >}})

![An inner caption]({{< placeholder >}})

An outer caption.

:::

This causes the dreaded not in outer par mode case. I think it happens because we have an outer FloatRefTarget with inner pandoc.Figure nodes, per our filter trace:

  - t: "Para"
    content: "Hi."
  - customAST: true
    type: "Figure"
    identifier: "fig-1"
    t: "FloatRefTarget"
    attributes: []
    classes: []
    scaffold:
      - t: "Div"
        attr: "('', [], ['__quarto_custom_scaffold,true'])"
        content:
          - t: "Figure"
            attr: "('', [], [])"
            content:
              - t: "Plain"
                content:
                  - t: "Image"
                    attr: "('', [], [])"
                    caption: "An inner caption"
                    src: "data:image/png;base64,..."
                    title: ""
            caption:
              - null
              -
                - t: "Plain"
                  c:
                    - t: "Str"
                      c: "An"
                    - t: "Space"
                    - t: "Str"
                      c: "inner"
                    - t: "Space"
                    - t: "Str"
                      c: "caption"
          - t: "Figure"
            attr: "('', [], [])"
            content:
              - t: "Plain"
                content:
                  - t: "Image"
                    attr: "('', [], [])"
                    caption: "An inner caption"
                    src: "data:image/png;base64,..."
                    title: ""
            caption:
              - null
              -
                - t: "Plain"
                  c:
                    - t: "Str"
                      c: "An"
                    - t: "Space"
                    - t: "Str"
                      c: "inner"
                    - t: "Space"
                    - t: "Str"
                      c: "caption"
      - t: "Div"
        attr: "('', [], ['__quarto_custom_scaffold,true'])"
        content:
          - t: "Plain"
            content: "An outer caption."

@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Jun 3, 2024

Very helpful context. The original example above produces

image

with LaTeX.

And this is what I'll enable here, probably by looking for this case with a walk in layout, rather than risk changing the has_subfloats logic in crossref_mark_subfloats() (although maybe worth trying both).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crossref typst
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants