13

In my LaTeX documents, I am playing with a lot of axioms which I write under a theorem environment, while using the following math packages:

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

I define the axiom environment in the preamble,

\newtheorem{ax}{Fairness axiom}

then in the text I write,

\begin{ax}[name of the axiom]
\label{label of the axiom}
{definition of the axiom}
\end{ax}

To refer to these axioms, I use \nameref{label of the axiom} through the following packages

\usepackage{hyperref}
\usepackage{nameref}

In the article document class, \nameref{label of the axiom} does exactly what I want: It references the name of the axiom with a hyperlink to its definition.

But in the beamer class, \nameref{label of the axiom} instead references the name of the section in which the axiom is included.

Do you know why? Is there any way to make the beamer class behave like the article class in this matter?

3
13

Class beamer stores the theorem name in \inserttheoremaddition. That needs to be passed at the right time to nameref:

\makeatletter
\addtobeamertemplate{theorem begin}{%
  \expandafter\NR@gettitle\expandafter{\inserttheoremaddition}%
}{}
\makeatother
4
  • Wonderful, adding this code to the preamble makes it work just fine! Many thanks – Martin Van der Linden Oct 27 '12 at 14:28
  • 4
    @user21434 I have also added this to the next versions of nameref (2.43) and zref-titleref (3.0). – Heiko Oberdiek Oct 27 '12 at 15:07
  • @HeikoOberdiek can you see easily whether something similar is needed for \nameref on slide names? I tried this \addtobeamertemplate with frame begin and \insertframetitle with no effect. If you prefer, I can also create an MWE, but if it is a straightforward fix... – Keelan Oct 16 '20 at 10:05
  • On second thought, I figured you'd probably want an MWE, so here: tex.stackexchange.com/q/567052/23992. Your time would be much appreciated! – Keelan Oct 16 '20 at 10:19

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.