5

I write some equations in the beamer and I want to point to these equations by using the hyperlink, but the link produced by the command hyperref[label]{text} in package hyperref doesn't point to the right place while the \ref command points to the right place. For example

\documentclass{beamer}
\hypersetup{
    colorlinks,
    linkcolor=red,
}
\begin{document}
    \begin{frame}[c]\frametitle{page 1}
        \begin{equation}\label{eq:1}
            123
        \end{equation}
    \end{frame}

    \begin{frame}[c]\frametitle{page 2}
        \begin{equation}\label{eq:2}
            456
        \end{equation}
    \end{frame}

    \begin{frame}[c]\frametitle{page 3}
    Right link, will point to page 2:\ref{eq:2}\par
    Wrong link, doesn't point to page 2:\hyperref[eq:2]{The equation 2}\par
    \end{frame}
\end{document}

I use xelatex as the compiler and the platform is TL2016 and windows 7.

  • 1
    Apparently beamer does provide link anchors other than 'usual' classes and packages. Replace \hyperref[eq:2]{The equation 2} with \hyperlink{eq:2}{The equation 2} and it will work inside beamer, but it wouldn't work inside a document setup with aother document class. Besides that, there's not much to gain with \hyperref here what could not be done with \ref already – user31729 Apr 13 '17 at 5:05
5

Instead of \hyperref[]{} use \hyperlink{}{} -- \hyperlink is redefined in beamer to use the usual \ref internally, since that command uses links by default (with hyperref) and the link will work,but it would fail in another document set up with another document class since \hyperlink applies the anchor name and not the label name.

Also note that \hyperlink does support the slide overlay <> syntax in beamer as well.

\documentclass{beamer}
\hypersetup{
    colorlinks,
    linkcolor=red,
}
\begin{document}
    \begin{frame}[c]\frametitle{page 1}
        \begin{equation}\label{eq:1}
            123
        \end{equation}
    \end{frame}

    \begin{frame}[c]\frametitle{page 2}
        \begin{equation}\label{eq:2}
            456
        \end{equation}
    \end{frame}

    \begin{frame}[c]\frametitle{page 3}
    Right link, will point to page 2:\ref{eq:2}

    Correct link, does point to page 2:\hyperlink{eq:2}{The equation 2} as well!
    \end{frame}
\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.