Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add theHcounter represention #1095

Draft
wants to merge 31 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
253b6e4
add support for theHcounter representation
u-fischer Jun 15, 2023
273c35b
remove theH-patches from latex-lab
u-fischer Jun 15, 2023
e654b3d
spurious space
u-fischer Jun 15, 2023
3a3428d
update tests
u-fischer Jun 15, 2023
ab87f32
update testfiles
u-fischer Jun 15, 2023
f235966
more testfiles with labels
u-fischer Jun 16, 2023
f2b0fb1
more testfiles with labels
u-fischer Jun 16, 2023
e9c83ee
add testfile
u-fischer Jun 16, 2023
d45e5f8
address review comments
u-fischer Jun 17, 2023
ad795d3
merge develop
u-fischer Sep 20, 2024
5409b8a
update branch and extend refstepcounter command
u-fischer Sep 20, 2024
eb43df6
missed a number
u-fischer Sep 20, 2024
b2aece4
update test files
u-fischer Sep 20, 2024
0454d17
remove stray text from merge
u-fischer Sep 20, 2024
0a53ae2
more tlg.
u-fischer Sep 20, 2024
ea79163
more tlg, socket changes
u-fischer Sep 20, 2024
137b07b
tools tlg update
u-fischer Sep 20, 2024
9b465c5
switch to tagging socket in refstepcounter.
u-fischer Sep 20, 2024
463b805
remove the kernel@refstepcounter definition, is in the kernel
u-fischer Sep 20, 2024
af45a27
Add target and tagging support to \refstepcounter and \MakeLinkTarget.
u-fischer Sep 21, 2024
faacce2
update changes file.
u-fischer Sep 21, 2024
0bbae18
update rollback tests.
u-fischer Sep 21, 2024
e47a3cd
update tests
u-fischer Sep 21, 2024
182b4a6
correct environment.
u-fischer Sep 21, 2024
2b7c9c1
tools testfiles
u-fischer Sep 21, 2024
eca8d68
enable recordstatus
u-fischer Sep 22, 2024
69cb5f0
test for latex3/tagging-project#414 and latex3/tagging-project#656
u-fischer Sep 22, 2024
abc1104
documentation
u-fischer Sep 22, 2024
0fdc473
use german, english is not installed on github
u-fischer Sep 22, 2024
1519f3b
merge develop
u-fischer Sep 24, 2024
27e48f3
merge develop
u-fischer Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ not part of the distribution.
* lttagging.dtx: dummy for \tag_suspend:n and \tag_resume:n
* lttagging.dtx: declare tagging sockets for floats and caption.


2024-09-21 Ulrike Fischer <[email protected]>

* ltcounts.dtx (subsection{Environment Counter Macros}):
extend \@definecounter and \@addtoreset so that they define also \theH<counter>
* ltxref.dtx (subsection{Cross Referencing}):
Use sockets in \refstepcounter for target and tagging support.
* ltmeta.dtx: move patches and change of \MakeLinkTarget from latex-lab.
* lttagging.dtx: add tagging socket for targets.


2024-09-15 Joseph Wright <[email protected]>

