4

I am writing a package for lecture's slides and script that should be used by third persons at our department.

I want to use features of the zref package together with beamer, but in a transparent way, i.e. the user should be able to continue to use the \label command. While it is sufficient in the <article> mode to have let\label=\zref@label to get \zref@newlabel instead of \newlabel in the aux file, this has not effect in the <presentation> mode. Redefining \beamer@origlabel does not work either.

Consider the following example:

% \documentclass{beamer}
\documentclass{article}
\usepackage{beamerarticle}
\usepackage[counter,user]{zref}
\makeatletter
\let\label=\zref@label
\makeatother

\newcounter{mycounter}
\begin{document}

\begin{frame}
  \frametitle{foo}
  \refstepcounter{mycounter}
  \label{mylabel}
  mycounter is \themycounter
\end{frame}

\end{document}

Then, one can find in the aux file:

\zref@newlabel{mylabel}{\default{1}\page{1}\counter{mycounter}}

If I comment in the first line but comment out the following both lines, I get only (a.o):

\newlabel{mylabel}{{1}{1}{}{Doc-Start}{}}

What is the best way to enable zref there?

3
  • 1
    Providing a MWE would deliver this question much more transparent ;-)
    – user31729
    Commented Aug 18, 2016 at 10:02
  • 1
    And maybe you could describe why you want to use zref. Commented Aug 18, 2016 at 10:08
  • @ChristianHupfer: I edited the question.
    – Matthias
    Commented Aug 18, 2016 at 10:19

1 Answer 1

4

Some counter and \label - related commands are redefined by packages and/or their action is shifted to the \@begindocumenthook command (\AtBeginDocument) - this must be done for \let\label\zref@label too, otherwise its definition is overruled by other settings.

I've not tested whether this other \label command would have consequences and I don't know how it would cooperate with cleveref as well.

\documentclass{beamer}
%\documentclass{article}
%\usepackage{beamerarticle}
\usepackage[counter,user]{zref}
\makeatletter
\AtBeginDocument{%
\let\label=\zref@label
}
\makeatother

\newcounter{mycounter}
\begin{document}

\begin{frame}
  \frametitle{foo}
  \refstepcounter{mycounter}
  \label{mylabel}
  mycounter is \themycounter
\end{frame}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .