1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
% !Mode:: "TeX:DE:UTF-8:Main"
% This example shows how one can patch lists command
% it is based on enumitem
% Pay attention to casing. Li/LI, Lbody/Lbody are different.
% It doesn't test nesting!
% We are using \DocumentMetadata
% This requires a new pdfmanagement and/or latex-dev!
% Older systems should use \DeclareDocumentMetadata
\IfFormatAtLeastTF{2022-06-01}{}
{\RequirePackage{pdfmanagement-testphase}}
\DocumentMetadata{pdfversion=1.7,uncompress,testphase=tagpdf}
\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{iftex}
\ifluatex
\usepackage{fontspec}
\usepackage{luacode}
\else
\usepackage[T1]{fontenc}
\fi
\tagpdfsetup
{
tabsorder=structure,
}
\usepackage{lipsum}%\textheight3cm
\usepackage{enumitem,xpatch}
% At first we add to the begin/end hooks the structure commands.
% To avoid problems with nested paragraphs we force a new paragraph for now.
% Real code should avoid that!
\AddToHook{env/itemize/begin}{\par\tagstructbegin{tag=L}}%\par is needed to close the paragraph before.
\AddToHook{env/itemize/end}{\par\tagstructend\tagstructend\tagstructend}%LBody,LI,L
\AddToHook{env/enumerate/begin}{\par\tagstructbegin{tag=L}}
\AddToHook{env/enumerate/end}{\par\tagstructend\tagstructend\tagstructend}%LBody,LI,L
\AddToHook{env/description/begin}{\par\tagstructbegin{tag=L}}
\AddToHook{env/description/end}{\par\tagstructend\tagstructend\tagstructend}%LBody,LI,L
\makeatletter
\ExplSyntaxOn
%We detect is this is the first or a follow up item where we have to end a structure first:
\newcommand\tag@enit@format@preset[1]{%
\str_if_eq:eeTF { \prop_item:cn { g__tag_struct_\g__tag_struct_stack_current_tl _prop }{S} }{/L}
{
%\typeout{BEGIN~OF~LIST}
}
{%\typeout{NEXT ITEM}
\tagstructend\tagstructend} % for the LBody/LI
\tagstructbegin{tag=LI}
\tagstructbegin{tag=Lbl}
\tagmcbegin{tag=Lbl}
#1
\tagmcend
\tagstructend
\tagstructbegin{tag=LBody}
}
\ExplSyntaxOff
\xpatchcmd\enit@preset{\@firstofone}{\tag@enit@format@preset}{}{\fail}
%close mc from paratagging and reopen ...
\xpatchcmd\@item{\box\@labels}{\tagmcend \box\@labels \tagmcbegin{tag=P}}{}{\fail}
\makeatother
\begin{document}
%I don't want to handle pagestyles, so set everything to empty:
\pagestyle{empty}\renewcommand\chapterpagestyle{empty}
\begin{itemize}
\item Ducks say quack
\item Marmots say something Parmotlike
\end{itemize}
\begin{enumerate}
\item The highest pass is the Col de l'Iseran.
\item The second highest pass is the Passo dello Stelvio.
\end{enumerate}
\begin{description}
\item[ducks] yellow
\item[marmots] brown
\end{description}
\end{document}
|