Debian Codegraph @

texmf-dist/tex/generic/tex4ht/nameref.4ht

raw
1 % nameref.4ht (2025-03-03-13:56), generated from tex4ht-4ht.tex
2 % Copyright 2005-2009 Eitan M. Gurari
3 % Copyright 2009-2025 TeX Users Group
4 %
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either
7 % version 1.3c of this license or (at your option) any
8 % later version. The latest version of this license is in
9 % https://www.latex-project.org/lppl.txt
10 % and version 1.3c or later is part of all distributions
11 % of LaTeX version 2005/12/01 or later.
12 %
13 % This work has the LPPL maintenance status "maintained".
14 %
15 % The Current Maintainer of this work
16 % is the TeX4ht Project <https://tug.org/tex4ht>.
17 %
18 % If you modify this program, changing the
19 % version identification would be appreciated.
20 \immediate\write-1{version 2025-03-03-13:56}
21
22 \let\NR:Type\relax
23 \let\ltx@label\label
24 \def\prf:label{{\ifx \NR:Title\:UnDef \a:newlabel{\@currentlabelname}\else \NR:Title\fi}%
25 {\ifx \NR:Type\relax \else \NR:Type .1\fi}{}}%
26
27 \append:defI\label{\let\NR:Title\undefined}
28
29 \let\NR:StartSec\:StartSec
30 \let\NR:no@sect\no@sect
31 \def\no@sect#1#2#3#4#5#6[#7]#8{\gdef\NR:Title{\a:newlabel{#7}}%
32 \gdef\NR:Type{#1}%
33 \NR:no@sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]{#8}}
34 \def\:StartSec#1#2#3{%
35 \gdef\NR:Title{\a:newlabel{#3}}%
36 \gdef\NR:Type{#1}%
37 \NR:StartSec{#1}{#2}{#3}%
38 }
39
40 \def\:tempc#1#2#3#4#5#6[#7]#8{%
41 \gdef\NR:Title{\a:newlabel{#7}}%
42 \gdef\NR:Type{#1}%
43 \o:NR@sect:{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]{#8}}
44 \HLet\NR@sect\:tempc
45
46 \def\:tempc#1#2#3#4#5{%
47 \gdef\NR:Title{\a:newlabel\ssect:ttl}%
48 \gdef\NR:Type{#1}%
49 \o:NR@ssect:{#1}{#2}{#3}{#4}{#5}%
50 }
51 \HLet\NR@ssect\:tempc
52
53 \def\:tempc[#1]#2{%
54 \gdef\NR:Title{\a:newlabel{#1}}%
55 \gdef\NR:Type{part}%
56 \o:no@part:[{#1}]{#2}}
57
58 % this definition clashes with asmart and amsproc classes, so we
59 % need to skip if these are active
60 \@ifundefined{[email protected]}{%
61 \@ifundefined{[email protected]}{%
62 \HLet\no@part\:tempc
63 }{}}{}
64
65
66 \def\:tempc#1{%
67 \gdef\NR:Title{\a:newlabel{#1}}%
68 \gdef\NR:Type{part}%
69 \o:no@spart:{#1}}
70 \HLet\no@spart\:tempc
71
72 \def\:tempc[#1]#2{%
73 \gdef\NR:Title{\a:newlabel{#1}}%
74 \gdef\NR:Type{chapter}%
75 \o:NR@chapter:[{#1}]{#2}}
76 \HLet\NR@chapter\:tempc
77
78 \def\:tempc#1{%
79 \gdef\NR:Title{\a:newlabel\sch:ttl}%
80 \o:NR@schapter:{#1}%
81 \gdef\NR:Type{chapter}%
82 }
83 \HLet\NR@schapter\:tempc
84
85 \ifdefined\scr@makechapterhead
86 % fixes for Koma-Script classes
87 % declarations for \NR@chapter don'w work in Koma-Script classes,
88 % so we need to redefine \@chapter and \@schapter
89 \def\:tempa[#1]#2{%
90 \gdef\NR:Title{\a:newlabel{#1}}%
91 \gdef\NR:Type{chapter}%
92 \o:@chapter:[#1]{#2}%
93 }
94 \HLet\@chapter\:tempa
95
96 \def\:tempa#1{%
97 \gdef\NR:Title{\a:newlabel{#1}}%
98 \gdef\NR:Type{chapter}%
99 \o:@schapter:{#1}%
100 }
101 \HLet\@schapter\:tempa
102 % end of fixes for Koma-Script classes
103 \fi
104
105
106 \let\o:NR@@caption\@caption
107 %
108 %
109 % Keith Andrews <[email protected]> reported that \@captype as
110 % \NR:Type threw an undefined control sequence error. I think
111 % \@currenvir is safe, there is nothing special about \@captype.
112 %
113 % use of \index and \label inside caption results in a fatal error
114 % we need to disable them in \NR:Title
115
116 % there can be more problematic commands, so we provide a configuration
117 % that can be used multiple times - the default value fixes known commands
118 % but a user can add more of them
119
120 \def\a:captioncommandsfix{}
121 \NewConfigure{CaptionCommandsFix}[1]{\concat:config\a:captioncommandsfix{#1}}
122 \Configure{CaptionCommandsFix}{
123 \let\index\:gobble%
124 \let\label\:gobble%
125 \let\\\relax% causes issues when \centering is active
126 }
127
128 \long\def\@caption#1[#2]{%
129 \gdef\NR:Type{\@currenvir}%
130 \begingroup%
131 \a:captioncommandsfix
132 \protected@xdef\NR:Title{\a:newlabel{#2}}%
133 \endgroup%
134 \o:NR@@caption{#1}[{#2}]%
135 }
136
137 \let\o:NRorg@opargbegintheorem\@opargbegintheorem
138 \def\@opargbegintheorem#1#2#3{%
139 \gdef\NR:Title{\a:newlabel{#3}}%
140 \gdef\NR:Type{\@currenvir}%
141 \NR@gettitle{#3}%
142 \defineautorefname{\@currenvir}{#1}%
143 \o:NRorg@opargbegintheorem{#1}{#2}{#3}%
144 }%
145
146 \let\o:NRorg@begintheorem\@begintheorem
147 \def\@begintheorem#1#2{%
148 \gdef\NR:Title{\a:newlabel{#1 #2}}%
149 \gdef\NR:Type{\@currenvir}%
150 \defineautorefname{\@currenvir}{#1}%
151 \NR@gettitle{}%
152 \o:NRorg@begintheorem{#1}{#2}%
153 }%
154
155 % I don't know if this was useful for anything
156 % but we cannot use it anymore
157 % \AtBeginDocument{%
158 \@ifpackageloaded{listings}{%
159 \def\:tempc#1{%
160 \gdef\NR:Title{\a:newlabel{listing}}%
161 \gdef\NR:Type{lstlisting}%
162 \o:NROrg@lst@MakeCaption:{#1}%
163 \gdef\@currentlabelname{listing}}
164 \HLet\NROrg@lst@MakeCaption\:tempc
165 }{}%
166 % bug [348]
167 \def\:tempams{%
168 \gdef\NR:Title{\a:newlabel{equation}}%
169 \gdef\NR:Type{equation}%
170 \gdef\@currentlabelname{equation}%
171 }
172
173 % https://tex.stackexchange.com/a/581856/2891
174 \@ifpackageloaded{caption}{
175 \pend:defIII\caption@beginex{%
176 \gdef\NR:Type{\@currenvir}%
177 % handle \label and \index in Caption's package
178 % version of \caption
179 \begingroup%
180 \a:captioncommandsfix
181 \protected@xdef\NR:Title{\a:newlabel{##2}}%
182 \endgroup%
183 }
184 }{}
185
186
187 \@ifpackageloaded{amsmath}{%
188 \Configure{@begin}{align}{\:tempams}
189 \Configure{@begin}{multline}{\:tempams}
190 \Configure{@begin}{equation}{\:tempams}
191 \Configure{@begin}{boxed}{\:tempams}
192 \Configure{@begin}{equations}{\:tempams}
193 \Configure{@begin}{equation}{\:tempams}
194 \Configure{@begin}{gather*}{\:tempams}
195 \Configure{@begin}{gather}{\:tempams}
196 \Configure{@begin}{genfrac}{\:tempams}
197 \Configure{@begin}{measure@}{\:tempams}
198 \Configure{@begin}{multline*}{\:tempams}
199 \Configure{@begin}{multline}{\:tempams}
200 \Configure{@begin}{overset}{\:tempams}
201 \Configure{@begin}{smallmatrix}{\:tempams}
202 \Configure{@begin}{split}{\:tempams}
203 \Configure{@begin}{subarray}{\:tempams}
204 \Configure{@begin}{substack}{\:tempams}
205 \Configure{@begin}{underset}{\:tempams}
206 \Configure{@begin}{xleftarrow}{\:tempams}
207 \Configure{@begin}{xrightarrow}{\:tempams}
208 }{
209 \Configure{@begin}{equation}{\:tempams}
210 }
211
212 \let\T:ref=\::ref
213 \def\::ref{\@ifstar{\protect\T@ref}{\protect\T@ref}}
214 \def\T@ref#1{%
215 \@safe@activestrue%
216 \let\::ref\T:ref%
217 \expandafter\@setref\csname r@#1\endcsname\@firstoffive{#1}%
218 \def\::ref{\@ifstar{\protect\T@ref}{\protect\T@ref}}%
219 \@safe@activesfalse%
220 }
221
222 \gdef\defineautorefname#1#2{%
223 \expandafter\gdef\csname #1autorefname\endcsname{#2}}
224 \defineautorefname{theorem}{Theorem}
225
226 \Configure{newlabel}
227 {\csname cur:th\endcsname \csname :currentlabel\endcsname}
228 {\string\csname\space :autoref\string\endcsname
229 {\NR:Type}#1}
230
231 \ifx \@currentlabelname\:UnDef
232 \let\@currentlabelname\empty
233 \fi
234
235 \pend:defIII\@setref{\edef\RefArg{##3}}
236 \append:defIII\@setref{\let\:autoref\:gobble}
237 \let\:autoref\:gobble
238
239
240 \Hinput{nameref}
241 \endinput
242