summaryrefslogtreecommitdiff
path: root/macros/latex-dev/base/ltcounts.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex-dev/base/ltcounts.dtx')
-rw-r--r--macros/latex-dev/base/ltcounts.dtx21
1 files changed, 17 insertions, 4 deletions
diff --git a/macros/latex-dev/base/ltcounts.dtx b/macros/latex-dev/base/ltcounts.dtx
index 69025fa479..006486d23b 100644
--- a/macros/latex-dev/base/ltcounts.dtx
+++ b/macros/latex-dev/base/ltcounts.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 1993-2023
+% Copyright (C) 1993-2024
% The LaTeX Project and any individual authors listed elsewhere
% in this file.
%
@@ -33,7 +33,7 @@
%<*driver>
% \fi
\ProvidesFile{ltcounts.dtx}
- [2021/07/08 v1.1m LaTeX Kernel (Counters)]
+ [2021/11/08 v1.1n LaTeX Kernel (Counters)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltcounts.dtx}
@@ -305,6 +305,7 @@
% \begin{macro}{\@definecounter}
% \changes{v1.1b}{1995/05/20}{Streamlined code}
% \changes{v1.1c}{1995/05/20}{And do it right}
+% \changes{v1.1n}{2023/11/07}{Do not change \cs{the...} if already defined (gh/823)}
%
% \begin{macrocode}
\def\@definecounter#1{\expandafter\newcount\csname c@#1\endcsname
@@ -312,9 +313,21 @@
\global\expandafter\let\csname cl@#1\endcsname\@empty
\@addtoreset{#1}{@ckpt}%
\global\expandafter\let\csname p@#1\endcsname\@empty
+% \end{macrocode}
+% If \cs{the\#1} is undefined or \cs{relax} we define it with the
+% standard definition for counters, otherwise we warn. This will
+% catch, for example, that somebody defines a counter named
+% ``index'' conflicting with the \env{theindex} environment.
+% \begin{macrocode}
\expandafter
- \gdef\csname the#1\expandafter\endcsname\expandafter
- {\expandafter\@arabic\csname c@#1\endcsname}}
+ \ifx\csname the#1\endcsname\relax
+ \expandafter
+ \gdef\csname the#1\expandafter\endcsname\expandafter
+ {\expandafter\@arabic\csname c@#1\endcsname}%
+ \else
+ \@latex@warning{Command `\string\the#1' already
+ defined -- not changed}%
+ \fi}
% \end{macrocode}
% \end{macro}
%