Debian Codegraph @

texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty

raw
1 %\RequirePackage[enable-debug]{expl3}[2018/06/14]
2 \ProvidesExplPackage {tagpdfdocu-patches} {2026-05-17} {1.0c}
3 {patches/commands for the tagpdf documentation}
4 \RequirePackage{etoolbox,xpatch}
5
6 %Logos
7 % only spacing changes:
8 \ExplSyntaxOn
9 \DeclareRobustCommand\TeX{
10 \leavevmode
11 T\kern-.1667em\lower.5ex\hbox{E}\kern-.05emX\@ %changed from -.125em
12 }
13 \DeclareRobustCommand{\LaTeX}{
14 \leavevmode
15 L\kern-.25em % %changed from -0.36em
16 \sbox\z@ T%
17 \vbox to\ht\z@{\hbox{\check@mathfonts
18 \fontsize\sf@size\z@
19 \math@fontsfalse\selectfont
20 A}%
21 \vss}%
22 \kern-.1em % %changed from 0.15em
23 T\kern-.1667em\lower.5ex\hbox{E}\kern-.05emX\@ %changed from -0.125
24 }
25
26 % minisec, correct tagging is still unclear.
27 \newcommand\minisec[1]{%
28 \if@noskipsec \leavevmode \fi
29 \par
30 \@afterindentfalse
31 \if@nobreak
32 \everypar{}%
33 \else
34 \addpenalty\@secpenalty\addvspace{1.5ex}%
35 \fi
36 {\tagpdfsetup{para/maintag=P,para/tag=Strong}\parindent \z@
37 \setlength{\parfillskip}{\z@ plus 1fil}%
38 \raggedright\normalfont\bfseries\nobreak
39 \nobreak\interlinepenalty \@M #1\par\nobreak%
40 }\nobreak
41 \@afterheading
42 }
43
44 % listings.
45 % The following seems to work, but it errors if the last line of
46 % a listing is empty.
47 % from previous tries there is also a copy taglstlisting.
48 % Support for numbers:
49
50 \NewTaggingSocket{listings/number}{2}
51 \NewTaggingSocketPlug{listings/number}{default}
52 {
53 \tag_mc_end_push:
54 \tagstructbegin{tag=Lbl}
55 \tagmcbegin{}
56 #2
57 \tagmcend
58 \tagstructend
59 \tag_mc_begin_pop:n{}
60 }
61 \AssignTaggingSocketPlug{listings/number}{default}
62 \ExplSyntaxOff
63 \lst@Key{numbers}{none}{%
64 \let\lst@PlaceNumber\@empty
65 \lstKV@SwitchCases{#1}%
66 {none:\\%
67 left:\def\lst@PlaceNumber{\llap{\normalfont
68 \UseTaggingSocket{listings/number}{}{\lst@numberstyle{\thelstnumber}}\kern\lst@numbersep}}\\%
69 right:\def\lst@PlaceNumber{\rlap{\normalfont
70 \kern\linewidth \kern\lst@numbersep
71 \UseTaggingSocket{listings/number}{}{\lst@numberstyle{\thelstnumber}}}}%
72 }{\PackageError{Listings}{value `#1' for keyword `numbers' not supported}\@ehc}}
73 \ExplSyntaxOn
74
75 % environment tagging. Updated 2025-12-27 to new block code
76
77 % new code from 2025-12-27, requires latex-dev
78 \DeclareInstance{blockenv}{lstlisting}{std}
79 {
80 name = lstlisting,
81 tag-name = verbatim,
82 tag-attr-class = ,
83 tagging-recipe = standard,
84 inner-level-counter = ,
85 transparent-level = true,
86 legacy-code = ,
87 block-instance = verbatim ,
88 inner-instance = ,
89 final-code = \AssignStructureRole {para/textblock}%
90 {\UseStructureName{block/verbatim/codeline}}\ignorespaces,
91 tagging-suppress-paras = true
92 }
93
94 \lst@AddToHook{PreInit}
95 {
96 \MathCollectFalse
97 \ifx\lst@float\relax
98 \SimpleBlockEnv{lstlisting}{}%
99 \else
100 \SimpleBlockEnv{lstlisting}{tagging-recipe = standalone}
101 \fi
102 }
103
104 \lst@AddToHook{DeInit}
105 {\BlockEnvEnd}%
106
107 \tagpdfsetup{float/new=lstlisting}
108
109 % ======== marginnote ==========
110 % 2024-03-23 currently marginnote is no longer used, we use marginpar
111 % TODO marginnote has a bug (a \par is missing) so it messes up tagging.
112 % but currently unneeded as we marked them up as artifacts anyway as they don't contain
113 % meaningful contents
114 %\renewcommand*{\mn@parboxrestore}{\tagpdfparaOff}%
115
116 %\NewDocumentCommand\sidenote{m}
117 % {%
118 % %\tag_mc_artifact_group_begin:n{notype}\tagpdfparaOff\marginnote{#1}\tag_mc_artifact_group_end:
119 % \marginpar{#1}%
120 % }
121
122 \ExplSyntaxOff
123
124 %======== tcolorbox ========
125 % We switch of paratagging at the begin and reenable it locally in before upper.
126 % the before upper setting is dangerous as it can be overwritten by
127 % users. So a more stable hook is needed.
128 % we force also a \par and add a div structure, to avoid clashes with the block
129 % tagging code. This needs revisiting!
130
131 %\AddToHook{env/tcolorbox/before}{\par\tagstructbegin{tag=Div}}
132 %\AddToHook{env/tcolorbox/begin}{%
133 %\AssignTaggingSocketPlug{minipage/before}{noop}%
134 %\AssignTaggingSocketPlug{minipage/after}{noop}%
135 %\tagpdfparaOff \tcbset{before upper=\tagpdfparaOn}}
136 %\AddToHook{env/tcolorbox/after}{\par\tagstructend}
137
138 % ========= doc Commands from tcolorbox
139 % Not sure if this is generally usable but one must avoid tagstop if there can
140 % be a pagebreak
141
142 \NewTaggingSocketPlug{para/begin}{tagpdf/mc}{\tagmcbegin{}}
143 \NewTaggingSocketPlug{para/end}{tagpdf/mc}{\tagmcend}
144
145 \DeclareInstance{blockenv}{docCommand}{std}
146 {
147 name = docCommand,
148 tag-name = Div,
149 tag-attr-class = ,
150 tagging-recipe = standalone,
151 inner-level-counter = ,
152 transparent-level = true,
153 legacy-code = ,
154 block-instance = std-display ,
155 }
156
157 \RenewDocumentEnvironment{tcb@manual@entry}{}
158 {\SimpleBlockEnv{docCommand}
159 {
160 leftmargin=\kvtcb@doc@left,
161 rightmargin=\kvtcb@doc@right,
162 tag-name=verbatim
163 }%
164 \MathCollectFalse
165 \AssignStructureRole {tcb/box}{codeline}%
166 \AssignTaggingSocketPlug{para/begin}{tagpdf/mc}
167 \AssignTaggingSocketPlug{para/end}{tagpdf/mc}
168 \AssignTaggingSocketPlug{minipage/before}{noop}%
169 \AssignTaggingSocketPlug{minipage/after}{noop}%
170 }
171 {\BlockEnvEnd }
172
173
174 % the \meta command uses \langle/\rangle which produce formulas in code.
175 % this need some general solution! For now we suppress tagging of \ensuremath.
176 \long\def\@ensuredmath#1{{\MathCollectFalse$\relax#1$}}
177
178
179 % ====== hyperref ========
180 % this should probably go into hyperref, but it is related to
181 % problem of pdf strings and context ....
182
183 \AddToHook{package/hyperref/after}
184 {%
185 \pdfstringdefDisableCommands{%
186 \let\tagstructbegin\@gobble
187 \let\tagmcbegin\@gobble
188 \let\tagmcend\relax
189 \let\tagstructend\relax
190 }}{}
191
192
193
194 \endinput