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

autoref and nameref seem not to work as exspected (i.e work like in article mode) #865

Open
ouboub opened this issue Nov 10, 2023 · 1 comment

Comments

@ouboub
Copy link

ouboub commented Nov 10, 2023

Hi

A while ago in issue 750 I wrote that cleverref and beamer do not work together well, but also found a sort of fix.

Now I am facing the same problem with autoref and nameref. I attach a minimal example and would appreciate any advice

\documentclass{beamer}
\usepackage[spanish]{babel}
\makeatletter
\Hy@AtBeginDocument{%
  \def\@pdfborder{0 0 1}% Overrides border definition set with colorlinks=true
  \def\@pdfborderstyle{/S/U/W 1}% Overrides border style set with colorlinks=true
                                % Hyperlink border style will be underline of width 1pt
}
\makeatother


\hypersetup{%
  colorlinks=true,% hyperlinks will be coloured
%  linkcolor=blue,% hyperlink text will be blue
  urlcolor=blue,% hyperlink text will be blue
%  linkbordercolor=red,% hyperlink border will be red
  urlbordercolor=red,% hyperlink border will be red
}
\usepackage{nameref}
\usepackage{thmtools}
\newtheorem{thm}{Theorem}
\begin{document}
\begin{frame}
  \frametitle{Equations are here}
  this is important
  \begin{equation}
    \label{eq:beamer-auto-nameref:1}
    \int f dx =0
  \end{equation}
\end{frame}
\begin{frame}
  \frametitle{Reference with autoref}
this is   \autoref{eq:beamer-auto-nameref:1}

But using eqref \eqref{eq:beamer-auto-nameref:1}
\end{frame}
\begin{frame}
  \frametitle{Now a theorem}
  \begin{thm}[Riemann's Hypothesis]
\label{thr:beamer-auto-nameref:1}
    Let 
  \end{thm}
\end{frame}


\begin{frame}
  \frametitle{Reference to the theorem}
\ref{thr:beamer-auto-nameref:1}

  Consider \autoref{thr:beamer-auto-nameref:1}

And \nameref{thr:beamer-auto-nameref:1}
\end{frame}
\end{document}

and the pdf file

beamer-auto-nameref.pdf

@ouboub
Copy link
Author

ouboub commented Nov 11, 2023

Hi

I found a solution for the required functionality but it relies on cleveref, any comments are welcome.

regards

Uwe Brauer

 \documentclass{beamer}
 \hypersetup{colorlinks=true}
 \usepackage{nameref}
 \newtheorem{thm}{Theorem}
 \usepackage{cleveref}
 \Crefname{thm}{Theorem}{Theorems}
 % fix for cleverref
 \let\chyperref\cref % Save the orginal command under a new name
 \renewcommand{\cref}[1]{\hyperlink{#1}{\chyperref{#1}}} % Redefine the \cref command and explictely add the hyperlink. 
 %
 \newcommand*{\fullcleveref}[1]{%
   \hyperref[{#1}]{\Cref{#1} (\nameref*{#1})}%
 }
 \newcommand*{\hypercleveref}[1]{%
   \hyperref[{#1}]{\Cref{#1}}%
 }
 
 \begin{document}
 \begin{frame}
   \frametitle{Equations are here}
   this is important
   \begin{equation}
     \label{eq:beamer-auto-nameref:1}
     \int f dx =0
   \end{equation}
 \end{frame}
 
 
 \begin{frame}
   \frametitle{Now a theorem}
   \begin{thm}[Riemann's Hypothesis]
 \label{thr:beamer-auto-nameref:1}
     Let 
   \end{thm}
 \end{frame}
 
 
 \begin{frame}
   \frametitle{Reference to the theorem and the equation}
 
 \hypercleveref{eq:beamer-auto-nameref:1}
 \fullcleveref{thr:beamer-auto-nameref:1}
 \end{frame}
 \end{document}

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

1 participant