Skip to content

Replace fig-pos [H] with [h] when PDF tagging is active#14165

Closed
gordonwoodhull wants to merge 1 commit intomainfrom
bugfix/14164
Closed

Replace fig-pos [H] with [h] when PDF tagging is active#14165
gordonwoodhull wants to merge 1 commit intomainfrom
bugfix/14164

Conversation

@gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented Mar 6, 2026

Summary

  • Fix broken PDF tag structure for figures when pdf-standard: ua-2 is set
  • Replace [H] float placement with [h] when PDF tagging is active, across all filter pipeline locations
  • Also fixes the previously-known non-cross-referenceable figure caption issue

Details

The [H] specifier (from LaTeX's float package) redefines the figure environment in a way that breaks lualatex's PDF tagging system — /Caption and /Figure end up as direct children of /Document instead of being properly nested. This causes verapdf to report <Document> shall not contain <Caption>.

Multiple code paths inject [H]: knitr/Jupyter execution engines (for echoed code chunks), pandoc3_figure.lua (for non-cross-referenceable figures), and quarto-post/latex.lua (for panel layouts). Cross-referenceable static images were unaffected only because they happen not to get [H] — the LaTeX output is structurally identical in all cases.

Empirical testing of placement specifiers with pdf-standard: ua-2:

Specifier verapdf result
(none) PASSED
[h] PASSED
[htbp] PASSED
[H] FAILED<Document> shall not contain <Caption>

Only [H] (from the float package) breaks tagging. All standard LaTeX specifiers work correctly. [h] is the closest semantic equivalent to [H] ("place here") without the float package's incompatible reimplementation.

Upstream: latex3/tagging-project#890

Changes

  • `src/format/pdf/format-pdf.ts` — expose `pdf-tagging` metadata to Lua filters
  • `src/resources/filters/quarto-pre/figures.lua` — replace `fig-pos='H'` with `'h'` when tagging is active
  • `src/resources/filters/quarto-post/latex.lua` — same for panel layouts and star environments
  • `src/resources/filters/layout/pandoc3_figure.lua` — same for non-cross-referenceable figures
  • `tests/docs/smoke-all/pdf-standard/ua-code-chunk-figure.qmd` — new test for R code chunk figure with ua-2
  • `tests/docs/smoke-all/pdf-standard/ua2-unlabeled-figure-caption.qmd` — updated from known-failure to passing

Test plan

  • New test `ua-code-chunk-figure.qmd` passes (R code chunk + ua-2 + verapdf)
  • Updated `ua2-unlabeled-figure-caption.qmd` now passes
  • Full `pdf-standard/` test suite: 40 passed, 0 failed
  • TypeScript typecheck passes

Fixes #14164

@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Mar 6, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gordonwoodhull gordonwoodhull marked this pull request as draft March 6, 2026 04:22
The [H] placement specifier (from LaTeX's float package) breaks
lualatex's PDF tag structure, causing /Caption and /Figure to appear
as direct children of /Document instead of being properly nested.
Standard [h] ("place here") is the closest equivalent without the
float package's incompatible reimplementation.

When pdf-standard requires tagging (e.g. ua-2), all automatic [H]
injections are replaced with [h] across the filter pipeline:
- quarto-pre/figures.lua (execution engine fig-pos defaults)
- quarto-post/latex.lua (panel layouts and star environments)
- layout/pandoc3_figure.lua (unlabeled figures)

Fixes #14164
@gordonwoodhull gordonwoodhull changed the title Replace fig-pos [H] with [htbp] when PDF tagging is active Replace fig-pos [H] with [h] when PDF tagging is active Mar 6, 2026
@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Mar 6, 2026

This is apparently not the way - there are hooks that can be set in order to make the float package work.

EDIT: Further research shows that no, there are no such hooks for float. But I don’t think making our floats into non-floats will be an acceptable solution.

@gordonwoodhull gordonwoodhull deleted the bugfix/14164 branch March 6, 2026 14:52
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 this pull request may close these issues.

Code chunk figures with fig-pos='H' produce broken PDF tag structure with pdf-standard: ua-2

2 participants