Skip to content

Commit 9c3c8f1

Browse files
claude: Only enable PDF tagging for standards that require it
PDF tagging is now only enabled for standards that actually require document structure tagging: - PDF/UA (ua-1, ua-2) - accessibility standards require tagging - PDF/A level "a" (a-2a, a-3a) - "accessible" level requires tagging Standards that don't require tagging no longer enable it: - PDF/A level "b" (a-1b, a-2b, a-3b) - "basic" level - PDF/A level "u" (a-2u, a-3u) - "unicode" level - PDF/A-4, a-4e, a-4f - tagging optional - PDF/X standards - print exchange, no tagging - PDF version only (1.7, 2.0) - version is independent of tagging Also fixes supported standards list: - Removed a-1a (not supported by LaTeX DocumentMetadata) - Added a-4e (supported by LaTeX) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 734261e commit 9c3c8f1

4 files changed

Lines changed: 56 additions & 14 deletions

File tree

‎src/format/pdf/format-pdf.ts‎

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,8 @@ function createPdfFormat(
322322
format.render?.[kPdfStandard] ?? format.metadata?.[kPdfStandard],
323323
);
324324
if (pdfStandard.length > 0) {
325-
const { version, standards } = normalizePdfStandardForLatex(
326-
pdfStandard,
327-
);
325+
const { version, standards, needsTagging } =
326+
normalizePdfStandardForLatex(pdfStandard);
328327
extras.pandoc.variables = extras.pandoc.variables || {};
329328
extras.pandoc.variables["pdf-standard"] = true; // Enable the partial
330329
if (version) {
@@ -334,8 +333,10 @@ function createPdfFormat(
334333
// Pass as array - Pandoc template will iterate with $for()$
335334
extras.pandoc.variables["pdf-standards"] = standards;
336335
}
337-
// Always enable tagging for pdf-standard (stable in LaTeX 2025+)
338-
extras.pandoc.variables["pdf-tagging"] = true;
336+
// Enable tagging only for standards that require it (ua-*, a-*a)
337+
if (needsTagging) {
338+
extras.pandoc.variables["pdf-tagging"] = true;
339+
}
339340
}
340341

341342
return extras;
@@ -1262,8 +1263,10 @@ const kbeginLongTablesideCap = `{
12621263

12631264
const kEndLongTableSideCap = "}";
12641265

1265-
// LaTeX-supported PDF standards
1266+
// LaTeX-supported PDF standards (from latex3/latex2e DocumentMetadata)
1267+
// See: https://github.com/latex3/latex2e - documentmetadata-support.dtx
12661268
const kLatexSupportedStandards = new Set([
1269+
// PDF/A standards (note: a-1a is NOT supported, only a-1b)
12671270
"a-1b",
12681271
"a-2a",
12691272
"a-2b",
@@ -1272,7 +1275,9 @@ const kLatexSupportedStandards = new Set([
12721275
"a-3b",
12731276
"a-3u",
12741277
"a-4",
1278+
"a-4e",
12751279
"a-4f",
1280+
// PDF/X standards
12761281
"x-4",
12771282
"x-4p",
12781283
"x-5g",
@@ -1281,6 +1286,18 @@ const kLatexSupportedStandards = new Set([
12811286
"x-6",
12821287
"x-6n",
12831288
"x-6p",
1289+
// PDF/UA standards
1290+
"ua-1",
1291+
"ua-2",
1292+
]);
1293+
1294+
// Standards that require PDF tagging (document structure)
1295+
// - PDF/A level "a" variants require tagged structure per PDF/A spec
1296+
// - PDF/UA standards require tagging for universal accessibility
1297+
// (LaTeX does NOT automatically enable tagging for UA standards)
1298+
const kTaggingRequiredStandards = new Set([
1299+
"a-2a",
1300+
"a-3a",
12841301
"ua-1",
12851302
"ua-2",
12861303
]);
@@ -1289,9 +1306,10 @@ const kVersionPattern = /^(1\.[4-7]|2\.0)$/;
12891306

12901307
function normalizePdfStandardForLatex(
12911308
standards: unknown[],
1292-
): { version?: string; standards: string[] } {
1309+
): { version?: string; standards: string[]; needsTagging: boolean } {
12931310
let version: string | undefined;
12941311
const result: string[] = [];
1312+
let needsTagging = false;
12951313

12961314
for (const s of standards) {
12971315
if (typeof s !== "string") continue;
@@ -1303,12 +1321,16 @@ function normalizePdfStandardForLatex(
13031321
} else if (kLatexSupportedStandards.has(normalized)) {
13041322
// LaTeX is case-insensitive, pass through lowercase
13051323
result.push(normalized);
1324+
// Check if this standard requires tagging
1325+
if (kTaggingRequiredStandards.has(normalized)) {
1326+
needsTagging = true;
1327+
}
13061328
} else {
13071329
warning(
13081330
`PDF standard '${s}' is not supported by LaTeX and will be ignored`,
13091331
);
13101332
}
13111333
}
13121334

1313-
return { version, standards: result };
1335+
return { version, standards: result, needsTagging };
13141336
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: "LaTeX PDF/A-2a standard (accessible)"
3+
format: pdf
4+
pdf-standard: a-2a
5+
keep-tex: true
6+
_quarto:
7+
tests:
8+
pdf:
9+
noErrors: default
10+
ensureLatexFileRegexMatches:
11+
# a-2a is "accessible" level - REQUIRES tagging
12+
- ['\\DocumentMetadata\{', 'pdfstandard=\{a-2a\}', 'tagging=on']
13+
- []
14+
---
15+
16+
# Test Document
17+
18+
This tests PDF/A-2a output with LaTeX. The "a" (accessible) level requires tagging.

‎tests/docs/smoke-all/pdf-standard/latex-pdfa.qmd‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ _quarto:
88
pdf:
99
noErrors: default
1010
ensureLatexFileRegexMatches:
11-
- ['\\DocumentMetadata\{', 'pdfstandard=\{a-2b\}', 'tagging=on']
12-
- []
11+
# a-2b is "basic" level - does NOT require tagging
12+
- ['\\DocumentMetadata\{', 'pdfstandard=\{a-2b\}']
13+
- ['tagging=on']
1314
---
1415

1516
# Test Document
1617

17-
This tests PDF/A-2b output with LaTeX.
18+
This tests PDF/A-2b output with LaTeX. The "b" (basic) level does not require tagging.

‎tests/docs/smoke-all/pdf-standard/latex-pdfversion.qmd‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ _quarto:
88
pdf:
99
noErrors: default
1010
ensureLatexFileRegexMatches:
11-
- ['\\DocumentMetadata\{', 'pdfversion=1\.7', 'tagging=on']
12-
- []
11+
# Version-only should NOT enable tagging (tagging is independent of version)
12+
- ['\\DocumentMetadata\{', 'pdfversion=1\.7']
13+
- ['tagging=on']
1314
---
1415

1516
# Test Document
1617

17-
This tests explicit PDF version 1.7.
18+
This tests explicit PDF version 1.7 without any standard requiring tagging.

0 commit comments

Comments
 (0)