Debian Codegraph @

texmf-dist/source/latex/undolabl/undolabl.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: undolabl.dtx
4 % Version: 2025-01-28 v1.0o
5 % Info: Overriding labels
6 %
7 % Copyright © 2010 - 2025 by
8 % H.-Martin Münch <Martin dot Muench at Uni-Bonn dot de>
9 % Portions of code copyrighted by other people as marked.
10 %
11 % The main code of this package was invented by Ulrich Diez
12 % and first published in the comp.text.tex newsgroup
13 % at Sun, 20 Apr 2008 16:39:26 +0200, with subject:
14 % Re: How to undefine/overwrite a label? (see e.g.
15 % https://groups.google.com/g/comp.text.tex/c/MBiR-EpPceo/m/2pdwkZP-bK8J
16 % ). While Ulrich Diez neither wanted to create a package himself yet
17 % nor have one published under his name, he granted the
18 % publication of his code. Therefore: Thanks!
19 %
20 % This work may be distributed and/or modified under the
21 % conditions of the LaTeX Project Public License, either
22 % version 1.3c of this license or (at your option) any later
23 % version. This version of this license is in
24 % https://www.latex-project.org/lppl/lppl-1-3c.txt
25 % and the latest version of this license is in
26 % https://www.latex-project.org/lppl.txt
27 % and version 1.3c or later is part of all distributions of
28 % LaTeX version 2005-12-01 or later.
29 %
30 % This work has the LPPL maintenance status "maintained".
31 %
32 % The Current Maintainer of this work is H.-Martin Münch.
33 %
34 % This work consists of the main source file undolabl.dtx,
35 % the README, and the derived files
36 % undolabl.sty, undolabl.pdf,
37 % undolabl.ins, undolabl.drv,
38 % undolabl-example.tex, undolabl-example.pdf.
39 %
40 % "undolabl" is available on CTAN:
41 % https://www.ctan.org/pkg/undolabl
42 %
43 % Also a TDS.ZIP file is provided that contains all the files
44 % already sorted in a TDS tree:
45 % https://mirror.ctan.org/install/macros/latex/contrib/undolabl.tds.zip
46 %
47 %<*ignore>
48 \begingroup
49 \catcode123=1 %
50 \catcode125=2 %
51 \def\x{LaTeX2e}%
52 \expandafter\endgroup
53 \ifcase 0\ifx\install y1\fi\expandafter
54 \ifx\csname processbatchFile\endcsname\relax\else1\fi
55 \ifx\fmtname\x\else 1\fi\relax
56 \else\csname fi\endcsname
57 %</ignore>
58 %<*install>
59 \input docstrip.tex
60 \Msg{*************************************************************}
61 \Msg{* Installation *}
62 \Msg{* Package: undolabl 2025-01-28 v1.0o Overriding labels (HMM)*}
63 \Msg{*************************************************************}
64
65 \keepsilent
66 \askforoverwritefalse
67
68 \let\MetaPrefix\relax
69 \preamble
70
71 This is a generated file.
72
73 Project: undolabl
74 Version: 2025-01-28 v1.0o
75
76 Copyright (C) 2010 - 2025 by
77 H.-Martin Muench <Martin dot Muench at Uni-Bonn dot de>
78 Portions of code copyrighted by other people as marked.
79
80 This work may be distributed and/or modified under the
81 conditions of the LaTeX Project Public License, either
82 version 1.3c of this license or (at your option) any later
83 version. This version of this license is in
84 https://www.latex-project.org/lppl/lppl-1-3c.txt
85 and the latest version of this license is in
86 https://www.latex-project.org/lppl.txt
87 and version 1.3c or later is part of all distributions of
88 LaTeX version 2005-12-01 or later.
89
90 This work has the LPPL maintenance status "maintained".
91
92 The Current Maintainer of this work is H.-Martin Muench.
93
94 The main code of this package was invented by
95 Ulrich Diez (eu_angelion AT web DOT de)
96 and first published in the comp.text.tex newsgroup
97 at Sun, 20 Apr 2008 16:39:26 +0200, with subject:
98 Re: How to undefine/overwrite a label? (see e.g.
99 https://groups.google.com/g/comp.text.tex/c/MBiR-EpPceo/m/2pdwkZP-bK8J
100 ). While Ulrich Diez neither wanted to create a package himself yet
101 nor have one published under his name, he granted the
102 publication of his code. Therefore: Thanks!
103
104 This work consists of the main source file undolabl.dtx,
105 the README, and the derived files
106 undolabl.sty, undolabl.pdf,
107 undolabl.ins, undolabl.drv,
108 undolabl-example.tex, undolabl-example.pdf.
109
110 In memoriam
111 Claudia Simone Barth + 1996-01-30
112 Tommy Muench + 2014-01-02
113 Hans-Klaus Muench + 2014-08-24
114
115 \endpreamble
116 \let\MetaPrefix\DoubleperCent
117
118 \generate{%
119 \file{undolabl.ins}{\from{undolabl.dtx}{install}}%
120 \file{undolabl.drv}{\from{undolabl.dtx}{driver}}%
121 \usedir{tex/latex/undolabl}%
122 \file{undolabl.sty}{\from{undolabl.dtx}{package}}%
123 \usedir{doc/latex/undolabl}%
124 \file{undolabl-example.tex}{\from{undolabl.dtx}{example}}%
125 }
126
127 \catcode32=13\relax% active space
128 \let =\space%
129 \Msg{************************************************************************}
130 \Msg{*}
131 \Msg{* To finish the installation you have to move the following}
132 \Msg{* file into a directory searched by TeX:}
133 \Msg{*}
134 \Msg{* undolabl.sty}
135 \Msg{*}
136 \Msg{* To produce the documentation run the file `undolabl.drv'}
137 \Msg{* through (pdf)LaTeX, e.g.}
138 \Msg{* pdflatex undolabl.drv}
139 \Msg{* makeindex -s gind.ist undolabl.idx}
140 \Msg{* pdflatex undolabl.drv}
141 \Msg{* makeindex -s gind.ist undolabl.idx}
142 \Msg{* pdflatex undolabl.drv}
143 \Msg{*}
144 \Msg{* At least three runs are necessary e.g. to get the}
145 \Msg{* references right!}
146 \Msg{*}
147 \Msg{* Happy TeXing!}
148 \Msg{*}
149 \Msg{************************************************************************}
150
151 \endbatchfile
152 %</install>
153 %<*ignore>
154 \fi
155 %</ignore>
156 %
157 % \section{The documentation driver file}
158 %
159 % The next bit of code contains the documentation driver file for
160 % \TeX , i.\,e., the file that will produce the documentation you
161 % are currently reading. It will be extracted from this file by the
162 % \texttt{docstrip} programme. That is, run \LaTeX{} on \texttt{docstrip}
163 % and specify the \texttt{driver} option when \texttt{docstrip}
164 % asks for options.
165 %
166 % \begin{macrocode}
167 %<*driver>
168 \NeedsTeXFormat{LaTeX2e}[2024-11-01]
169 \ProvidesFile{undolabl.drv}%
170 [2025-01-28 v1.0o Overriding labels (HMM)]
171 \documentclass{ltxdoc}[2024/02/08]% v2.1j
172 \usepackage{holtxdoc}[2019/12/09]% v0.30
173 \hypersetup{%
174 pdfsubject={Overriding labels (HMM)},%
175 pdfkeywords={LaTeX, undolabl, undolabel, undo label, label, override},%
176 pdfencoding=auto,%
177 pdflang={en},%
178 breaklinks=true,%
179 linktoc=all,%
180 pdfstartview=FitH,%
181 pdfpagelayout=OneColumn,%
182 bookmarksnumbered=true,%
183 bookmarksopen=true,%
184 bookmarksopenlevel=3,%
185 pdfmenubar=true,%
186 pdftoolbar=true,%
187 pdfwindowui=true,%
188 pdfnewwindow=true%
189 }
190 \CodelineIndex
191 \hyphenation{docu-ment}
192 \begin{document}
193 \DocInput{undolabl.dtx}%
194 \end{document}
195 %</driver>
196 % \end{macrocode}
197 % \fi
198 %
199 % \GetFileInfo{undolabl.drv}
200 %
201 % \begingroup
202 % \def\x{\#,\$,\^,\_,\~,\ ,\&,\{,\},\%}%
203 % \makeatletter
204 % \@onelevel@sanitize\x
205 % \expandafter\endgroup
206 % \expandafter\DoNotIndex\expandafter{\x}
207 % \expandafter\DoNotIndex\expandafter{\string\ }
208 % \begingroup
209 % \makeatletter
210 % \lccode`9=32\relax
211 % \lowercase{%^^A
212 % \edef\x{\noexpand\DoNotIndex{\@backslashchar9}}%^^A
213 % }%^^A
214 % \expandafter\endgroup\x
215 %
216 % \DoNotIndex{\@auxout,\@bsphack,\@esphack,\@firstofone,\@gobble,\@ifl@t@r,\@ifundefined,%
217 % \@namedef,\@secondoftwo,\\,\AddToHook,\begin,\begindocument,\bigskip,%
218 % \csname,\documentclass,\empty,\end,\endcsname,\endinput,\fmtversion,\g@addto@macro,%
219 % \holtxdoc,\hypdoc,\hyperref,\if@filesw,\IfFormatAtLeastTF,\IfPackageAtLeastF,%
220 % \IfPackageLoadedT,\IfPackageLoadedTF,\ifx,\label,\listfiles,\MessageBreak,\nameref,%
221 % \NeedsTeXFormat,\newcommand,\newline,\newpage,\PackageError,\PackageWarning,%
222 % \pagenumbering,\pageref,\par,\ProvidesPackage,\ref,\section,\space,\textsf,%
223 % \usepackage}
224 %
225 % \title{The \xpackage{undolabl} package}
226 % \author{H.-Martin Münch\\\xemail{Martin.Muench at Uni-Bonn.de}}
227 % \date{2025-01-28 v1.0o}
228 % \maketitle
229 %
230 % \begin{abstract}
231 % \noindent This \LaTeX{} package allows to override existing labels,
232 % especially automatically generated ones.
233 % \end{abstract}
234 %
235 % \noindent \textbf{WARNING}: Since version 1.0d [2010-07-15] the |\undonewlabel|
236 % command takes only one argument,\newline
237 % \texttt{\textbackslash undonewlabel\{<\textit{label name}>\}},\newline
238 % instead of two,\newline
239 % \texttt{\textbackslash undonewlabel\{<\textit{label name}>\}\{\textbackslash on@line\}}.\newline
240 % Packages or documents, which used older versions of the \xpackage{undolabl} package, must be
241 % updated by removing the second argument of |\undonewlabel|, i.\,e.~the |{\on@line}|.
242 % \bigskip
243 %
244 % \noindent Note: The main code of this package was invented by\newline
245 % \textbf{ULRICH DIEZ}\newline
246 % and first published in the \Newsgroup{comp.text.tex} newsgroup at\newline
247 % \texttt{Sun,~20~Apr~2008~16:39:26~+0200}, with subject:\newline
248 % \texttt{Re:~How~to~undefine/overwrite~a~label?} (see e.\,g.~%
249 % \url{https://groups.google.com/g/comp.text.tex/c/MBiR-EpPceo/m/2pdwkZP-bK8J}%
250 % ).\newline
251 % While \textbf{ULRICH DIEZ} neither wanted to create a~package himself yet
252 % nor have one published under his name, he granted the publication of his code.
253 % Therefore: Thanks!
254 % I submitted this package to CTAN (after some updates of the documentation,
255 % mainly layout, typos and such things) and try to maintain it.
256 % \bigskip
257 %
258 % \noindent Disclaimer for web links: The author is not responsible for any contents
259 % referred to in this work unless having full knowledge of illegal contents.
260 % If any damage occurs by the use of information presented there,
261 % only the author of the respective pages might be liable,
262 % not the one who has referred to those pages.
263 % \newpage
264 % \tableofcontents
265 %
266 % \section{Introduction\label{sec:Introduction}}
267 % \indent The package's name \texttt{undolabl} is an eight-letter
268 % abbreviation for the phrases ``undo'' and ``label''.\bigskip
269 %
270 % This package allows to override existing labels,
271 % especially automatically generated ones.\bigskip
272 %
273 % When an instance of the |\label|-macro occurs in the document\linebreak
274 % (e.\,g.~|\label{FOO}|), then a delayed |\write| (a~write which is
275 % performed at shipout-time when the page-number is determined) to
276 % the \xfile{.aux} file is issued and you find in the \xfile{.aux} file
277 % something like:
278 % \begin{verbatim}
279 % \newlabel{FOO}{{eval(\@currentlabel)}{eval(\thepage)}%
280 % {eval(\@currentlabelname)}{eval(\@currentHref)}{%
281 % eval(\@kernel@reserved@label@data)}}
282 % \end{verbatim}
283 % (in one line). During the beginning of the next \LaTeX{}-run,
284 % the \xfile{.aux} file will be read and |\newlabel{FOO}{...}| is expanded to
285 % |\@newl@bel r{FOO}{...}|, which in turn gets expanded to something
286 % like (pseudo code):
287 % \newpage
288 % \begin{verbatim}
289 % IF (macro \r@FOO is already defined)
290 % THEN - issue an error-message,
291 % - make sure that the multiply-defined-labels-warning occurs
292 % in the log-file.
293 % ELSE \def\r@FOO{...}
294 % ENDIF
295 % \end{verbatim}
296 %
297 % \begin{description}
298 % \item[-] At the beginning of the \LaTeX{}-run, all the |\r@<label>|-macros
299 % get defined from reading the \xfile{.aux} file. The |\r@<label>|-macros
300 % get used by the referencing-macros (|\ref|, |\pageref|,\ldots{}) during
301 % the \LaTeX{}-run.
302 % \item[-] During the \LaTeX{}-run, the \xfile{.aux} file gets rewritten.
303 % \item[-] At the end of the \LaTeX{}-run, the \xfile{.aux} file (which was
304 % rewritten/newly created during the \LaTeX{}-run) is read in order
305 % to detect whether references have changed during the current
306 % \LaTeX{}-run.
307 % \end{description}
308 % But this time |\@newl@bel| is redefined (|\let| equal to |\@testdef|)
309 % and thus this time\newline
310 % |\@newl@bel r{FOO}{{...}{...}{...}{...}{...}}|\newline
311 % expands to something like (pseudo code):
312 % \begin{verbatim}
313 % Compare the (newly written) third argument (that is:
314 % {{...}{...}{...}{...}{...}})
315 % to the (current/former) definition of \r@FOO.
316 % If the two are different, then some page- or section-number
317 % related to referencing has changed from the last to the current
318 % LaTeX-run, thus in this case issue a message in the log-file:
319 % "References may have changed. Rerun LaTeX in order to get
320 % cross-references right".
321 % \end{verbatim}
322 % So what do you need to do in order to override a label:
323 % \begin{description}
324 % \item[-] First you need to write to the \xfile{.aux} file to silently
325 % undefine the associated |\r@<label>|-macro if it is already defined.
326 % That is why |\overridelabel| writes in terms of |\protected@write|
327 % to the \xfile{.aux} file:
328 % \begin{verbatim}
329 % \undonewlabel{<label>}
330 % \end{verbatim}
331 % |\undonewlabel| \textquotedblleft undefines\textquotedblright{} the
332 % |\r@<label>|-macro. (How this works will be explained below.)
333 % \item[-] Then |\overridelabel| can call |\label{<label>}| again
334 % and thus produce another |\newlabel{<label>}|-entry to the
335 % \xfile{.aux} file.
336 % \end{description}
337 % In the \xfile{.aux} file all this results in a sequence like:
338 % \begin{verbatim}
339 % % from the former \label-call:
340 % \newlabel{<label>}{...}
341 % |->| \r@<label>-macro gets produced.
342 % % from the \overrridelabel-call:
343 % % - call to \undonewlabel within \overrridelabel:
344 % \undonewlabel{<label>}
345 % |->| \r@<label>-macro gets destroyed.
346 % % - call to \label within \overrridelabel:
347 % \newlabel{<label>}{...}
348 % |->| a new \r@<label>-macro but no multiply-label-defined warning
349 % gets produced.
350 % \end{verbatim}
351 % \pagebreak
352 %
353 % There is another issue left:
354 % \begin{description}
355 % \item[-] It was said that \xfile{.aux} file is read at the beginning and
356 % at the end of the \LaTeX{}-run for detecting whether references have changed.
357 % \item[-] When overriding a |<label>|, there will be several
358 % |\newlabel{<label>}|-calls associated to the same label-name in
359 % the \xfile{.aux} file.
360 % \item[-] At the beginning of the \LaTeX{}-run only the last one counts
361 % for defining the associated |\r@<label>|-macro.
362 % \item[-] But at the end, when the new \xfile{.aux} file is read,
363 % they all count and thus with all these entries but the last one,
364 % the above-mentioned |\@testdef|-comparison will yield difference
365 % and thus in any case cause a warning-message about references
366 % having changed although that might not be a correct statement.
367 % \end{description}
368 %
369 % \textbf{ULRICH DIEZ} decided to catch this up by his |\undolabl@testdef| command.
370 % The |\undolabl@testdef|-comparison-mechanism gets enhanced via
371 % \textquotedblleft replacing\textquotedblright . This works as follows:
372 % When the \xfile{.aux} file is read at the beginning of the \LaTeX{}-run,
373 % |\@newl@bel| is \underline{not} let equal to |\@testdef|.
374 % When the \xfile{.aux} file is read at the end of the \LaTeX{}-run,
375 % |\@newl@bel| \underline{is} let equal to |\@testdef|.
376 % Thus it is sufficient to write into the beginning of the \xfile{.aux} file
377 % a direction which leads to \nolinebreak{|\let|ting} |\@newl@bel| equal to
378 % |\undolabl@testdef| in case its definition equals |\@testdef|. That direction
379 % is called \nolinebreak{\textquotedblleft |\reset@newl@bel|\textquotedblright .}
380 % Also, when the \xfile{.aux} file is read at the end of the \LaTeX -run,
381 % |\undonewlabel|-entries therein should do nothing, thus
382 % |\undonewlabel| is |\let| equal to |\@gobble|.
383 %
384 % \section{Usage}
385 % Load the package placing
386 % \begin{quote}
387 % |\usepackage{undolabl}|
388 % \end{quote}
389 % \noindent in the preamble of your \LaTeXe\ source file.\bigskip
390 %
391 % \noindent When an existing label shall be replaced by a new one, say\newline
392 % |\overridelabel{<label name>}|\newline
393 % (where |<label name>| is the name of the label to be replaced
394 % by the new one), instead of just |\label{<label name>}|,
395 % which would produce a\newline
396 % |LaTeX Warning: Label `<label name>' multiply defined.|
397 % \newpage
398 %
399 % \section{Example}
400 % \begin{macrocode}
401 %<*example>
402 \documentclass[british]{article}[2024/06/29]% v1.4n
403 \usepackage{undolabl}[2025-01-28]% v1.0o
404 %% There are no options for the undolabl package.
405 \usepackage[%
406 extension=pdf,%
407 plainpages=false,%
408 pdfpagelabels=true,%
409 hyperindex=false,%
410 pdflang={en},%
411 pdftitle={undolabl package example},%
412 pdfauthor={H.-Martin Muench, after Ulrich Diez},%
413 pdfsubject={Example for the undolabl package},%
414 pdfkeywords={LaTeX, undolabl, undolabel},%
415 pdfview=FitH,%
416 pdfstartview=FitH,%
417 pdfpagelayout=OneColumn,%
418 bookmarksopen=true%
419 ]{hyperref}[2024-11-05]% v7.01l; when you want to use nameref
420 \listfiles
421 \begin{document}
422 \pagenumbering{arabic}
423 \section*{Example for undolabl}
424 This example demonstrates the use of package\newline
425 \textsf{undolabl}, v1.0o as of 2025-01-28 (HMM).\newline
426 For details please see the documentation!
427 \bigskip
428
429 \section{Test}
430 text \label{testlabel} and text \overridelabel{testlabel}\par
431 page-reference: \pageref{testlabel}\par%% -> page 4
432 sectional-reference: \ref{testlabel}\par%% -> section 4
433 name-reference: \nameref{testlabel}%% -> Still another test
434
435 \newpage
436 \section{Another test}
437 text \overridelabel{testlabel}\par
438 page-reference: \pageref{testlabel}\par%% -> page 4
439 sectional-reference: \ref{testlabel}\par%% -> section 4
440 name-reference: \nameref{testlabel}%% -> Still another test
441
442 \newpage
443 \section{Yet another test}
444 text \overridelabel{testlabel}\par
445 page-reference: \pageref{testlabel}\par%% -> page 4
446 sectional-reference: \ref{testlabel}\par%% -> section 4
447 name-reference: \nameref{testlabel}%% -> Still another test
448
449 \newpage
450 \section{Still another test}
451 text \overridelabel{testlabel}\par
452 page-reference: \pageref{testlabel}\par%% -> page 4
453 sectional-reference: \ref{testlabel}\par%% -> section 4
454 name-reference: \nameref{testlabel}%% -> Still another test
455 \end{document}
456 %</example>
457 % \end{macrocode}
458 %
459 % \StopEventually{}
460 %
461 % \newpage
462 % \section{The implementation}
463 % For a somewhat longer description see section~\ref{sec:Introduction}.\bigskip
464 %
465 % We start off by checking that we are loading into \LaTeXe{} and
466 % announcing the name and version of this package.\bigskip
467 %
468 % \begin{macrocode}
469 %<*package>
470 % \end{macrocode}
471 %
472 % \begin{macrocode}
473 \NeedsTeXFormat{LaTeX2e}[2024-11-01]
474 \ProvidesPackage{undolabl}[2025-01-28 v1.0o Overriding labels (HMM)]
475
476 \@ifl@t@r\fmtversion{2024/11/01}{}{\PackageError{undolabl}{%
477 LaTeX format 2024-11-01 or newer needed}{%
478 Needed LaTeX format version: 2024-11-01 or newer.\MessageBreak%
479 Found\space\space LaTeX format version: \fmtversion.\MessageBreak%
480 Please update your TeX distribution!\MessageBreak%
481 Loading of undolabl package is aborted.}
482 \expandafter\endinput}
483
484 % \end{macrocode}
485 % \begin{macro}{\overridelabel}
486 % \DescribeMacro{\overridelabel}
487 % In order to override a label, first one needs to write to the
488 % \xfile{.aux} file to silently undefine the associated |\r@<label>|-macro
489 % if it is already defined. That is why |\overridelabel| writes in
490 % terms of |\protected@write| to the \xfile{.aux} file:
491 % |\undonewlabel{<label>}|,
492 % \textquotedblleft undefining\textquotedblright{} the |\r@<label>|-macro.
493 % And a message about this is given.
494 %
495 % \begin{macrocode}
496 \newcommand\overridelabel[1]{%
497 \@bsphack%
498 \if@filesw%
499 \protected@write\@auxout{}{\string\undonewlabel{#1}}%
500 \@overriddenmessage s{#1}%
501 % \end{macrocode}
502 %
503 % \noindent Then |\overridelabel| can call |\label{<label>}| again
504 % and thus produce another |\newlabel{<label>}|-entry to the
505 % \xfile{.aux} file.
506 %
507 % \begin{macrocode}
508 \label{#1}%
509 \fi%
510 \@esphack%
511 }
512
513 % \end{macrocode}
514 % \end{macro}
515 % \begin{macro}{\undonewlabel}
516 % \DescribeMacro{\undonewlabel}
517 % \vspace{-1.15\baselineskip}
518 % \begin{macrocode}
519 \newcommand\undonewlabel{\@und@newl@bel r}
520
521 % \end{macrocode}
522 % \end{macro}
523 % \begin{macro}{\@und@newl@bel}
524 % \DescribeMacro{\@und@newl@bel}
525 % If |\r@<label>| is undefined, give an error message:
526 % \begin{macrocode}
527 \newcommand\@und@newl@bel[2]{%
528 \@ifundefined{#1@#2}{%
529 \PackageError{undolabl}{Label `#2' shall be overridden ^^J%
530 although it does not yet exist}{%
531 A label which does not exist cannot be overridden.}%
532 % \end{macrocode}
533 % \noindent otherwise:\newline
534 % Undefine |\r@label| via letting it equal to |\relax|:
535 % \begin{macrocode}
536 }{\expandafter\global
537 \expandafter\let
538 \csname #1@#2\endcsname\relax%
539 }%
540 }
541
542 % \end{macrocode}
543 % \end{macro}
544 % \newpage
545 % \begin{macro}{\@overriddenmessage}
546 % \DescribeMacro{\@overriddenmessage}
547 % Command for the notification of overriding a label:
548 % \begin{macrocode}
549 \newcommand\@overriddenmessage[2]{%
550 \@ifundefined{#1@#2}{\global\@namedef{#1@#2}{i}}{%
551 \expandafter\g@addto@macro\csname #1@#2\endcsname{i}%
552 }%
553 \PackageNote{undolabl}{Label `#2' overridden}%
554 }
555
556 % \end{macrocode}
557 % \end{macro}
558 % \begin{macro}{\undolabl@testdef}
559 % \DescribeMacro{\undolabl@testdef}
560 % \vspace{-1.15\baselineskip}
561 % \begin{macrocode}
562 \newcommand\undolabl@testdef[3]{%
563 \@ifundefined{s@#2}\@secondoftwo\@firstofone{%
564 \expandafter\ifx\csname s@#2\endcsname\empty
565 \expandafter\@firstofone
566 \else%
567 \expandafter\xdef\csname s@#2\endcsname{%
568 \expandafter\expandafter
569 \expandafter\@gobble
570 \csname s@#2\endcsname
571 }%
572 \expandafter\@gobble
573 \fi%
574 }{\@testdef{#1}{#2}{#3}%
575 }%
576 }
577
578 % \end{macrocode}
579 % \end{macro}
580 % \begin{macro}{\reset@newl@bel}
581 % \DescribeMacro{\reset@newl@bel}
582 % \vspace{-1.15\baselineskip}
583 % \begin{macrocode}
584 \newcommand\reset@newl@bel{%
585 \ifx\@newl@bel\@testdef%
586 \let\@newl@bel\undolabl@testdef%
587 \let\undonewlabel\@gobble%
588 \fi%
589 }
590
591 % \end{macrocode}
592 % \end{macro}
593 % \begin{macro}{AddToHook\{begindocument\}}
594 % \DescribeMacro{AddToHook\{begindocument\}}
595 % \vspace{-1.15\baselineskip}\par%
596 % At |begindocument| it is checked whether writing to files is allowed.
597 % Some packages (e.\,g.~\xpackage{tikz} and \xpackage{selectp}) sometimes prevent
598 % the output to the \xfile{aux} file. In that case a warning or an error message
599 % is issued. This is no problem as long as there is/was another compilation run
600 % where the labels can/could be processed via the \xfile{aux} file.\bigskip
601 %
602 % \noindent If writing is allowed, a |\reset@newl@bel| (see above)
603 % is written into the \xfile{aux} file.
604 %
605 % \begin{macrocode}
606 \AddToHook{begindocument}{%
607 \if@filesw%
608 \immediate\write\@auxout{\string\reset@newl@bel}%
609 % \end{macrocode}
610 %
611 % \noindent When writing to files is not allowed, nothing can be done.
612 % But when the labels were already processed via the \xfile{aux} file,
613 % nothing needs to be done (if enough compilation runs have been done before).
614 %
615 % \begin{macrocode}
616 \else%
617 \IfPackageLoadedTF{tikz}{\PackageWarningNoLine{undolabl}{%
618 The undolabl package was not allowed to write to an\MessageBreak%
619 .aux file. This package does not work without access\MessageBreak%
620 to an .aux file.\MessageBreak%
621 It is OK if the .aux file was already updated\MessageBreak%
622 by a previous compiler run\MessageBreak%
623 and would not have changed anyway.}%
624 }{\PackageError{undolabl}{No writing to auxiliary file allowed}{%
625 The undolabl package was not allowed to write to an .aux file.\MessageBreak%
626 This package does not work without access to an .aux file.\MessageBreak%
627 Press Ctrl+Z to exit.\MessageBreak%
628 But it is OK if the .aux file was already updated\MessageBreak%
629 by a previous compiler run\MessageBreak%
630 and would not have changed anyway.}%
631 }%
632 \fi%
633 % \end{macrocode}
634 %
635 % The \textsf{undolabl} and the \textsf{acronym} packages shared some commands
636 % with the same names and where therefore incompatible. \textsc{Jan Heisswolf}
637 % (ITIV at KIT) reported this in 2014 (Thanks!). Changing the macros in the
638 % \textsf{undolabl} package also required changing them in the \textsf{pageslts}
639 % package and providing a fallback mechanism for the old commands used in
640 % existing \xfile{.aux} files. When I wanted to implement this in 2015,
641 % it turned out the \textsf{acronym} package had been updated a week before
642 % (Thanks!) and fixed the incompatibility. Now what remains to be done
643 % is just to check that no ancient acronym package is used:
644 %
645 % \begin{macrocode}
646 \IfPackageLoadedT{acronym}{\IfPackageAtLeastF{acronym}{2015/03/21}{%
647 \PackageError{undolabl}{Incompatible old acronym package detected}{%
648 The undolabl package is not compatible with acronym package\MessageBreak%
649 older than 2015/03/21 v1.41.\MessageBreak%
650 Found version: \csname [email protected]\endcsname .\MessageBreak%
651 Please update your acronym package!%
652 }}}}
653 % \end{macrocode}
654 % \end{macro}
655 % \begin{macrocode}
656 %</package>
657 % \end{macrocode}
658 %
659 % \section{Installation}
660 % \subsection{Downloads}
661 % Everything is available at \url{https://www.ctan.org}
662 % but may need additional packages themselves.\bigskip
663 %
664 % \DescribeMacro{undolabl.dtx}
665 % For unpacking the |undolabl.dtx| file and constructing the documentation
666 % it is required:
667 % \begin{description}
668 % \item[-] \TeX{} Format \LaTeXe{} [2024-11-01] (or newer),
669 % \url{https://www.CTAN.org}
670 % \item[-] document class \xpackage{ltxdoc}, 2024/02/08, v2.1j,
671 % \url{https://www.ctan.org/pkg/ltxdoc}
672 % \item[-] package \xpackage{holtxdoc}, 2019/12/09, v0.30,
673 % \url{https://www.ctan.org/pkg/holtxdoc}
674 % \item[-] package \xpackage{hypdoc}, 2023-10-26, v1.19,
675 % \url{https://www.ctan.org/pkg/hypdoc}
676 % \end{description}
677 %
678 % \DescribeMacro{undolabl.sty}
679 % The |undolabl.sty| for \LaTeXe{} (i.\,e.~each document using
680 % the \xpackage{undolabl} package) requires:
681 % \begin{description}
682 % \item[-] \TeX{} Format \LaTeXe{} [2024-11-01] (or newer),
683 % \url{https://www.CTAN.org}.
684 % \end{description}
685 %
686 % \DescribeMacro{undolabl-example.tex}
687 % The |undolabl-example.tex| requires the same files as all
688 % documents using the \xpackage{undolabl} package and additionally:
689 % \begin{description}
690 % \item[-] class \xpackage{article}, 2024/06/29, v1.4n,
691 % \url{https://www.ctan.org/pkg/article}
692 % \item[-] package \xpackage{hyperref}, 2024-11-05, v7.01,
693 % \url{https://www.ctan.org/pkg/hyperref},
694 % if |\nameref| shall be used (and when the references
695 % shall be hyperlinked, of course)
696 % \item[-] package \xpackage{undolabl}, 2025-01-28, v1.0o,
697 % \url{https://www.ctan.org/pkg/undolabl}\newline
698 % (Well, it is the example file for this package, and because you are reading
699 % the documentation for the \xpackage{undolabl} package, it can be assumed
700 % that you already have some version of it -- is it the current one?)
701 % \end{description}
702 %
703 % \DescribeMacro{Münch}
704 % A hyperlinked list of my (other) packages can be found at\newline
705 % \url{https://www.ctan.org/author/muench-hm}.
706 %
707 % \subsection{Package, unpacking TDS}
708 % \paragraph{Package.} This package is available at
709 % \url{https://www.ctan.org/pkg/undolabl}, especially
710 % the manual (README, undolabl.pdf), the example (source: undolabl-example.tex,
711 % compiled: undolabl-example.pdf), and the undolabl.dtx.
712 % There is also an undolabl.tds.zip available:
713 % \url{https://mirror.ctan.org/install/macros/latex/contrib/undolabl.tds.zip}
714 % (everything in \xfile{TDS} compliant, compiled format),
715 % which additionally contains\par
716 % \begin{tabular}{ll}
717 % undolabl.ins & The installation file.\\
718 % undolabl.drv & The driver to generate the documentation.\\
719 % undolabl.sty & The \xext{sty}le file.\\
720 % undolabl-example.tex & The example file.
721 % \end{tabular}
722 %
723 % \bigskip
724 %
725 % \noindent For required other packages, please see the preceding subsection.
726 %
727 % \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
728 % \docstrip{} archive. The files are extracted by running the
729 % \xext{.dtx} through \plainTeX{}:
730 % \begin{quote}
731 % \verb|tex undolabl.dtx|
732 % \end{quote}
733 %
734 % \noindent About generating the documentation see paragraph~\ref{GenDoc} below.\bigskip
735 %
736 % \paragraph{TDS.} Now the different files must be moved into
737 % the different directories in your installation TDS tree
738 % (also known as \xfile{texmf} tree):
739 % \begin{quote}
740 % \def\t{^^A
741 % \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
742 % undolabl.sty & tex/latex/undolabl/undolabl.sty\\
743 % undolabl.pdf & doc/latex/undolabl/undolabl.pdf\\
744 % undolabl-example.tex & doc/latex/undolabl/undolabl-example.tex\\
745 % undolabl-example.pdf & doc/latex/undolabl/undolabl-example.pdf\\
746 % undolabl.dtx & source/latex/undolabl/undolabl.dtx
747 % \end{tabular}^^A
748 % }^^A
749 % \sbox0{\t}^^A
750 % \ifdim\wd0>\linewidth
751 % \begingroup
752 % \advance\linewidth by\leftmargin
753 % \advance\linewidth by\rightmargin
754 % \edef\x{\endgroup
755 % \def\noexpand\lw{\the\linewidth}^^A
756 % }\x
757 % \def\lwbox{^^A
758 % \leavevmode
759 % \hbox to \linewidth{^^A
760 % \kern-\leftmargin\relax
761 % \hss
762 % \usebox0
763 % \hss
764 % \kern-\rightmargin\relax
765 % }^^A
766 % }^^A
767 % \ifdim\wd0>\lw
768 % \sbox0{\small\t}^^A
769 % \ifdim\wd0>\linewidth
770 % \ifdim\wd0>\lw
771 % \sbox0{\footnotesize\t}^^A
772 % \ifdim\wd0>\linewidth
773 % \ifdim\wd0>\lw
774 % \sbox0{\scriptsize\t}^^A
775 % \ifdim\wd0>\linewidth
776 % \ifdim\wd0>\lw
777 % \sbox0{\tiny\t}^^A
778 % \ifdim\wd0>\linewidth
779 % \lwbox
780 % \else
781 % \usebox0
782 % \fi
783 % \else
784 % \lwbox
785 % \fi
786 % \else
787 % \usebox0
788 % \fi
789 % \else
790 % \lwbox
791 % \fi
792 % \else
793 % \usebox0
794 % \fi
795 % \else
796 % \lwbox
797 % \fi
798 % \else
799 % \usebox0
800 % \fi
801 % \else
802 % \lwbox
803 % \fi
804 % \else
805 % \usebox0
806 % \fi
807 % \end{quote}
808 % If you have a \xfile{docstrip.cfg} that configures and enables \docstrip{}'s
809 % \xfile{TDS} installing feature, then some files can already be in the right
810 % place, see the documentation of \docstrip{}.
811 %
812 % \subsection{Refresh file name databases}
813 %
814 % If your \TeX~distribution (\TeX\,Live, \mikTeX, \dots) relies on
815 % file name databases, you must refresh these. For example, \TeX\,Live\ users
816 % run \verb|texhash| or \verb|mktexlsr|.
817 %
818 % \subsection{Some details for the interested}
819 %
820 % \paragraph{Unpacking with \LaTeX{}.}
821 % The \xfile{.dtx} chooses its action depending on the format:
822 % \begin{description}
823 % \item[\plainTeX:] Run \docstrip{} and extract the files.
824 % \item[\LaTeX:] Generate the documentation.
825 % \end{description}
826 % If you insist on using \LaTeX{} for \docstrip{} (really,
827 % \docstrip{} does not need \LaTeX{}), then inform the autodetect routine
828 % about your intention:
829 % \begin{quote}
830 % \verb|latex \let\install=y\input{undolabl.dtx}|
831 % \end{quote}
832 % Do not forget to quote the argument according to the demands
833 % of your shell.
834 %
835 % \paragraph{Generating the documentation.\label{GenDoc}}
836 % You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
837 % the documentation. The process can be configured by a
838 % configuration file \xfile{ltxdoc.cfg}. For instance, put the following
839 % line into this file, if you want to have A4 as paper format:
840 % \begin{quote}
841 % \verb|\PassOptionsToClass{a4paper}{article}|
842 % \end{quote}
843 %
844 % \noindent An example follows how to generate the
845 % documentation with \pdfLaTeX{}:
846 %
847 % \begin{quote}
848 %\begin{verbatim}
849 %pdflatex undolabl.dtx
850 %makeindex -s gind.ist undolabl.idx
851 %pdflatex undolabl.dtx
852 %makeindex -s gind.ist undolabl.idx
853 %pdflatex undolabl.dtx
854 %\end{verbatim}
855 % \end{quote}
856 %
857 % \section{Acknowledgements}
858 %
859 % The main code of this package was invented by\newline
860 % \textbf{ULRICH DIEZ} (\texttt{eu\[email protected]})\newline
861 % and first published in the \Newsgroup{comp.text.tex} newsgroup at\newline
862 % \texttt{Sun,~20~Apr~2008~16:39:26~+0200}, with subject:\newline
863 % \texttt{Re:~How~to~undefine/overwrite~a~label?} (see e.\,g.
864 % \url{https://groups.google.com/g/comp.text.tex/c/MBiR-EpPceo/m/2pdwkZP-bK8J}
865 % as well as\newline
866 % \url{https://groups.google.com/g/comp.text.tex/c/0jzpQsn5dPs/m/Lrb45ByCZtMJ}).\newline
867 % I (\textsc{H.-Martin Münch}) would like to thank \textbf{ULRICH DIEZ}
868 % for this as well as for his permission to publish it on CTAN as well as
869 % for his bug reports.
870 % I also thank those anonymous people who had published the package somewhere else
871 % on the internet, where I found it first.
872 % Further I would like to thank \textsc{Heiko Oberdiek} for providing a~lot~(!) of useful
873 % packages (from which I also got everything I know about creating a file in \xfile{dtx} format,
874 % OK, say it: copying).
875 %
876 % \phantomsection
877 % \begin{History}\label{History}
878 % \begin{Version}{2008/04/20 v0.3(a)}
879 % \item Created by \textbf{ULRICH DIEZ}.
880 % \end{Version}
881 % \begin{Version}{2010/04/08 v0.3b}
882 % \item \xfile{.dtx} updated by \textsc{H.-Martin Münch},
883 % submitted to CTAN (no changes in the style code).
884 % \end{Version}
885 % \begin{Version}{2010/06/01 v1.0(a)}
886 % \item \xfile{.dtx} updated: some minor corrections in the documentation,
887 % an internal renaming for possible better compatibility with other packages.
888 % \item The main code of this package was invented in 2008 by \textbf{ULRICH DIEZ}
889 % (\texttt{eu\[email protected]}) and published on the internet.
890 % Because \textbf{ULRICH DIEZ} neither wanted to create a package himself yet
891 % nor have one published under his name,
892 % but granted the publication of his code (Thanks!),
893 % I had to change author/maintainer of this package and resubmit it.
894 % \end{Version}
895 % \begin{Version}{2010/06/03 v1.0b}
896 % \item Found an unchanged reference to the package authors/maintainer.
897 % \item Example adapted to other examples of mine.
898 % \item Updated references to other packages.
899 % \item \xfile{TDS} locations updated.
900 % \item Several changes in the documentation and the \texttt{README} file.
901 % \end{Version}
902 % \begin{Version}{2010/06/24 v1.0c}
903 % \item \xpackage{holtxdoc} warning in \xfile{drv} updated.
904 % \item Corrected the location of the package at CTAN. (\xfile{TDS} of
905 % this version was still missing due to a~packaging error.)
906 % \item Updated references to other packages: \xpackage{hyperref} and
907 % \xpackage{pagesLTS} (which has been renamed to \xpackage{pageslts}
908 % and is no longer referenced since v1.0h).
909 % \end{Version}
910 % \begin{Version}{2010/07/15 v1.0d}
911 % \item There was another update by \textbf{ULRICH DIEZ} on
912 % \Newsgroup{comp.text.tex} at
913 % \texttt{Mon,~21~Apr~2008~23:04:03~+0200}, see e.\,g.\newline
914 % \url{https://groups.google.com/g/comp.text.tex/c/MBiR-EpPceo/m/2pdwkZP-bK8J},
915 % which now has been included in this package.
916 % \item Put more emphasis on \textbf{ULRICH DIEZ} writing the initial code.
917 % \item Updated references to other packages and corrected the given location
918 % of the \textsf{undolabl.tds.zip} file at \href{https://www.ctan.oeg/}{CTAN.org}.
919 % \end{Version}
920 % \begin{Version}{2010/07/25 v1.0e}
921 % \item Bugs reported by \textbf{ULRICH DIEZ} on \Newsgroup{comp.text.tex} at\newline
922 % \texttt{Sat,~17~Jul~2010~12:27:10~+0200},
923 % subject \texttt{Re:~CTAN~Update:~undolabl}, see e.\,g.\ %
924 % \url{https://groups.google.com/g/comp.text.tex/c/0jzpQsn5dPs/m/Lrb45ByCZtMJ},
925 % eradicated.
926 % \item |\StopEventually| added and |\CheckSum| value corrected (was~$0$).
927 % \item Minor details.
928 % \end{Version}
929 % \begin{Version}{2010/07/29 v1.0f}
930 % \item Corrected diverse urls, updated references to other packages.
931 % \end{Version}
932 % \begin{Version}{2010/09/12 v1.0g}
933 % \item There was a wrong \texttt{\%} behind \texttt{2010/07/29 v1.0f},
934 % resulting in the version being displayed as
935 % \textquotedblleft \texttt{v1.0fOverriding}\textquotedblright.
936 % \item Changed the |\unit| definition (got rid of an old |\rm|).
937 % \item A lot of small changes.
938 % \end{Version}
939 % \begin{Version}{2011/02/01 v1.0h}
940 % \item Updated to new version of the \xpackage{hyperref} package.
941 % \item Removed |/muench/| from the path at diverse locations.
942 % \item Some small changes.
943 % \end{Version}
944 % \begin{Version}{2011/06/26 v1.0i}
945 % \item The \xpackage{holtxdoc} package was fixed (recent: 2011/02/04, v0.21),
946 % therefore the warning in \xfile{drv} could be removed.~--
947 % Adapted the style of this documentation to new \textsc{Oberdiek}
948 % \xfile{dtx} style.
949 % \item There is a new version of the used \xpackage{hyperref} package.
950 % \item Quite some changes in the \xfile{.dtx}/documentation.
951 % \end{Version}
952 % \begin{Version}{2011/08/08 v1.0j}
953 % \item The \xpackage{pagesLTS} package has been renamed to
954 % \xpackage{pageslts}: 2011/08/08,~v1.2a.
955 % \item Some minor changes.
956 % \end{Version}
957 % \begin{Version}{2012/01/01 v1.0k}
958 % \item Bugfix: Obsolete installation path given in the documentation, updated.
959 % \item Bugfix: A section was broken in the documentation (text had been lost
960 % but was recovered now).
961 % \item Update of documentation, README, and \xfile{dtx} internals.
962 % \end{Version}
963 % \begin{Version}{2015/03/29 v1.0l}
964 % \item Incompatibility with \textsf{acronym} package fixed --
965 % by \textsf{acronym} package, thanks! Check for older versions introduced.
966 % \item Introduced a check, whether writing to the \xfile{aux} file is allowed.
967 % \item Update of documentation, README, and \xfile{dtx} internals.
968 % \end{Version}
969 % \begin{Version}{2023-02-14 v1.0m}
970 % \item Removed |\unit|.
971 % \item Converted to UTF-8.
972 % \item Updated to \LaTeX{} format 2022-11-01.
973 % \item Documentation updated (there were lots of outdated urls).
974 % \end{Version}
975 % \begin{Version}{2024-12-05 v1.0n}
976 % \item In an edge case, |\reset@newl@bel| was issued too late. Fixed.
977 % \item Update of minor details in the code and update of documentation
978 % (e.\,g.~regarding of the number of arguments in labels).
979 % \end{Version}
980 % \begin{Version}{2025-01-28 v1.0o}
981 % \item Documentation update.
982 % \end{Version}
983 % \end{History}
984 % \bigskip
985 %
986 % When you find a mistake or have a suggestion for an improvement of this package,
987 % please send an e-mail to the maintainer, thanks! (Please see BUG REPORTS in the README.)
988 % \bigskip
989 %
990 % \PrintIndex
991 %
992 % \Finale
993 \endinput