% \iffalse meta-comment
%
% File: undolabl.dtx
% Version: 2025-01-28 v1.0o
% Info: Overriding labels
%
% Copyright © 2010 - 2025 by
%    H.-Martin Münch <Martin dot Muench at Uni-Bonn dot de>
% Portions of code copyrighted by other people as marked.
%
% The main code of this package was invented by Ulrich Diez
% and first published in the comp.text.tex newsgroup
% at Sun, 20 Apr 2008 16:39:26 +0200, with subject:
% Re: How to undefine/overwrite a label? (see e.g.
% https://groups.google.com/g/comp.text.tex/c/MBiR-EpPceo/m/2pdwkZP-bK8J
% ). While Ulrich Diez neither wanted to create a package himself yet
% nor have one published under his name, he granted the
% publication of his code. Therefore: Thanks!
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any later
% version. This version of this license is in
%    https://www.latex-project.org/lppl/lppl-1-3c.txt
% and the latest version of this license is in
%    https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of
% LaTeX version 2005-12-01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work is H.-Martin Münch.
%
% This work consists of the main source file undolabl.dtx,
% the README, and the derived files
%    undolabl.sty, undolabl.pdf,
%    undolabl.ins, undolabl.drv,
%    undolabl-example.tex, undolabl-example.pdf.
%
% "undolabl" is available on CTAN:
% https://www.ctan.org/pkg/undolabl
%
% Also a TDS.ZIP file is provided that contains all the files
% already sorted in a TDS tree:
% https://mirror.ctan.org/install/macros/latex/contrib/undolabl.tds.zip
%
%<*ignore>
\begingroup
  \catcode123=1 %
  \catcode125=2 %
  \def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
         \ifx\csname processbatchFile\endcsname\relax\else1\fi
         \ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\Msg{*************************************************************}
\Msg{* Installation                                              *}
\Msg{* Package: undolabl 2025-01-28 v1.0o Overriding labels (HMM)*}
\Msg{*************************************************************}

\keepsilent
\askforoverwritefalse

\let\MetaPrefix\relax
\preamble

This is a generated file.

Project: undolabl
Version: 2025-01-28 v1.0o

Copyright (C) 2010 - 2025 by
    H.-Martin Muench <Martin dot Muench at Uni-Bonn dot de>
Portions of code copyrighted by other people as marked.

This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3c of this license or (at your option) any later
version. This version of this license is in
   https://www.latex-project.org/lppl/lppl-1-3c.txt
and the latest version of this license is in
   https://www.latex-project.org/lppl.txt
and version 1.3c or later is part of all distributions of
LaTeX version 2005-12-01 or later.

This work has the LPPL maintenance status "maintained".

The Current Maintainer of this work is H.-Martin Muench.

The main code of this package was invented by
Ulrich Diez (eu_angelion AT web DOT de)
and first published in the comp.text.tex newsgroup
at Sun, 20 Apr 2008 16:39:26 +0200, with subject:
Re: How to undefine/overwrite a label? (see e.g.
https://groups.google.com/g/comp.text.tex/c/MBiR-EpPceo/m/2pdwkZP-bK8J
). While Ulrich Diez neither wanted to create a package himself yet
nor have one published under his name, he granted the
publication of his code. Therefore: Thanks!

This work consists of the main source file undolabl.dtx,
the README, and the derived files
   undolabl.sty, undolabl.pdf,
   undolabl.ins, undolabl.drv,
   undolabl-example.tex, undolabl-example.pdf.

In memoriam
 Claudia Simone Barth + 1996-01-30
 Tommy Muench         + 2014-01-02
 Hans-Klaus Muench    + 2014-08-24

\endpreamble
\let\MetaPrefix\DoubleperCent

\generate{%
  \file{undolabl.ins}{\from{undolabl.dtx}{install}}%
  \file{undolabl.drv}{\from{undolabl.dtx}{driver}}%
  \usedir{tex/latex/undolabl}%
  \file{undolabl.sty}{\from{undolabl.dtx}{package}}%
  \usedir{doc/latex/undolabl}%
  \file{undolabl-example.tex}{\from{undolabl.dtx}{example}}%
}

