Skip to content

Caption should not be used as fallback alt text for images in PDF/Typst #14107

@gordonwoodhull

Description

@gordonwoodhull

Summary

When an image has a caption but no explicit fig-alt, Quarto silently copies the caption into the image's alt text attribute for LaTeX/PDF and Typst output. This was introduced as part of PDF/UA compliance work but is an accessibility anti-pattern.

The problem

Captions and alt text serve fundamentally different purposes:

  • Caption: Visible text describing the figure's significance in context (e.g., "Figure 3: Comparison of methods A and B showing the 2x improvement")
  • Alt text: Non-visible text describing what the image looks like for screen readers (e.g., "A bar chart with two bars labeled Method A and Method B, where B is approximately twice the height of A")

Using the caption as alt text violates WCAG guidance, which explicitly notes that when a caption is already present, the alt text should describe the image content rather than duplicate the caption. The current behavior silences PDF/UA validators without actually improving accessibility.

Affected code

The fallback logic exists in three places:

  1. src/resources/filters/layout/latex.lua:335-337 (and :387-389, :672-674) — three separate code paths that copy the stringified caption into image.attributes["alt"] before clearing the caption for LaTeX rendering
  2. src/resources/filters/quarto-post/typst.lua:228-232 — same pattern for Typst output

All introduced in commits a867c3c24 (Jan 9, 2026, "Add pdf-standard option with verapdf validation") and ba75b374f (Jan 10, 2026, "Add Typst image alt text for PDF/UA accessibility").

Note: explicit fig-alt works correctly

The explicit fig-alt propagation in src/resources/filters/quarto-pre/figures.lua:31-53 is fine — it correctly propagates user-specified alt text. The problem is only in the fallback when no fig-alt is provided.

Suggested fix

Remove the caption-as-alt fallback and instead either:

  • Emit no alt text, letting PDF/UA validators flag it so authors add proper fig-alt
  • Emit a build warning when an image has a caption but no fig-alt, prompting the author to add one

Metadata

Metadata

Labels

accessibilitybackportbugSomething isn't workinglatexLaTeX engines related libraries and technologiestypst

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions