Skip to content

Commit

Permalink
code for #1632
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcarlisle committed Jan 22, 2025
1 parent c152407 commit 8bd9ffe
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
6 changes: 6 additions & 0 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ to completeness or accuracy and it contains some references to files that are
not part of the distribution.
================================================================================

2025-01-22 David Carlisle <[email protected]>

* ltcounts.dtx, ltxref.dtx:
Allow * to denote the current counter (as used by \label) in counter
related commands, \alph* \stepcounter* etc. gh/1632

2025-01-21 Joseph Wright <[email protected]>

* ltcmd.dtx:
Expand Down
8 changes: 8 additions & 0 deletions base/doc/ltnews41.tex
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@ \subsection{Socket and plug conditionals}
%
\githubissue{1577}

\subsection{Accessing the current counter}
Counter commands such as \cs{alph}, \cs{stepcounter}, may now have
argument \texttt{*} to denote the current counter (as used by
\cs{label}). This is compatible with the \pkg{enumitem} use of
\verb|\alph*| in item labels but is generally available.
%
\githubissue{1632}

\section{Code improvements}

\subsection{Refinement of \cs{MakeTitlecase}}
Expand Down
27 changes: 21 additions & 6 deletions base/ltcounts.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
%<*driver>
% \fi
\ProvidesFile{ltcounts.dtx}
[2024/10/26 v1.1p LaTeX Kernel (Counters)]
[2025/01/22 v1.2a LaTeX Kernel (Counters)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltcounts.dtx}
Expand All @@ -56,14 +56,17 @@
%</driver>
% \fi
%
% \providecommand\env[1]{\texttt{#1}}
%
% \changes{v1.0c}{1994/03/29}
% {Create file from parts of ltmiscen and ltherest.}
% \changes{v1.1a}{1994/05/19}{Extracted file from ltcntlen.}
% \changes{v1.1d}{1996/04/23}{Documentation improvements}
%
% \section{Counters and Lengths}
% Commands for defining and using counters. This file defines:
% Commands for defining and using counters.
% This file definef the following commands. In each case \marg{counter} may be
% |*| denoting the current counter as set by a previous |\refstepcouter|.
%
% \DescribeMacro{\newcounter}
% To define a new counter.
Expand All @@ -72,13 +75,13 @@
% To set the value of counters.
%
% \DescribeMacro{\addtocounter}
% Increase the counter |#1| by the number |#2|.
% Increase the \marg{counter} |#1| by the number |#2|.
%
% \DescribeMacro{\stepcounter}
% Increase a counter by one.
% Increase th \marg{counter} by one.
%
% \DescribeMacro{\refstepcounter}
% Increase a counter by one, also setting the value used by |\label|.
% Increase the \marg{counter} by one, also setting the value used by |\label|.
%
%
% \DescribeMacro{\value}
Expand Down Expand Up @@ -246,7 +249,19 @@
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@newctr}
% \begin{macro}{\c@*}
% \changes{v1.2a}{2025/01/22}{\cs{c@*} added gh/1632}
% Make the current counter available as a \LaTeX\ counter
% with name |*|, so `\alph*` returns the current list
% counter as a letter, |\stepcounter{*}| increments the current
% counter, etc.
% \begin{macrocode}
\protected\expandafter
\def\csname c@*\endcsname{\value\@currentcounter}
% \end{macrocode}
% \end{macro}

%\begin{macro}{\@newctr}
% \changes{v1.0d}{1994/04/09}
% {\cs{@nocnterr} now has counter name argument}
% \changes{v1.0e}{1994/04/17}
Expand Down
5 changes: 3 additions & 2 deletions base/ltxref.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
%<*driver>
% \fi
\ProvidesFile{ltxref.dtx}
[2024/12/10 v1.1s LaTeX Kernel (Cross Referencing)]
[2025/01/22 v1.1t LaTeX Kernel (Cross Referencing)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltxref.dtx}
Expand Down Expand Up @@ -424,6 +424,7 @@
% \changes{v1.1r}{2024/09/20}{set also \@currentHref}
% \changes{v1.1r}{2024/09/20}{provide a kernel copy \@kernel@refstepcounter}
% \changes{v1.1r}{2024/09/20}{add sockets}
% \changes{v1.1t}{2025/01/22}{Guard * from causing infinite loop}
% \begin{macrocode}
%<latexrelease>\IncludeInRelease{2022/06/01}%
%<latexrelease> {\Ref}{Add starred version}%
Expand Down Expand Up @@ -465,7 +466,7 @@
\def\refstepcounter#1{%
\UseSocket{refstepcounter}{%
\stepcounter{#1}%
\edef\@currentcounter{#1}%
\edef\@currentcounter{\ifx*#1\@currentcounter\else#1\fi}%
\protected@edef\@currentlabel
% \end{macrocode}
% By generating the second csname first the |\p@...| command can
Expand Down

0 comments on commit 8bd9ffe

Please sign in to comment.