# \ref* with Beamer

When I use \ref*{xx} in beamer, it gives me an error: "pdfTeX warning (dest): name{*} has been referenced but does not exist." Does beamer fool with it, or what am I missing?

If I run a regular MWE it works great.

\documentclass{article}
\usepackage{hyperref}
\usepackage{lipsum}

\begin{document}
\section{First}
\lipsum[1-3]

\section{Second}
\lipsum[4-5]
Label \label{jh}

\section{Third}
\lipsum[6-9]

Reference: \ref*{jh}
\end{document}


It prints a "2" there, without a hyper-reference.

But in beamer, my mwe gives me the error I mentioned at the start.

\documentclass{beamer}

\begin{document}
\section{test section}
\begin{frame}
Label: \label{jh}
\end{frame}

\begin{frame}
Reference: \ref*{jh}
\end{frame}
\end{document}


A regular \ref (no star) works fine. It prints the reference, and makes it hyper also.

I have downloaded beamer from CTAN today, and I downloaded oberdiek also, because I was getting warnings about the date of some loaded packages, which I have resolved. Beyond that, I have the TeXLive 2009 that comes with Ubuntu 10.04's package manager.

(FWIW, I want \ref* because the references come from another document courtesy of xr.sty.)

-
Right, beamer.clsdoes not provide a \ref* command. You have to define it yourself. –  Daniel Apr 2 '12 at 16:03
@Daniel, that was my first thought as well, but beamer loads hyperref and hyperref defines \ref* so arguably it should work, but then beamer redefines \ref again.... –  David Carlisle Apr 2 '12 at 16:32

Elaborating on David's answer, beamer does modify \ref, just like most other macros and environments. Within beameroverlay.sty, the following is executed:

\AtBeginDocument
{
\let\beamer@origref=\ref
}


removing the starred capability of \ref (since \hyperlink{*}{...} has no meaning). Here's a minimal example that refines \reff which returns the original starred-variant. I'm sure you can also redefine \ref in this way.

\documentclass{beamer}% http://ctan.org/pkg/beamer
\usepackage{xparse}% http://ctan.org/pkg/xparse

\makeatletter
\NewDocumentCommand{\reff}{s m}{%
\IfBooleanTF{#1}% Check for starred variant
{\beamer@origref{#2}}% \reff*
}
\makeatother

\begin{document}
\section{test section}
\begin{frame}
Label: \label{jh}
\end{frame}

\begin{frame}
Reference: \ref{jh}, \reff{jh}, \reff*{jh}
\end{frame}
\end{document}​

-
Thank you, David and Werner. I particularly appreciate the confirmation that it is not something I am doing wrong, or something with my setup. I have reported the problem as a bug on the bitbucket.org beamer archive. –  Jim Hefferon Apr 2 '12 at 16:50
I will have to do this by hand in beamer, as I can't require xparse there :-) –  Joseph Wright Apr 2 '12 at 17:08

beamer and hyperref (as loaded by beamer) appear to get into a tangle each saving an "original" version of \ref and each layering on extra functionality.

This tips things back in the direction of hyperref's definition, I'm not sure how much beamer functionality it loses, but it seems to work on this example,

\documentclass{beamer}

{\def\protect{\global\let\YesIMeanThisRef}\ref}

\AtBeginDocument{\def\ref{\protect\YesIMeanThisRef}}

\begin{document}

\section{test section}
\begin{frame}
Label: \label{jh}
\end{frame}

\begin{frame}
Reference: \ref*{jh}
\end{frame}
\end{document}

-