1

I am a beginner with amsthm, and I'm using cleveref for referencing the theorem s/definitions/lemmas. BTW, all of this is happening in beamer. On using \Cref{label} for definitions, lemmas, and everything else under the sun - I get something of the form Theorem <number>. Everything isn't a theorem! I want Definition <number> and Lemma <number> too. How can I fix this?

I also get this error:

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.

\documentclass[aspectratio=169,xcolor=dvipsnames]{beamer}
\setbeamercovered{transparent}
\setbeamertemplate{theorems}[numbered] 
\usetheme{CambridgeUS}

\usepackage{amsmath,amssymb,amsthm,amsfonts,amscd} \usepackage{cleveref} \usepackage{tikz} \usepackage{parskip} \usepackage{graphicx} % Allows including images \usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables \usepackage{hyperref}

\theoremstyle{definition} \numberwithin{theorem}{section} \newtheorem{exercise}{Exercise}

\begin{definition}[Program] \label{prog} A program is a set of states in a labeled transition system. \end{definition}

\begin{theorem} Euler is the best mathematician. \end{theorem}

\begin{lemma} \label{xyz} beamer is amazing. \end{lemma}

We just saw \Cref{xyz} and \Cref{prog}.

  • Note that amsthm might not be compatible with beamer as it uses a very different theorem setup. Please also complete your example – daleif Apr 21 '21 at 11:11
  • Completed the example. @daleif How do I get around this, then? – stoic-santiago Apr 21 '21 at 11:16
  • Did you try just googling latex beamer theorem numbering? Here's the first hit: https://tex.stackexchange.com/a/188393/3929, I'm pretty sure it is also mentioned in the beamer manual (not at pc so cannot test) – daleif Apr 21 '21 at 11:41
  • @daleif I have figured something out and edited the question, since now I have a different issue. – stoic-santiago Apr 21 '21 at 12:51

1 Answers1

1

By default, beamer defines the definition to share a counter with the theorem like this:

\newtheorem{definition}[theorem]{\translate{Definition}}

If you want cleveref to distinguish between both environments, you can redefine it without the shared counter:

\documentclass[aspectratio=169,xcolor=dvipsnames]{beamer}
\setbeamercovered{transparent}
\setbeamertemplate{theorems}[numbered] 
\usetheme{CambridgeUS}

\usepackage{cleveref}

\makeatletter \let\definition@undefined \makeatother \newtheorem{definition}{Definition}

\makeatletter \let\lemma@undefined \makeatother \newtheorem{lemma}{Lemma}

\begin{document}

\begin{frame}

\begin{definition}[Program] \label{prog} A program is a set of states in a labeled transition system. \end{definition}

\begin{theorem} Euler is the best mathematician. \end{theorem}

\begin{lemma} \label{xyz} beamer is amazing. \end{lemma}

We just saw \Cref{xyz} and \Cref{prog}.

\end{frame}

\end{document}

enter image description here

  • But, but, ... There's no "Theorem 2", and it's lemma that has \label{xyz}. There's more going wrong here. Also, the code is silent regarding use of amsthm so it's unclear whether it's being used; I'll assume it isn't. – barbara beeton Aug 14 '22 at 14:27
  • @barbarabeeton I just updated the answer to also redefine the lemma. I thought if I showed how to do the definition, the user could use the same technique to do the lemma themselves. Beamer will automatically load amsthm. – samcarter_is_at_topanswers.xyz Aug 14 '22 at 18:39
  • The first comment by @daleif above suggests that beamer and amsthm may be incompatible. Never having tried to use them together, I punted. – barbara beeton Aug 14 '22 at 23:17
  • @barbarabeeton We'd have a very big problem if amsthm wouldn't be compatible with beamer https://github.com/josephwright/beamer/blob/865a19d4ec64f4c8e4935c19e162b8f4fd5aa190/base/beamerbasetheorems.sty#L18 :) – samcarter_is_at_topanswers.xyz Aug 15 '22 at 08:00