\catcode32=13\relax% active space
\let =\space%
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
\Msg{*  undolabl.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `undolabl.drv'}
\Msg{* through (pdf)LaTeX, e.g.}
\Msg{*  pdflatex undolabl.drv}
\Msg{*  makeindex -s gind.ist undolabl.idx}
\Msg{*  pdflatex undolabl.drv}
\Msg{*  makeindex -s gind.ist undolabl.idx}
\Msg{*  pdflatex undolabl.drv}
\Msg{*}
\Msg{* At least three runs are necessary e.g. to get the}
\Msg{*  references right!}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}

\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%
% \section{The documentation driver file}
%
% The next bit of code contains the documentation driver file for
% \TeX , i.\,e., the file that will produce the documentation you
% are currently reading. It will be extracted from this file by the
% \texttt{docstrip} programme. That is, run \LaTeX{} on \texttt{docstrip}
% and specify the \texttt{driver} option when \texttt{docstrip}
% asks for options.
%
% \begin{macrocode}
%<*driver>
\NeedsTeXFormat{LaTeX2e}[2024-11-01]
\ProvidesFile{undolabl.drv}%
  [2025-01-28 v1.0o Overriding labels (HMM)]
\documentclass{ltxdoc}[2024/02/08]% v2.1j
\usepackage{holtxdoc}[2019/12/09]%  v0.30
\hypersetup{%
 pdfsubject={Overriding labels (HMM)},%
 pdfkeywords={LaTeX, undolabl, undolabel, undo label, label, override},%
 pdfencoding=auto,%
 pdflang={en},%
 breaklinks=true,%
 linktoc=all,%
 pdfstartview=FitH,%
 pdfpagelayout=OneColumn,%
 bookmarksnumbered=true,%
 bookmarksopen=true,%
 bookmarksopenlevel=3,%
 pdfmenubar=true,%
 pdftoolbar=true,%
 pdfwindowui=true,%
 pdfnewwindow=true%
}
\CodelineIndex
\hyphenation{docu-ment}
\begin{document}
  \DocInput{undolabl.dtx}%
\end{document}
%</driver>
% \end{macrocode}
% \fi
%
% \GetFileInfo{undolabl.drv}
%
% \begingroup
%   \def\x{\#,\$,\^,\_,\~,\ ,\&,\{,\},\%}%
%   \makeatletter
%   \@onelevel@sanitize\x
% \expandafter\endgroup
% \expandafter\DoNotIndex\expandafter{\x}
% \expandafter\DoNotIndex\expandafter{\string\ }
% \begingroup
%   \makeatletter
%     \lccode`9=32\relax
%     \lowercase{%^^A
%       \edef\x{\noexpand\DoNotIndex{\@backslashchar9}}%^^A
%     }%^^A
%   \expandafter\endgroup\x
%
% \DoNotIndex{\@auxout,\@bsphack,\@esphack,\@firstofone,\@gobble,\@ifl@t@r,\@ifundefined,%
% \@namedef,\@secondoftwo,\\,\AddToHook,\begin,\begindocument,\bigskip,%
% \csname,\documentclass,\empty,\end,\endcsname,\endinput,\fmtversion,\g@addto@macro,%
% \holtxdoc,\hypdoc,\hyperref,\if@filesw,\IfFormatAtLeastTF,\IfPackageAtLeastF,%
% \IfPackageLoadedT,\IfPackageLoadedTF,\ifx,\label,\listfiles,\MessageBreak,\nameref,%
% \NeedsTeXFormat,\newcommand,\newline,\newpage,\PackageError,\PackageWarning,%
% \pagenumbering,\pageref,\par,\ProvidesPackage,\ref,\section,\space,\textsf,%
% \usepackage}
%
% \title{The \xpackage{undolabl} package}
% \author{H.-Martin Münch\\\xemail{Martin.Muench at Uni-Bonn.de}}
% \date{2025-01-28 v1.0o}
% \maketitle
%
% \begin{abstract}
%  \noindent This \LaTeX{} package allows to override existing labels,
%  especially automatically generated ones.
% \end{abstract}
%
% \noindent \textbf{WARNING}: Since version 1.0d [2010-07-15] the |\undonewlabel|
% command takes only one argument,\newline
% \texttt{\textbackslash undonewlabel\{<\textit{label name}>\}},\newline
% instead of two,\newline
% \texttt{\textbackslash undonewlabel\{<\textit{label name}>\}\{\textbackslash on@line\}}.\newline
% Packages or documents, which used older versions of the \xpackage{undolabl} package, must be
% updated by removing the second argument of |\undonewlabel|, i.\,e.~the |{\on@line}|.
% \bigskip
%
% \noindent Note: The main code of this package was invented by\newline
% \textbf{ULRICH DIEZ}\newline
% and first published in the \Newsgroup{comp.text.tex} newsgroup at\newline
% \texttt{Sun,~20~Apr~2008~16:39:26~+0200}, with subject:\newline
% \texttt{Re:~How~to~undefine/overwrite~a~label?} (see e.\,g.~%
% \url{https://groups.google.com/g/comp.text.tex/c/MBiR-EpPceo/m/2pdwkZP-bK8J}%
% ).\newline
% While \textbf{ULRICH DIEZ} neither wanted to create a~package himself yet
% nor have one published under his name, he granted the publication of his code.
% Therefore: Thanks!
% I submitted this package to CTAN (after some updates of the documentation,
% mainly layout, typos and such things) and try to maintain it.
% \bigskip
%
% \noindent Disclaimer for web links: The author is not responsible for any contents
% referred to in this work unless having full knowledge of illegal contents.
% If any damage occurs by the use of information presented there,
% only the author of the respective pages might be liable,
% not the one who has referred to those pages.
% \newpage
% \tableofcontents
%
% \section{Introduction\label{sec:Introduction}}
% \indent The package's name \texttt{undolabl} is an eight-letter
% abbreviation for the phrases ``undo'' and ``label''.\bigskip
%
% This package allows to override existing labels,
% especially automatically generated ones.\bigskip
%
% When an instance of the |\label|-macro occurs in the document\linebreak
% (e.\,g.~|\label{FOO}|), then a delayed |\write| (a~write which is
% performed at shipout-time when the page-number is determined) to
% the \xfile{.aux} file is issued and you find in the \xfile{.aux} file
% something like:
% \begin{verbatim}
% \newlabel{FOO}{{eval(\@currentlabel)}{eval(\thepage)}%
%  {eval(\@currentlabelname)}{eval(\@currentHref)}{%
%  eval(\@kernel@reserved@label@data)}}
% \end{verbatim}
% (in one line). During the beginning of the next \LaTeX{}-run,
% the \xfile{.aux} file will be read and |\newlabel{FOO}{...}| is expanded to
% |\@newl@bel r{FOO}{...}|, which in turn gets expanded to something
% like (pseudo code):
% \newpage
% \begin{verbatim}
% IF   (macro \r@FOO is already defined)
% THEN - issue an error-message,
%      - make sure that the multiply-defined-labels-warning occurs
%        in the log-file.
% ELSE \def\r@FOO{...}
% ENDIF
% \end{verbatim}
%
% \begin{description}
%   \item[-] At the beginning of the \LaTeX{}-run, all the |\r@<label>|-macros
%     get defined from reading the \xfile{.aux} file. The |\r@<label>|-macros
%     get used by the referencing-macros (|\ref|, |\pageref|,\ldots{}) during
%     the \LaTeX{}-run.
%   \item[-] During the \LaTeX{}-run, the \xfile{.aux} file gets rewritten.
%   \item[-] At the end of the \LaTeX{}-run, the \xfile{.aux} file (which was
%     rewritten/newly created during the \LaTeX{}-run) is read in order
%     to detect whether references have changed during the current
%     \LaTeX{}-run.
% \end{description}
% But this time |\@newl@bel| is redefined (|\let| equal to |\@testdef|)
% and thus this time\newline
% |\@newl@bel r{FOO}{{...}{...}{...}{...}{...}}|\newline
% expands to something like (pseudo code):
% \begin{verbatim}
%   Compare the (newly written) third argument (that is:
%   {{...}{...}{...}{...}{...}})
%   to the (current/former) definition of \r@FOO.
%   If the two are different, then some page- or section-number
%   related to referencing has changed from the last to the current
%   LaTeX-run, thus in this case issue a message in the log-file:
%   "References may have changed. Rerun LaTeX in order to get
%   cross-references right".
% \end{verbatim}
% So what do you need to do in order to override a label:
% \begin{description}
%   \item[-] First you need to write to the \xfile{.aux} file to silently
%     undefine the associated |\r@<label>|-macro if it is already defined.
%     That is why |\overridelabel| writes in terms of |\protected@write|
%     to the \xfile{.aux} file:
%     \begin{verbatim}
%       \undonewlabel{<label>}
%     \end{verbatim}
%     |\undonewlabel| \textquotedblleft undefines\textquotedblright{} the
%     |\r@<label>|-macro. (How this works will be explained below.)
%   \item[-] Then |\overridelabel| can call |\label{<label>}| again
%     and thus produce another |\newlabel{<label>}|-entry to the
%     \xfile{.aux} file.
% \end{description}
% In the \xfile{.aux} file all this results in a sequence like:
% \begin{verbatim}
%   % from the former \label-call:
%   \newlabel{<label>}{...}
%   |->| \r@<label>-macro gets produced.
%   % from the \overrridelabel-call:
%   % - call to \undonewlabel within \overrridelabel:
%   \undonewlabel{<label>}
%   |->| \r@<label>-macro gets destroyed.
%   % - call to \label within \overrridelabel:
%   \newlabel{<label>}{...}
%   |->| a new \r@<label>-macro but no multiply-label-defined warning
%   gets produced.
% \end{verbatim}
% \pagebreak
%
% There is another issue left:
% \begin{description}
%   \item[-] It was said that \xfile{.aux} file is read at the beginning and
%     at the end of the \LaTeX{}-run for detecting whether references have changed.
%   \item[-] When overriding a |<label>|, there will be several
%     |\newlabel{<label>}|-calls associated to the same label-name in
%     the \xfile{.aux} file.
%   \item[-] At the beginning of the \LaTeX{}-run only the last one counts
%     for defining the associated |\r@<label>|-macro.
%   \item[-] But at the end, when the new \xfile{.aux} file is read,
%     they all count and thus with all these entries but the last one,
%     the above-mentioned |\@testdef|-comparison will yield difference
%     and thus in any case cause a warning-message about references
%     having changed although that might not be a correct statement.
% \end{description}
%
% \textbf{ULRICH DIEZ} decided to catch this up by his |\undolabl@testdef| command.
% The |\undolabl@testdef|-comparison-mechanism gets enhanced via
% \textquotedblleft replacing\textquotedblright . This works as follows:
% When the \xfile{.aux} file is read at the beginning of the \LaTeX{}-run,
% |\@newl@bel| is \underline{not} let equal to |\@testdef|.
% When the \xfile{.aux} file is read at the end of the \LaTeX{}-run,
% |\@newl@bel| \underline{is} let equal to |\@testdef|.
% Thus it is sufficient to write into the beginning of the \xfile{.aux} file
% a direction which leads to \nolinebreak{|\let|ting} |\@newl@bel| equal to
% |\undolabl@testdef| in case its definition equals |\@testdef|. That direction
% is called \nolinebreak{\textquotedblleft |\reset@newl@bel|\textquotedblright .}
% Also, when the \xfile{.aux} file is read at the end of the \LaTeX -run,
% |\undonewlabel|-entries therein should do nothing, thus
% |\undonewlabel| is |\let| equal to |\@gobble|.
%
% \section{Usage}
% Load the package placing
% \begin{quote}
%   |\usepackage{undolabl}|
% \end{quote}
% \noindent in the preamble of your \LaTeXe\ source file.\bigskip
%
% \noindent When an existing label shall be replaced by a new one, say\newline
% |\overridelabel{<label name>}|\newline
% (where |<label name>| is the name of the label to be replaced
% by the new one), instead of just |\label{<label name>}|,
% which would produce a\newline
% |LaTeX Warning: Label `<label name>' multiply defined.|
% \newpage
%
% \section{Example}
%    \begin{macrocode}
%<*example>
\documentclass[british]{article}[2024/06/29]% v1.4n
\usepackage{undolabl}[2025-01-28]% v1.0o
%% There are no options for the undolabl package.
\usepackage[%
 extension=pdf,%
 plainpages=false,%
 pdfpagelabels=true,%
 hyperindex=false,%
 pdflang={en},%
 pdftitle={undolabl package example},%
 pdfauthor={H.-Martin Muench, after Ulrich Diez},%
 pdfsubject={Example for the undolabl package},%
 pdfkeywords={LaTeX, undolabl, undolabel},%
 pdfview=FitH,%
 pdfstartview=FitH,%
 pdfpagelayout=OneColumn,%
 bookmarksopen=true%
]{hyperref}[2024-11-05]% v7.01l; when you want to use nameref
\listfiles
\begin{document}
\pagenumbering{arabic}
\section*{Example for undolabl}
This example demonstrates the use of package\newline
\textsf{undolabl}, v1.0o as of 2025-01-28 (HMM).\newline
For details please see the documentation!
\bigskip

\section{Test}
text \label{testlabel} and text \overridelabel{testlabel}\par
page-reference: \pageref{testlabel}\par%%  -> page 4
sectional-reference: \ref{testlabel}\par%% -> section 4
name-reference: \nameref{testlabel}%%      -> Still another test

\newpage
\section{Another test}
text \overridelabel{testlabel}\par
page-reference: \pageref{testlabel}\par%%  -> page 4
sectional-reference: \ref{testlabel}\par%% -> section 4
name-reference: \nameref{testlabel}%%      -> Still another test

\newpage
\section{Yet another test}
text \overridelabel{testlabel}\par
page-reference: \pageref{testlabel}\par%%  -> page 4
sectional-reference: \ref{testlabel}\par%% -> section 4
name-reference: \nameref{testlabel}%%      -> Still another test

\newpage
\section{Still another test}
text \overridelabel{testlabel}\par
page-reference: \pageref{testlabel}\par%%  -> page 4
sectional-reference: \ref{testlabel}\par%% -> section 4
name-reference: \nameref{testlabel}%%      -> Still another test
\end{document}
%</example>
%    \end{macrocode}
%
% \StopEventually{}
%
% \newpage
% \section{The implementation}
% For a somewhat longer description see section~\ref{sec:Introduction}.\bigskip
%
% We start off by checking that we are loading into \LaTeXe{} and
% announcing the name and version of this package.\bigskip
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[2024-11-01]
\ProvidesPackage{undolabl}[2025-01-28 v1.0o Overriding labels (HMM)]

\@ifl@t@r\fmtversion{2024/11/01}{}{\PackageError{undolabl}{%
  LaTeX format 2024-11-01 or newer needed}{%
  Needed LaTeX format version: 2024-11-01 or newer.\MessageBreak%
  Found\space\space LaTeX format version: \fmtversion.\MessageBreak%
  Please update your TeX distribution!\MessageBreak%
  Loading of undolabl package is aborted.}
  \expandafter\endinput}

%    \end{macrocode}
%    \begin{macro}{\overridelabel}
% \DescribeMacro{\overridelabel}
% In order to override a label, first one needs to write to the
% \xfile{.aux} file to silently undefine the associated |\r@<label>|-macro
% if it is already defined. That is why |\overridelabel| writes in
% terms of |\protected@write| to the \xfile{.aux} file:
% |\undonewlabel{<label>}|,
% \textquotedblleft undefining\textquotedblright{} the |\r@<label>|-macro.
% And a message about this is given.
%
%    \begin{macrocode}
\newcommand\overridelabel[1]{%
\@bsphack%
  \if@filesw%
    \protected@write\@auxout{}{\string\undonewlabel{#1}}%
    \@overriddenmessage s{#1}%
%    \end{macrocode}
%
% \noindent Then |\overridelabel| can call |\label{<label>}| again
% and thus produce another |\newlabel{<label>}|-entry to the
% \xfile{.aux} file.
%
%    \begin{macrocode}
    \label{#1}%
  \fi%
\@esphack%
}

%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\undonewlabel}
% \DescribeMacro{\undonewlabel}
% \vspace{-1.15\baselineskip}
%    \begin{macrocode}
\newcommand\undonewlabel{\@und@newl@bel r}

%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\@und@newl@bel}
% \DescribeMacro{\@und@newl@bel}
% If |\r@<label>| is undefined, give an error message:
%    \begin{macrocode}
\newcommand\@und@newl@bel[2]{%
  \@ifundefined{#1@#2}{%
    \PackageError{undolabl}{Label `#2' shall be overridden ^^J%
      although it does not yet exist}{%
      A label which does not exist cannot be overridden.}%
%    \end{macrocode}
% \noindent otherwise:\newline
% Undefine |\r@label| via letting it equal to |\relax|:
%    \begin{macrocode}
  }{\expandafter\global
    \expandafter\let
    \csname #1@#2\endcsname\relax%
   }%
  }

