Debian Codegraph @

texmf-dist/source/latex-dev/latex-lab/latex-lab-mathpkg.dtx

raw
1 % \iffalse meta-comment
2 %
3 %% File: latex-lab-mathpkg.dtx
4 %
5 % Copyright (C) 2022-2026 The LaTeX Project
6 %
7 % It may be distributed and/or modified under the conditions of the
8 % LaTeX Project Public License (LPPL), either version 1.3c of this
9 % license or (at your option) any later version. The latest version
10 % of this license is in the file
11 %
12 % https://www.latex-project.org/lppl.txt
13 %
14 %
15 % The latex-lab bundle is developed in the LaTeX2e GitHub.
16 % Issues may be reported at
17 %
18 % https://github.com/latex3/latex2e/issues
19 %
20 %<*driver>
21 \DocumentMetadata{tagging=on,pdfstandard=ua-2}
22 \documentclass[kernel]{l3in2edoc}
23
24 \EnableCrossrefs
25 \CodelineIndex
26 \begin{document}
27 \DocInput{latex-lab-mathpkg.dtx}
28 \end{document}
29 %</driver>
30 %
31 % \fi
32 %
33 %
34 % \title{The \texttt{latex-lab-mathpkg} code\thanks{}}
35 % \author{\LaTeX{} Project}
36 %
37 % \maketitle
38 %
39 % \newcommand\fmi[1]{\begin{quote} TODO: \itshape #1\end{quote}}
40 % \newcommand\NEW[1]{\marginpar{\mbox{}\hfill\fbox{New: #1}}}
41 % \providecommand\class[1]{\texttt{#1.cls}}
42 % \providecommand\pkg[1]{\texttt{#1}}
43 % \providecommand\hook[1]{\texttt{#1}}
44 %
45 % \begin{abstract}
46 % \end{abstract}
47 %
48 % \tableofcontents
49 %
50 % \section{Introduction}
51 %
52 % This file implements adaptions to various math packages needed for
53 % the tagging project.
54 %
55 % \MaybeStop{\setlength\IndexMin{200pt} \PrintIndex }
56 %
57 % \section{The Implementation}
58 %
59 % \begin{macrocode}
60 %<@@=math>
61 % \end{macrocode}
62 %
63 % \begin{macrocode}
64 %<*kernel>
65 % \end{macrocode}
66 %
67 % \subsection{File declaration}
68 % \begin{macrocode}
69 \ProvidesFile{latex-lab-mathpkg.ltx}
70 [2026-04-25 v0.1d mathpkg adaptions]
71 % \end{macrocode}
72 %
73 % \subsection{breqn}
74 % \begin{macrocode}
75 \AddToHook{package/breqn/after}{
76 \RegisterMathEnvironment{dmath}
77 \RegisterMathEnvironment{dgroup*}
78 \AddToHook{env/dmath/begin}{\tagpdfparaOff}
79 \AddToHook{env/dgroup*/begin}{\tagpdfparaOff}
80 }
81 % \end{macrocode}
82 %
83 % \subsection{cases}
84 % Force loading of \pkg{amsmath} before \pkg{cases}.
85 % \begin{macrocode}
86 \AddToHook{package/cases/before}{\RequirePackage{amsmath}}
87 \AddToHook{package/cases/after}{
88 \RegisterMathEnvironment{subnumcases}
89 }
90 % \end{macrocode}
91 %
92 % \subsection{bm}
93 % Similar to the amsbsy code in latex-lab-amsmath for \cs{pmb} we need to mark up
94 % copies as artifact (with mathml-SE this probably has the same problem as \cs{pmb}):
95 % \changes{v0.1d}{2026-04-25}{Use tagging sockets in pmb patch}
96 % \begin{macrocode}
97 \ExplSyntaxOn
98 \cs_new:Npn\__math_patch_bm_pmb:
99 {
100 \NewTaggingSocket{bm/pmb}{2}
101 \NewTaggingSocketPlug{bm/pmb}{default}
102 {
103 \tag_mc_end:\tag_mc_begin:n{artifact}
104 \tag_mc_reset_box:N##1
105 ##2
106 \tag_mc_end:
107 \tag_mc_begin:n{}
108 }
109 \AssignTaggingSocketPlug{amsbsy/pmb}{default}
110 \def\bm@pmb@@@@##1##2##3{{%
111 \hbox_set:Nn\l_@@_tmpa_box{$\m@th##1##3$}%
112 \dimen@##2\wd\tw@
113 \rlap{\box_use:N\l_@@_tmpa_box}%
114 \UseTaggingSocket{bm/pmb}{\l_@@_tmpa_box}
115 {
116 \kern\dimen@
117 \raise1.5\dimen@\rlap{\box_use:N\l_@@_tmpa_box}%
118 \kern\dimen@
119 \box_use_drop:N\l_@@_tmpa_box
120 }}}
121 }
122 \AddToHook{package/bm/after}
123 { \__math_patch_bm_pmb: }
124 \ExplSyntaxOff
125 % \end{macrocode}
126 % \subsection{amsmath timing}
127 % These packages error or lose their function if loaded before \pkg{amsmath}.
128 % \begin{macrocode}
129 \AddToHook{package/accents/before}{\RequirePackage{amsmath}}
130 \AddToHook{package/cleveref/before}{\RequirePackage{amsmath}}
131 \AddToHook{package/esint/before}{\RequirePackage{amsmath}}
132 \AddToHook{package/grmath/before}{\RequirePackage{amsmath}}
133 \AddToHook{package/mathabx/before}{\RequirePackage{amsmath}}
134 \AddToHook{package/wasysym/before}{\RequirePackage{amsmath}}
135 % \end{macrocode}
136 % \begin{macrocode}
137 %</kernel>
138 % \end{macrocode}
139 %
140 % \Finale
141 %