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

Add theHcounter represention #1095

wants to merge 31 commits into from

Conversation

u-fischer
Copy link
Member

hyperref and also the tagging code need for links and structure references an additional counter represention \theH<counter>. This moves the relevant hyperref and latex-lab patches of \@definecounter, \@addtoreset and \refstepcounter into the kernel.

Internal housekeeping

Status of pull request

  • Ready to merge

Checklist of required changes before merge will be approved

  • Test file(s) added
  • Version and date string updated in changed source files
  • Relevant \changes entries in source included
  • Relevant changes.txt updated
  • ltnewsX.tex (and/or latexchanges.tex) updated

Copy link
Contributor

@car222222 car222222 left a comment

Choose a reason for hiding this comment

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

See two pending comments:
one being a possible problem with the code.

@@ -144,6 +144,16 @@ \section{Introduction}

\section{New or improved commands}

\subsection{Proving counter representations for link targets}
Copy link
Contributor

Choose a reason for hiding this comment

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

Proving ==> Provide

% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@addtoreset}
% \changes{v1.1n}{2023/06/15}{add the parent theHfoo if a counter is reset}
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs further explanation, both of the details of the code that does this, and of the effects/reasons for doing this.
Thus, maybe some explanation of the details of how the H-* stuff works would be useful?

%<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.

@car222222
Copy link
Contributor

One more comment, but just a typo!

@car222222
Copy link
Contributor

Looking further into this suggests that it is not necessary for any of this to be in the kernel, at least not in this very specialised form. Is this move considered essential? If so, why?

@car222222
Copy link
Contributor

It seems likely that it would be safer to only add a hook here to the kernel version. This enables packages, including the various options in hyperref, to independently add whatever code they need. And it avoids building in particular, and not totally robust, code that is specific to some uses (options) of hyperref.

@u-fischer
Copy link
Member Author

The code is not specific to hyperref. As said above the counter representation is also used for structure references and for this the H-representation is needed also for counters created before hyperref is loaded and also if hyperref is not loaded at all. The latex-lab code contained therefore a copy of the hyperref code, and this PR mainly moves this code from latex-lab into the kernel.

Generally: one goal of the tagging project is to move support for hyperlinks into the kernel. To quote one of the subtasks:

Add the hyperref document interfaces (as appropriate) to the LaTeX kernel and then retire the package itself.

And this requires that hyperref stops to patch kernel commands, both directly and through hooks.

@car222222
Copy link
Contributor

OK, so the ability to adapt is needed more generally, including maybe for applications not yet imagined.

In that case there are even stronger reasons to only add hooks or generic commands to the kernel, rather than very specific, and in some cases suboptimal, chunks of code. Or not?

@car222222
Copy link
Contributor

"To quote one of the subtasks:
Add the hyperref document interfaces (as appropriate) to the LaTeX kernel and then retire the package itself."

For the interfaces this is probably desirable at some stage.
But this does not imply that we should be "building into the kernel a very specific internal method of (on a good day) generating a unique string."

This is one of many ideas in hyperref that is strangely implemented. And in general the internal details should not be built into the kernel. So we need to decide what is a good interface to put into the kernel here, so as to avoid having to add such implememtation details.

Aside: I never signed off on that subtask being included:-).

@u-fischer
Copy link
Member Author

In that case there are even stronger reasons to only add hooks or generic commands to the kernel, rather than very specific, and in some cases suboptimal, chunks of code. Or not?

Sorry I'm loosing you. \@definecounter{blub} defines currently a count \c@blub, and the commands \theblub, \cl@blub, and \p@blub, and with this PR it will also define \theHblub. Why is the last a specific, suboptimal chunk of code? And do you really suggest that I add to the kernel \AddToHooksWithArguments{cmd/@definecounter/after}{\expandafter\gdef\csname theH#1\endcsname{\the\value{#1}} only to get the H-representation defined all the time? Hooks are fine, but they have an overload, why use them if I can do the definition directly?? And do not forget that we need the representation also for counters like enumi and equation which are defined by the kernel.

This is one of many ideas in hyperref that is strangely implemented

What is strange? It is simply another command associated with a counter and not stranger than \p@blub or \theblub.

@github-actions
Copy link

This PR has been automatically marked as stale because it has not had recent activity.

@github-actions github-actions bot added the stale label Aug 19, 2023
@car222222 car222222 mentioned this pull request Nov 8, 2023
6 tasks
@github-actions github-actions bot removed the stale label Mar 19, 2024
Copy link

This PR has been automatically marked as stale because it has not had recent activity.

@github-actions github-actions bot added the stale label May 19, 2024
@josephwright
Copy link
Member

Can you rebase this onto current dev?

@github-actions github-actions bot removed the stale label Jul 26, 2024
@u-fischer u-fischer marked this pull request as draft September 20, 2024 15:12
base/changes.txt Outdated
* usrguide.tex
Correct description of font encodings supported for case changing

>>>>>>> develop
Copy link

Choose a reason for hiding this comment

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

probably remnant from merge conflict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants