Skip to content

LaTeX writer: Add PDF standard support via DocumentMetadata#11407

Merged
jgm merged 1 commit intojgm:mainfrom
gordonwoodhull:pdfstandard
Jan 22, 2026
Merged

LaTeX writer: Add PDF standard support via DocumentMetadata#11407
jgm merged 1 commit intojgm:mainfrom
gordonwoodhull:pdfstandard

Conversation

@gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented Jan 20, 2026

Hi @jgm!

We want to do something like this to support PDF standards in Quarto 1.9, releasing in a month or so.

We'd prefer to have this upstream in Pandoc, as it's going to be an essential feature for Pandoc LaTeX users in public institutions in the US.

It's pretty much the same behavior as Typst's --pdf-standard option.

Summary

Adds pdfstandard metadata variable for generating PDF/A, PDF/X, and PDF/UA compliant documents via LaTeX's \DocumentMetadata command.

Example usage

---
pdfstandard: ua-2
lang: en-US
---

Or multiple standards:

---
pdfstandard:
  - ua-2
  - a-4f
lang: en-US
---

Features

  • Supports PDF/A (a-1b, a-2a, a-2b, a-2u, a-3a, a-3b, a-3u, a-4, a-4e, a-4f), PDF/X, and PDF/UA (ua-1, ua-2) variants
  • Automatically infers required PDF version (e.g., a-2b sets PDF 1.7), or accepts an explicit version (e.g., 1.7, 2.0)
  • Automatically enables tagging for standards that require it (ua-1, ua-2, a-2a, a-3a)
  • Warns on unsupported standard names

Notes

The \DocumentMetadata command must appear before \documentclass, which is handled by a new document-metadata.latex partial template.

Copy link
Owner

@jgm jgm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea, thanks. I've made a couple small comments. Also tests will probably need to be updated; you can do make TESTARGS=--accept and then inspect the changes to see if everything looks right.

@gordonwoodhull
Copy link
Contributor Author

Thanks @jgm, sounds good. I've pushed fixes.

The CI error was a -Werror thing.

Comment on lines 9 to 13
$if(pdfstandard)$
$-- lang is set in DocumentMetadata instead
$else$
pdflang={$lang$},
$endif$
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you verified that including pdflang here, even if it is also set in DocumentMetadata, causes a problem? It's worth checking on this, because if it doesn't cause a problem, it's cleaner to leave it here.

Copy link
Contributor Author

@gordonwoodhull gordonwoodhull Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double checked this - they have the same effect, and \hypersetup takes precedence (overwrites).

So it's harmless to do both, and I've removed the change.

Copy link
Owner

@jgm jgm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is close to ready! I made a couple more comments on things that can be improved.

Add `pdfstandard` metadata variable for specifying PDF standards
(PDF/A, PDF/X, PDF/UA) in LaTeX output. Uses LaTeX's \DocumentMetadata
command which requires LuaLaTeX.

Features:
- PdfStandard data type for clean configuration handling
- Automatic PDF version inference (e.g., a-2b implies PDF 1.7)
- Automatic tagging for standards that require it (ua-1, ua-2, a-2a, a-3a)
- Support for explicit version override
- Warning for unsupported standards
- Documentation in MANUAL.txt (Variables for LaTeX, Accessible PDFs)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jgm jgm merged commit e07a3f3 into jgm:main Jan 22, 2026
8 of 11 checks passed
Comment on lines +7825 to +7826
requires LuaLaTeX and a recent LaTeX installation.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried the command above after compiling with this code. I got the error: "! LaTeX Error: The key 'document/metadata/tagging' is unknown and is being
(LaTeX) ignored." I'm guessing this is because my lualatex is too old? It's from TeXLive 2024, lualatex 1.18.0. Can we document the version required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

@jpcirrus
Copy link
Contributor

I believe this change is going to cause issues as the 2025-11-01 LaTeX release extended the \DocumentMetadata command to always load the tagging support code even with tagging=off, and many classes (e.g. KOMA-Script) and packages don't yet support tagging. The current way to support PDF standards, without loading the tagging support code, is for example from my custom latex template:

\RequirePackage{pdfmanagement}
\SetKeys[document/metadata]{%
  lang=${if(lang)}${lang}${else}en-NZ${endif},
  pdfstandard=${if(pdfstandard)}${pdfstandard}${else}A-3u${endif}
}

For details see the newsletter for the LaTeX 2025-11-01 release and the the open and closed issues as well as CHANGELOG.md of the LaTeX PDF management bundle.

Unfortunately, I'm not going to be able to contribute more as I'm currently in the process of hiking the south island of New Zealand and am off again tomorrow.

@jgm
Copy link
Owner

jgm commented Jan 24, 2026

I'm a bit confused, the release note says:

Tagging remains opt-in, still needing \DocumentMetadata{lang = ..., tagging = on}.

@jgm
Copy link
Owner

jgm commented Jan 24, 2026

We could perhaps use a conditional:

$if(pdfstandard)$
$if(pdfstandard.tagging)$
% what we do above
$else$
\RequirePackage{pdfmanagement}
\SetKeys[document/metadata]{%
% set lang and standard
}
$endif$
$endif$

@jpcirrus
Copy link
Contributor

We would also need to test for the version of the LaTeX kernel as the original proposal works up to the 2025-11-01 release with both tagging=on and tagging=off. It is only from the 2025-11-01 version when tagging=off that the standard and other options need to be set using

\RequirePackage{pdfmanagement}
\SetKeys[document/metadata]{%
% set lang and standard
}

Since 2020-10-01 there exists the command \IfFormatAtLeastTF{2025-11-01}{% true code}{% false code} for that purpose.

@jgm
Copy link
Owner

jgm commented Jan 25, 2026

Good, then we could also issue an error if the kernel is < 2025-06-01 and pdfstandard has been specified.

@jgm
Copy link
Owner

jgm commented Jan 25, 2026

I opened a new issue at #11421 since this is closed.

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.

3 participants