3

While putting together a presentation about LaTeX i noticed that \hyperref won't recognize any label while \ref works fine. First i thought that there was a error while importing my setup file but i managed to recreate the problem in a MWE.

\documentclass{beamer} 
    \usepackage{hyperref}
    \usepackage{cmbright}
    \usepackage{cleveref}

\begin{document}
\begin{frame}{Some Fancy Title}
\section{Some fancy section}\label{sec:section}
This is some fancy text. It would be nice to reference \hyperref[sec:section]{to it}. But hyperref jumps to the start of the document, while ref works fine. \ref{sec:section}     
\end{frame}
\end{document}

Some additional information: I am using ShareLaTeX Community Edition (not sure which version) I hope its not just a typo but after searching for over 2 hours it might be possible to overlook the obvious. :D

1
  • Welcome to TeX.SE. If you switch from the beamer class to, say, the article class, the issue you describe vanishes automatically. – Mico May 9 '17 at 21:21
4

Please do not use \section inside of a frame!

Also you don't need \usepackage{hyperref} with beamer.

You could use \hyperlink{sec:section}{to it} instead -- or if you want to go to the start of the current section, let beamer do it's job and use \hyperlinksectionstart{to it}

\documentclass{beamer} 
\usepackage{cmbright}
\usepackage{cleveref}

\begin{document}

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

\section{Some fancy section}
\label{sec:section}

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

\begin{frame}{Some Fancy Title}
This is some fancy text. It would be nice to reference \hyperlink{sec:section}{to it}. But hyperref jumps to the start of the document, while ref works fine. \ref{sec:section}   

\hyperlinksectionstart{to it}

  
\end{frame}
\end{document}
3
  • Thank you, this works. Normally i don't use sections in the frame environment, i just put some example file together. If possible does anyone know why hyperref won't work or am i just to stupid to use it? – user133314 May 9 '17 at 21:23
  • @user133314 not really an explanation, but for beamer \hyperlink is the standard tool, it uses it to define many new commands. – samcarter_is_at_topanswers.xyz May 9 '17 at 21:38
  • @user133314 hypertext is a very "intrusive" package - it redefines many macros that are defined in other packages, and often it needs to know which other package originally defined the macro to redefine it successfully. As such, trying to use it in 'non-standard' ways is usually a high risk option. Since beamer has implemented some of hypertext's functionality already, it's a good bet they are going to fight with each other! – alephzero May 10 '17 at 2:12

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.