%    \end{macrocode}
%    \end{macro}
% \newpage
%    \begin{macro}{\@overriddenmessage}
% \DescribeMacro{\@overriddenmessage}
% Command for the notification of overriding a label:
%    \begin{macrocode}
\newcommand\@overriddenmessage[2]{%
  \@ifundefined{#1@#2}{\global\@namedef{#1@#2}{i}}{%
    \expandafter\g@addto@macro\csname #1@#2\endcsname{i}%
    }%
  \PackageNote{undolabl}{Label `#2' overridden}%
  }

%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\undolabl@testdef}
% \DescribeMacro{\undolabl@testdef}
% \vspace{-1.15\baselineskip}
%    \begin{macrocode}
\newcommand\undolabl@testdef[3]{%
  \@ifundefined{s@#2}\@secondoftwo\@firstofone{%
    \expandafter\ifx\csname s@#2\endcsname\empty
      \expandafter\@firstofone
    \else%
    \expandafter\xdef\csname s@#2\endcsname{%
      \expandafter\expandafter
      \expandafter\@gobble
      \csname s@#2\endcsname
      }%
    \expandafter\@gobble
    \fi%
   }{\@testdef{#1}{#2}{#3}%
    }%
  }

%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\reset@newl@bel}
% \DescribeMacro{\reset@newl@bel}
% \vspace{-1.15\baselineskip}
%    \begin{macrocode}
\newcommand\reset@newl@bel{%
  \ifx\@newl@bel\@testdef%
    \let\@newl@bel\undolabl@testdef%
    \let\undonewlabel\@gobble%
  \fi%
  }

%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{AddToHook\{begindocument\}}
% \DescribeMacro{AddToHook\{begindocument\}}
% \vspace{-1.15\baselineskip}\par%
% At |begindocument| it is checked whether writing to files is allowed.
% Some packages (e.\,g.~\xpackage{tikz} and \xpackage{selectp}) sometimes prevent
% the output to the \xfile{aux} file. In that case a warning or an error message
% is issued. This is no problem as long as there is/was another compilation run
% where the labels can/could be processed via the \xfile{aux} file.\bigskip
%
% \noindent If writing is allowed, a |\reset@newl@bel| (see above)
% is written into the \xfile{aux} file.
%
%    \begin{macrocode}
\AddToHook{begindocument}{%
  \if@filesw%
    \immediate\write\@auxout{\string\reset@newl@bel}%
%    \end{macrocode}
%
% \noindent When writing to files is not allowed, nothing can be done.
% But when the labels were already processed via the \xfile{aux} file,
% nothing needs to be done (if enough compilation runs have been done before).
%
%    \begin{macrocode}
  \else%
    \IfPackageLoadedTF{tikz}{\PackageWarningNoLine{undolabl}{%
      The undolabl package was not allowed to write to an\MessageBreak%
      .aux file. This package does not work without access\MessageBreak%
      to an .aux file.\MessageBreak%
      It is OK if the .aux file was already updated\MessageBreak%
      by a previous compiler run\MessageBreak%
      and would not have changed anyway.}%
    }{\PackageError{undolabl}{No writing to auxiliary file allowed}{%
        The undolabl package was not allowed to write to an .aux file.\MessageBreak%
        This package does not work without access to an .aux file.\MessageBreak%
        Press Ctrl+Z to exit.\MessageBreak%
        But it is OK if the .aux file was already updated\MessageBreak%
        by a previous compiler run\MessageBreak%
        and would not have changed anyway.}%
     }%
  \fi%
%    \end{macrocode}
%
% The \textsf{undolabl} and the \textsf{acronym} packages shared some commands
% with the same names and where therefore incompatible. \textsc{Jan Heisswolf}
% (ITIV at KIT) reported this in 2014 (Thanks!). Changing the macros in the
% \textsf{undolabl} package also required changing them in the \textsf{pageslts}
% package and providing a fallback mechanism for the old commands used in
% existing \xfile{.aux} files. When I wanted to implement this in 2015,
% it turned out the \textsf{acronym} package had been updated a week before
% (Thanks!) and fixed the incompatibility. Now what remains to be done
% is just to check that no ancient acronym package is used:
%
%    \begin{macrocode}
  \IfPackageLoadedT{acronym}{\IfPackageAtLeastF{acronym}{2015/03/21}{%
    \PackageError{undolabl}{Incompatible old acronym package detected}{%
      The undolabl package is not compatible with acronym package\MessageBreak%
      older than 2015/03/21 v1.41.\MessageBreak%
      Found version: \csname ver@acronym.sty\endcsname .\MessageBreak%
      Please update your acronym package!%
  }}}}
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \section{Installation}
% \subsection{Downloads}
% Everything is available at \url{https://www.ctan.org}
% but may need additional packages themselves.\bigskip
%
% \DescribeMacro{undolabl.dtx}
% For unpacking the |undolabl.dtx| file and constructing the documentation
% it is required:
% \begin{description}
% \item[-] \TeX{} Format \LaTeXe{} [2024-11-01] (or newer),
%           \url{https://www.CTAN.org}
% \item[-] document class \xpackage{ltxdoc}, 2024/02/08, v2.1j,
%           \url{https://www.ctan.org/pkg/ltxdoc}
% \item[-] package \xpackage{holtxdoc}, 2019/12/09, v0.30,
%           \url{https://www.ctan.org/pkg/holtxdoc}
% \item[-] package \xpackage{hypdoc}, 2023-10-26, v1.19,
%           \url{https://www.ctan.org/pkg/hypdoc}
% \end{description}
%
% \DescribeMacro{undolabl.sty}
% The |undolabl.sty| for \LaTeXe{} (i.\,e.~each document using
% the \xpackage{undolabl} package) requires:
% \begin{description}
% \item[-] \TeX{} Format \LaTeXe{} [2024-11-01] (or newer),
%   \url{https://www.CTAN.org}.
% \end{description}
%
% \DescribeMacro{undolabl-example.tex}
% The |undolabl-example.tex| requires the same files as all
% documents using the \xpackage{undolabl} package and additionally:
% \begin{description}
% \item[-] class \xpackage{article}, 2024/06/29, v1.4n,
%            \url{https://www.ctan.org/pkg/article}
% \item[-] package \xpackage{hyperref}, 2024-11-05, v7.01,
%            \url{https://www.ctan.org/pkg/hyperref},
%            if |\nameref| shall be used (and when the references
%            shall be hyperlinked, of course)
% \item[-] package \xpackage{undolabl}, 2025-01-28, v1.0o,
%            \url{https://www.ctan.org/pkg/undolabl}\newline
%   (Well, it is the example file for this package, and because you are reading
%    the documentation for the \xpackage{undolabl} package, it can be assumed
%    that you already have some version of it -- is it the current one?)
% \end{description}
%
% \DescribeMacro{Münch}
% A hyperlinked list of my (other) packages can be found at\newline
% \url{https://www.ctan.org/author/muench-hm}.
%
% \subsection{Package, unpacking TDS}
% \paragraph{Package.} This package is available at
% \url{https://www.ctan.org/pkg/undolabl}, especially
% the manual (README, undolabl.pdf), the example (source: undolabl-example.tex,
% compiled: undolabl-example.pdf), and the undolabl.dtx.
% There is also an undolabl.tds.zip available:
% \url{https://mirror.ctan.org/install/macros/latex/contrib/undolabl.tds.zip}
% (everything in \xfile{TDS} compliant, compiled format),
% which additionally contains\par
% \begin{tabular}{ll}
% undolabl.ins & The installation file.\\
% undolabl.drv & The driver to generate the documentation.\\
% undolabl.sty & The \xext{sty}le file.\\
% undolabl-example.tex & The example file.
% \end{tabular}
%
% \bigskip
%
% \noindent For required other packages, please see the preceding subsection.
%
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
% \docstrip{} archive. The files are extracted by running the
% \xext{.dtx} through \plainTeX{}:
% \begin{quote}
%   \verb|tex undolabl.dtx|
% \end{quote}
%
% \noindent About generating the documentation see paragraph~\ref{GenDoc} below.\bigskip
%
% \paragraph{TDS.} Now the different files must be moved into
% the different directories in your installation TDS tree
% (also known as \xfile{texmf} tree):
% \begin{quote}
% \def\t{^^A
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
%   undolabl.sty & tex/latex/undolabl/undolabl.sty\\
%   undolabl.pdf & doc/latex/undolabl/undolabl.pdf\\
%   undolabl-example.tex & doc/latex/undolabl/undolabl-example.tex\\
%   undolabl-example.pdf & doc/latex/undolabl/undolabl-example.pdf\\
%   undolabl.dtx & source/latex/undolabl/undolabl.dtx
% \end{tabular}^^A
% }^^A
% \sbox0{\t}^^A
% \ifdim\wd0>\linewidth
%   \begingroup
%     \advance\linewidth by\leftmargin
%     \advance\linewidth by\rightmargin
%   \edef\x{\endgroup
%     \def\noexpand\lw{\the\linewidth}^^A
%   }\x
%   \def\lwbox{^^A
%     \leavevmode
%     \hbox to \linewidth{^^A
%       \kern-\leftmargin\relax
%       \hss
%       \usebox0
%       \hss
%       \kern-\rightmargin\relax
%     }^^A
%   }^^A
%   \ifdim\wd0>\lw
%     \sbox0{\small\t}^^A
%     \ifdim\wd0>\linewidth
%       \ifdim\wd0>\lw
%         \sbox0{\footnotesize\t}^^A
%         \ifdim\wd0>\linewidth
%           \ifdim\wd0>\lw
%             \sbox0{\scriptsize\t}^^A
%             \ifdim\wd0>\linewidth
%               \ifdim\wd0>\lw
%                 \sbox0{\tiny\t}^^A
%                 \ifdim\wd0>\linewidth
%                   \lwbox
%                 \else
%                   \usebox0
%                 \fi
%               \else
%                 \lwbox
%               \fi
%             \else
%               \usebox0
%             \fi
%           \else
%             \lwbox
%           \fi
%         \else
%           \usebox0
%         \fi
%       \else
%         \lwbox
%       \fi
%     \else
%       \usebox0
%     \fi
%   \else
%     \lwbox
%   \fi
% \else
%   \usebox0
% \fi
% \end{quote}
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip{}'s
% \xfile{TDS} installing feature, then some files can already be in the right
% place, see the documentation of \docstrip{}.
%
% \subsection{Refresh file name databases}
%
% If your \TeX~distribution (\TeX\,Live, \mikTeX, \dots) relies on
% file name databases, you must refresh these. For example, \TeX\,Live\ users
% run \verb|texhash| or \verb|mktexlsr|.
%
% \subsection{Some details for the interested}
%
% \paragraph{Unpacking with \LaTeX{}.}
% The \xfile{.dtx} chooses its action depending on the format:
% \begin{description}
% \item[\plainTeX:] Run \docstrip{} and extract the files.
% \item[\LaTeX:] Generate the documentation.
% \end{description}
% If you insist on using \LaTeX{} for \docstrip{} (really,
% \docstrip{} does not need \LaTeX{}), then inform the autodetect routine
% about your intention:
% \begin{quote}
%   \verb|latex \let\install=y\input{undolabl.dtx}|
% \end{quote}
% Do not forget to quote the argument according to the demands
% of your shell.
%
% \paragraph{Generating the documentation.\label{GenDoc}}
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
% the documentation. The process can be configured by a
% configuration file \xfile{ltxdoc.cfg}. For instance, put the following
% line into this file, if you want to have A4 as paper format:
% \begin{quote}
%   \verb|\PassOptionsToClass{a4paper}{article}|
% \end{quote}
%
% \noindent An example follows how to generate the
% documentation with \pdfLaTeX{}:
%
% \begin{quote}
%\begin{verbatim}
%pdflatex undolabl.dtx
%makeindex -s gind.ist undolabl.idx
%pdflatex undolabl.dtx
%makeindex -s gind.ist undolabl.idx
%pdflatex undolabl.dtx
%\end{verbatim}
% \end{quote}
%
% \section{Acknowledgements}
%
% The main code of this package was invented by\newline
% \textbf{ULRICH DIEZ} (\texttt{eu\_angelion@web.de})\newline
% and first published in the \Newsgroup{comp.text.tex} newsgroup at\newline
% \texttt{Sun,~20~Apr~2008~16:39:26~+0200}, with subject:\newline
% \texttt{Re:~How~to~undefine/overwrite~a~label?} (see e.\,g.
% \url{https://groups.google.com/g/comp.text.tex/c/MBiR-EpPceo/m/2pdwkZP-bK8J}
% as well as\newline
% \url{https://groups.google.com/g/comp.text.tex/c/0jzpQsn5dPs/m/Lrb45ByCZtMJ}).\newline
% I (\textsc{H.-Martin Münch}) would like to thank \textbf{ULRICH DIEZ}
% for this as well as for his permission to publish it on CTAN as well as
% for his bug reports.
% I also thank those anonymous people who had published the package somewhere else
% on the internet, where I found it first.
% Further I would like to thank \textsc{Heiko Oberdiek} for providing a~lot~(!) of useful
% packages (from which I also got everything I know about creating a file in \xfile{dtx} format,
% OK, say it: copying).
%
% \phantomsection
% \begin{History}\label{History}
%   \begin{Version}{2008/04/20 v0.3(a)}
%     \item Created by \textbf{ULRICH DIEZ}.
%   \end{Version}
%   \begin{Version}{2010/04/08 v0.3b}
%     \item \xfile{.dtx} updated by \textsc{H.-Martin Münch},
%            submitted to CTAN (no changes in the style code).
%   \end{Version}
%   \begin{Version}{2010/06/01 v1.0(a)}
%     \item \xfile{.dtx} updated: some minor corrections in the documentation,
%            an internal renaming for possible better compatibility with other packages.
%     \item The main code of this package was invented in 2008 by \textbf{ULRICH DIEZ}
%            (\texttt{eu\_angelion@web.de}) and published on the internet.
%            Because \textbf{ULRICH DIEZ} neither wanted to create a package himself yet
%            nor have one published under his name,
%            but granted the publication of his code (Thanks!),
%            I had to change author/maintainer of this package and resubmit it.
%   \end{Version}
%   \begin{Version}{2010/06/03 v1.0b}
%     \item Found an unchanged reference to the package authors/maintainer.
%     \item Example adapted to other examples of mine.
%     \item Updated references to other packages.
%     \item \xfile{TDS} locations updated.
%     \item Several changes in the documentation and the \texttt{README} file.
%   \end{Version}
%   \begin{Version}{2010/06/24 v1.0c}
%     \item \xpackage{holtxdoc} warning in \xfile{drv} updated.
%     \item Corrected the location of the package at CTAN. (\xfile{TDS} of
%             this version was still missing due to a~packaging error.)
%     \item Updated references to other packages: \xpackage{hyperref} and
%             \xpackage{pagesLTS} (which has been renamed to \xpackage{pageslts}
%             and is no longer referenced since v1.0h).
%   \end{Version}
%   \begin{Version}{2010/07/15 v1.0d}
%     \item There was another update by \textbf{ULRICH DIEZ} on
%             \Newsgroup{comp.text.tex} at
%             \texttt{Mon,~21~Apr~2008~23:04:03~+0200}, see e.\,g.\newline
%             \url{https://groups.google.com/g/comp.text.tex/c/MBiR-EpPceo/m/2pdwkZP-bK8J},
%             which now has been included in this package.
%     \item Put more emphasis on \textbf{ULRICH DIEZ} writing the initial code.
%     \item Updated references to other packages and corrected the given location
%             of the \textsf{undolabl.tds.zip} file at \href{https://www.ctan.oeg/}{CTAN.org}.
%   \end{Version}
%   \begin{Version}{2010/07/25 v1.0e}
%     \item Bugs reported by \textbf{ULRICH DIEZ} on \Newsgroup{comp.text.tex} at\newline
%             \texttt{Sat,~17~Jul~2010~12:27:10~+0200},
%             subject \texttt{Re:~CTAN~Update:~undolabl}, see e.\,g.\ %
%             \url{https://groups.google.com/g/comp.text.tex/c/0jzpQsn5dPs/m/Lrb45ByCZtMJ},
%             eradicated.
%     \item |\StopEventually| added and |\CheckSum| value corrected (was~$0$).
%     \item Minor details.
%   \end{Version}
%   \begin{Version}{2010/07/29 v1.0f}
%     \item Corrected diverse urls, updated references to other packages.
%   \end{Version}
%   \begin{Version}{2010/09/12 v1.0g}
%     \item There was a wrong \texttt{\%} behind \texttt{2010/07/29 v1.0f},
%             resulting in the version being displayed as
%             \textquotedblleft \texttt{v1.0fOverriding}\textquotedblright.
%     \item Changed the |\unit| definition (got rid of an old |\rm|).
%     \item A lot of small changes.
%   \end{Version}
%   \begin{Version}{2011/02/01 v1.0h}
%     \item Updated to new version of the \xpackage{hyperref} package.
%     \item Removed |/muench/| from the path at diverse locations.
%     \item Some small changes.
%   \end{Version}
%   \begin{Version}{2011/06/26 v1.0i}
%     \item The \xpackage{holtxdoc} package was fixed (recent: 2011/02/04, v0.21),
%             therefore the warning in \xfile{drv} could be removed.~--
%             Adapted the style of this documentation to new \textsc{Oberdiek}
%             \xfile{dtx} style.
%     \item There is a new version of the used \xpackage{hyperref} package.
%     \item Quite some changes in the \xfile{.dtx}/documentation.
%   \end{Version}
%   \begin{Version}{2011/08/08 v1.0j}
%     \item The \xpackage{pagesLTS} package has been renamed to
%             \xpackage{pageslts}: 2011/08/08,~v1.2a.
%     \item Some minor changes.
%   \end{Version}
%   \begin{Version}{2012/01/01 v1.0k}
%     \item Bugfix: Obsolete installation path given in the documentation, updated.
%     \item Bugfix: A section was broken in the documentation (text had been lost
%             but was recovered now).
%     \item Update of documentation, README, and \xfile{dtx} internals.
%   \end{Version}
%   \begin{Version}{2015/03/29 v1.0l}
%     \item Incompatibility with \textsf{acronym} package fixed --
%             by \textsf{acronym} package, thanks! Check for older versions introduced.
%     \item Introduced a check, whether writing to the \xfile{aux} file is allowed.
%     \item Update of documentation, README, and \xfile{dtx} internals.
%   \end{Version}
%   \begin{Version}{2023-02-14 v1.0m}
%     \item Removed |\unit|.
%     \item Converted to UTF-8.
%     \item Updated to \LaTeX{} format 2022-11-01.
%     \item Documentation updated (there were lots of outdated urls).
%   \end{Version}
%   \begin{Version}{2024-12-05 v1.0n}
%     \item In an edge case, |\reset@newl@bel| was issued too late. Fixed.
%     \item Update of minor details in the code and update of documentation
%           (e.\,g.~regarding of the number of arguments in labels).
%   \end{Version}
%   \begin{Version}{2025-01-28 v1.0o}
%     \item Documentation update.
%   \end{Version}
% \end{History}
% \bigskip
%
% When you find a mistake or have a suggestion for an improvement of this package,
% please send an e-mail to the maintainer, thanks! (Please see BUG REPORTS in the README.)
% \bigskip
%
% \PrintIndex
%
% \Finale
\endinput