0

In the MWE below, you will see that \cref is not working with hyperref. Also, even with the conventional \ref command, hyperref leads to the wrong equation

This is the output

enter image description here

This is where \ref takes us (right under Equation 1, instead of Equation 1 itself)

enter image description here

One solution is mentioned in cleveref hyperlink not working in beamer redefines \cref as follows

\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. 

The solution above works only to reference only one equation. If multiple equations are referenced, hyperlink will always take us to the beginning of the document. This means that \cref with this solution is pretty much the same as \ref

\documentclass[aspectratio=169, xcolor={x11names}]{beamer}

\usecolortheme{seahorse}

\useoutertheme[]{miniframes}
\useinnertheme{inmargin}
\setbeamersize{sidebar width left=1cm, sidebar width right=1cm}
\setbeamersize{text margin left=0.5mm, text margin right=0.5mm}

\usepackage{hyperref}
\hypersetup{citecolor=SlateBlue2, citebordercolor=SlateBlue2, 
linkbordercolor=DodgerBlue3, linkcolor=DodgerBlue3, urlcolor=Blue1, colorlinks=true}

\usepackage{cleveref}

    % Single equations (non-breakable)
    \crefformat{equation}{\mbox{Eq. #2(#1)#3}}
    \crefrangeformat{equation}{\mbox{Eqs. #3(#1)#4 to #5(#2)#6}}
    \crefmultiformat{equation}{\mbox{Eqs. #2(#1)#3}}{ and #2(#1)#3}{, #2(#1)#3}{ and #2(#1)#3}
    \crefrangemultiformat{equation}{\mbox{Eqs. #3(#1)#4 to #5(#2)#6}}{ and #3(#1)#4 to #5(#2)#6}{, #3(#1)#4 to #5(#2)#6}{ and #3(#1)#4 to #5(#2)#6}

\let\chyperref\cref % Save the orginal command under a new name
\renewcommand{\cref}[1]{{\color{blue}\hyperlink{#1}{\chyperref{#1}}}} % Redefine the \cref command and explictely add the hyperlink. 

\begin{document}

\begin{frame}{Title Here}

    \begin{block}

        \begin{align}
            A  &= B
            \label{eq1}
            \\
             &= C
             \label{eq2}
             \\
             &= D
             \label{eq3}
        \end{align}

    \end{block}

\end{frame}


\begin{frame}{Title Here}

    \begin{block}

        \begin{align}
            A  &= B
            \label{eq4}
            \\
             &= C
             \label{eq5}
             \\
             &= D
             \label{eq6}
        \end{align}

    \end{block}

\end{frame}

\begin{frame}{Title Here}

\begin{block}

    \begin{align}
    A  &= B
    \label{eq7}
    \\
    &= C
    \label{eq8}
    \\
    &= D
    \label{eq9}
    \end{align}

\end{block}

\end{frame}

\begin{frame}
    contents in between
\end{frame}


\begin{frame}

    \cref{eq1} 

    \cref{eq1,,eq2}

    \cref{eq1,eq2,eq3} 

    \cref{eq1,eq2,eq3,eq7,eq8,eq9} 

    \cref{eq1,,eq2,,eq3,eq7,eq8,eq9} 

    \cref{eq6,eq7,eq9} 


    Eq. \ref{eq1} 
\end{frame}


\end{document}
  • 2
    Could you please add a screenshot of the output you get to your question? If I compile your code, I get the following in slide 3: eqs. (1) and (2) Eq. 1 Maybe interesting: cleveref hyperlink not working in beamer – leandriis Mar 23 at 8:54
3

No, hyperrefs with cleverref and beamer don't work. You only need to compile a small beamer document with cleverref and then look in the log:

Package cleveref Warning: hyperref package loaded with implicit=false option - 
disabling cleveref's hyperref support. This situation is not supported by cleveref, 
and there's no guarantee anything will work. You're on your own! on input 
line 2370.

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.