* lttemplates-doc.tex, lttemplates-code.tex:
Expand Down
19 changes: 19 additions & 0 deletions base/doc/ltnews40.tex
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ \section{Switch to T1 as default encoding in documents using \cs{DocumentMetadat
\texttt{OT1} encoding in their document can do so with
\verb+\usepackage[OT1]{fontenc}+.



\section{News from the \enquote{\LaTeX{} Tagged PDF} project}

The tagging of tabulars has been extended: it is now possible to tag
Expand Down Expand Up @@ -295,6 +297,23 @@ \subsection{Improved error raised by empty hook}
%
\githubissue{1423}

\subsection{Provide counter representations for link targets}

To create unique link targets the package
\pkg{hyperref} needs special counter representations
\verb+\theH+\meta{counter}. For this it patches the
commands \verb+\@definecounter+, \verb+\@addtoreset+
and \verb+\refstepcounter+. These counter representations are also
needed for the tagged PDF project and so these patches have now been incorporated
into the kernel. So from now on every \verb+\newcounter{+\meta{counter}\verb+}+ will not
only define \verb+\the+\meta{counter} but also \verb+\theH+\meta{counter}.

\subsection{Extending \cs{refstepcounter}}

The package \pkg{hyperref} redefines since many years \verb+\refstepcounter+ and
adds code that creates link targets. The kernel definition has now been extended
with socket interfaces that will allow \pkg{hyperref} to avoid the redefinitions. The new interfaces are also used by the Tagged PDF code that needs target names to resolve
references between structures.

\section{Bug fixes}

Expand Down
59 changes: 52 additions & 7 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}
[2021/11/08 v1.1n LaTeX Kernel (Counters)]
[2024/09/20 v1.1o LaTeX Kernel (Counters)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltcounts.dtx}
Expand Down Expand Up @@ -171,13 +171,15 @@
%
% |\refstepcounter|\marg{foo}\\
% Same as |\stepcounter|, but it also defines
% |\@currentreference| so that a subsequent
% |\@currentlabel|, |\@currentHref| and |\@currentcounter|
% and so that a subsequent
% |\label|\marg{bar} command causes |\ref|\marg{bar} to
% generate the current value of counter \meta{foo}.
%
% |\@definecounter|\marg{foo}\\
% Initializes counter \marg{foo} (with empty reset list), defines
% |\p@foo| and |\thefoo| to be null. Also adds \meta{foo}
% |\p@foo| and |\thefoo| to be null and |\theHfoo| to be
% |\number\value{foo}|. Also adds \meta{foo}
% to |\cl@@ckpt| --
% the reset list of a dummy counter |@ckpt| used for taking
% checkpoints for the |\include| system.
Expand Down Expand Up @@ -306,19 +308,24 @@
% \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)}
%
% \changes{v1.1o}{2024/09/20}{define theHfoo (used for internal links)}
% \begin{macrocode}
%</2ekernel>
%<latexrelease>\IncludeInRelease{2024/11/01}{\@definecounter}
%<latexrelease> {provide theHfoo commands}%
%<*2ekernel|latexrelease>
\def\@definecounter#1{\expandafter\newcount\csname c@#1\endcsname
\setcounter{#1}\z@
\global\expandafter\let\csname cl@#1\endcsname\@empty
\@addtoreset{#1}{@ckpt}%
\global\expandafter\let\csname p@#1\endcsname\@empty
\expandafter\gdef\csname theH#1\endcsname{\the\value{#1}}%
% \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}
% \begin{macrocode}
\expandafter
\ifx\csname the#1\endcsname\relax
\expandafter
Expand All @@ -328,12 +335,50 @@
\@latex@warning{Command `\string\the#1' already
defined -- not changed}%
\fi}
%<latexrelease>\EndIncludeInRelease
%</2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{0000/00/00}{\@definecounter}
%<latexrelease> {provide theHfoo commands}%%
%<latexrelease>\def\@definecounter#1{\expandafter\newcount\csname c@#1\endcsname
%<latexrelease> \setcounter{#1}\z@
%<latexrelease> \global\expandafter\let\csname cl@#1\endcsname\@empty
%<latexrelease> \@addtoreset{#1}{@ckpt}%
%<latexrelease> \global\expandafter\let\csname p@#1\endcsname\@empty
%<latexrelease> \expandafter
%<latexrelease> \ifx\csname the#1\endcsname\relax
%<latexrelease> \expandafter
%<latexrelease> \gdef\csname the#1\expandafter\endcsname\expandafter
%<latexrelease> {\expandafter\@arabic\csname c@#1\endcsname}%
%<latexrelease> \else
%<latexrelease> \@latex@warning{Command `\string\the#1' already
%<latexrelease> defined -- not changed}%
%<latexrelease> \fi}
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@addtoreset}
% \changes{v1.1o}{2024/09/20}{add the parent theHfoo if a counter is reset}
% If a counter is reset when a parent counter changes it no longer has an unique value
% across the document. As |\theH<counter>| should be unique
% this representation is changed to include also the
% representation of the parent.
% \begin{macrocode}
\def\@addtoreset#1#2{\expandafter\@cons\csname cl@#2\endcsname {{#1}}}
%</2ekernel>
%<latexrelease>\IncludeInRelease{2024/11/01}{\@addtoreset}
%<latexrelease> {provide theHfoo commands}%
%<*2ekernel|latexrelease>
\def\@addtoreset#1#2{\expandafter\@cons\csname cl@#2\endcsname {{#1}}%
\expandafter\gdef\csname theH#1\endcsname{\csname theH#2\endcsname.\the\value{#1}}%
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work as intended in the following cases?
-- Counter A is reset by Counter B and
Counter A is also reset by Counter C ;
-- Counter A is reset by Counter B and
Counter B is reset by Counter D .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact definition of \theHA depends naturally on the order of the @addtoreset calls. It "works" if one get unique \theHA value, which isn't 100% garantied -- users can always find a way to build something odd, -- but it is the definition used by hyperref since many years, so it is compatible with the current behaviour.

}
%<latexrelease>\EndIncludeInRelease
%</2ekernel|latexrelease>
%<latexrelease>\IncludeInRelease{0000/00/00}{\@addtoreset}
%<latexrelease> {provide theHfoo commands}%%
%<latexrelease>\def\@addtoreset#1#2{\expandafter\@cons\csname cl@#2\endcsname {{#1}}}
%<latexrelease>\EndIncludeInRelease
%<*2ekernel>
% \end{macrocode}
% \end{macro}
%
Expand Down Expand Up @@ -423,7 +468,7 @@
}%
}
% \end{macrocode}
%
%
% \begin{macrocode}
\NewDocumentCommand \counterwithin {sO{\arabic}mm}{%
\@ifbothcounters{#3}{#4}{%
Expand Down
34 changes: 31 additions & 3 deletions base/ltmeta.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
%<*driver>
% \fi
\ProvidesFile{ltmeta.dtx}
[2024/05/16 v1.0b LaTeX Kernel (Document Metadata)]
[2024/09/21 v1.0c LaTeX Kernel (Document Metadata)]
% \iffalse
%
\documentclass{l3doc}
Expand Down Expand Up @@ -152,20 +152,48 @@
% we provide also the new interface commands of the hyperref package
% for the creation of targets.
% \changes{v1.0b}{2022/05/17}{Default definition for targets added}
% \changes{v1.0c}{2024/09/21}{Added tagging support}
% \begin{macro}{\MakeLinkTarget}
% \begin{macro}{\LinkTargetOn}
% \begin{macro}{\LinkTargetOff}
% \begin{macro}{\NextLinkTarget}
% \begin{macrocode}
%<latexrelease>\IncludeInRelease{2024/11/01}%
%<latexrelease> {\MakeLinkTarget}{Record target name for tagging support}%
\ExplSyntaxOn
\int_new:N\g__kernel_target_int
\NewDocumentCommand\MakeLinkTarget{sO{}m}{%
\ifvmode
\special{}%
\else
\@savsf\spacefactor
\smash{}%
\spacefactor\@savsf
\fi}
\NewDocumentCommand\LinkTargetOn{}{}
\fi
\IfBooleanTF {#1}
{
\tl_gset:Ne \@currentHref {#3}
}
{
\int_gincr:N\g__kernel_target_int
\tl_gset:Ne \@currentHref {target*.\int_use:N\g__kernel_target_int}
}
\UseTaggingSocket{recordtarget}
}
\ExplSyntaxOff
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{2022/06/01}%
%<latexrelease> {\MakeLinkTarget}{Record target name for tagging support}%
%<latexrelease>\NewDocumentCommand\MakeLinkTarget{sO{}m}{%
%<latexrelease> \ifvmode
%<latexrelease> \special{}%
%<latexrelease> \else
%<latexrelease> \@savsf\spacefactor
%<latexrelease> \smash{}%
%<latexrelease> \spacefactor\@savsf
%<latexrelease> \fi}
%<latexrelease>\EndIncludeInRelease
\NewDocumentCommand\LinkTargetOn{}{}
\NewDocumentCommand\LinkTargetOff{}{}
\NewDocumentCommand\NextLinkTarget{m}{}
% \end{macrocode}
Expand Down
39 changes: 31 additions & 8 deletions base/lttagging.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
%<*driver>
% \fi
\ProvidesFile{lttagging.dtx}
[2024/09/17 v1.0h LaTeX Kernel (tagging support)]
[2024/09/24 v1.0i LaTeX Kernel (tagging support)]
% \iffalse
\documentclass{l3doc}
\GetFileInfo{lttagging.dtx}
Expand Down Expand Up @@ -241,7 +241,6 @@
\int_zero:N \l__tag_block_flattened_level_int
}
\AssignSocketPlug{tagsupport/para/restore}{default}
\ExplSyntaxOff
% \end{macrocode}
% \end{plugdecl}
%
Expand All @@ -252,6 +251,34 @@
% TODO: move this into lttagging.
% \end{socketdecl}

% \subsubsection{Tagging socket for targets}

% \begin{socketdecl}{tagsupport/refstepcounter}
% When tagging is active we want to track the current structure number
% when targets are set. This will be mostly used in \cs{refstepcounter}
% but also if targets are set manually.
% \begin{macrocode}
\NewSocket{tagsupport/recordtarget}{0}
% \end{macrocode}
% \end{socketdecl}
%
% \begin{plugdecl}{kernel (tagsupport/recordtarget)}
% \begin{macrocode}
%
\NewSocketPlug{tagsupport/recordtarget}{kernel}
{
\tl_if_blank:VF \@currentHref
{
\prop_gput:Nee
\g__tag_struct_dest_num_prop
{\@currentHref}
{\tag_get:n{struct_num}}
}
}
\AssignSocketPlug{tagsupport/recordtarget}{kernel}
\ExplSyntaxOff
% \end{macrocode}
% \end{plugdecl}
% \subsubsection{Tagging sockets for toc}

% \begin{socketdecl}{tagsupport/toc/contentsline/before,
Expand Down Expand Up @@ -886,14 +913,10 @@
%<@@=>
% \end{macrocode}
%
% \changes{v1.0h}{2024/09/20}{moved \cs{@kernel@refstepcounter} into ltxref}
% This is needed for \pkg{longtable} because \cs{refstepcounter} is
% setting up a target when \pkg{hyperref} is loaded and we don't
% want that in \pkg{longtable}.
%
% TODO: move to right .dtx file
% \begin{macrocode}
\let\@kernel@refstepcounter\refstepcounter
% \end{macrocode}
% want that in \pkg{longtable}.%%
% Prevent longtable patching by hyperref until hyperref does so automatically:
% \begin{macrocode}
\def\hyper@nopatch@longtable{}
Expand Down
Loading