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

correct label data #917

Open
u-fischer opened this issue Nov 14, 2024 · 10 comments
Open

correct label data #917

u-fischer opened this issue Nov 14, 2024 · 10 comments

Comments

@u-fischer
Copy link

In beamer anchors are created by the \label command, have the name of the key and \ref{key} references the anchor key.

The data written to the aux-file doesn't reflect that. Beamer always writes Doc-Start as anchor.

\newlabel{blub}{{2}{2}{}{Doc-Start}{}}

This makes it hard for other code to create correct hyperlinks, for example \hyperref doesn't work, but also zref-clever has problems https://tex.stackexchange.com/q/730782/2388 (and the tagging code needs the anchors too)

I suggest to update \@currentHref before issuing the label:

\documentclass{beamer}

\makeatletter
\def\beamer@label<#1>#2%
 {\alt<#1>{\gdef\@currentHref{#2}% <-- new
   \beamer@origlabel{#2}\beamer@nameslide{#2}}{\beamer@dummynameslide}}
\makeatother

\begin{document}

\begin{frame}
First page
\end{frame}


\begin{frame}
\label{blub}
Goal
\end{frame}

\begin{frame}
\hyperref[blub]{jump}
\end{frame}

\end{document}
@samcarter
Copy link
Collaborator

@u-fischer Thanks a lot!

@gusbrs
Copy link

gusbrs commented Nov 14, 2024

Thank you both!

@u-fischer
Copy link
Author

@samcarter It could be that it is needed here too

\def\beamer@label@in@display<#1>#2{\alt<#1>{\beamer@origlabel@in@display{#2}\beamer@nameslide{#2}}{\beamer@dummynameslide}}

but I have no test files to check.

@samcarter
Copy link
Collaborator

@samcarter It could be that it is needed here too

\def\beamer@label@in@display<#1>#2{\alt<#1>{\beamer@origlabel@in@display{#2}\beamer@nameslide{#2}}{\beamer@dummynameslide}}

but I have no test files to check.

With the following, the aux file would contain equation.1. Does this need changing?

\documentclass{beamer}

\begin{document}

\begin{frame}[label=foo]
content...
\end{frame}

\begin{frame}
  \begin{equation}
  x\tag{quack}\label{key}
  \end{equation}
\end{frame}

\begin{frame}
content...
\end{frame}


\begin{frame}
\eqref{key}
\end{frame}


\end{document}

@u-fischer
Copy link
Author

yes. If you use \hyperref[key]{key}, it will complain about the missing destination equation.1

@samcarter
Copy link
Collaborator

@u-fischer added 8ba8b9f

@u-fischer
Copy link
Author

thanks. And thinking about it, it is probably better to expand the key name, so \xdef\@currentHref. For beamer it shouldn't matter, as the label is written directly, but perhaps someone looks later at \@currentHref.

samcarter added a commit to samcarter/beamer that referenced this issue Nov 14, 2024
@samcarter
Copy link
Collaborator

done :)

@u-fischer
Copy link
Author

let's hope that not nobody uses something in the \label key stuff that doesn't like an xdef. But in view that beamer uses it since a long type for destination names one can hope that it is safe. If not one will have to add some protections ...

@gusbrs
Copy link

gusbrs commented Nov 15, 2024

@samcarter Might I add a (related) request here? When you set a label as in:

\begin{frame}[label=foo]
content...
\end{frame}

The \@currentcounter is not set for foo. I presume it would be framenumber. I don't know when, where or how this is stepped. But, could a proper \@currentcounter value be made available for it?

EDIT: With the caveat that my beamer acquaintance is very limited, \refcounter appears to be the place that sets label data for it. So something like?:

\def\refcounter#1{\edef\@currentcounter{#1}%
  \protected@edef\@currentlabel%
  {\csname p@#1\endcsname\csname the#1\endcsname}}%

EDIT 2: I also see a couple of direct settings to \@currentlabel in beamerbaseframecomponents.sty, apparently for footnotes. Corresponding \@currentcounter settings there would also be appropriate, I think.

@samcarter samcarter reopened this Nov 20, 2024
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

No branches or pull requests

3 participants