josephwright / beamer

A LaTeX class for producing presentations and slides
Other
1.35k stars 139 forks source link

Using \tag with an earlier equation number and \label does not work #814

Open cejkiebo opened 1 year ago

cejkiebo commented 1 year ago

I'm trying to use Beamer to show a variant of a previously defined equation, yet it throws me weird undescriptive errors (that appear to relate to the frame, not the equation environment). My MWE:

\documentclass{beamer}
\usepackage{amsmath,amsfonts,amssymb}

\begin{document}
\begin{equation}
y = x^2 \label{eq:equation1}
\end{equation}
\begin{equation}
y = x^2+2 \tag{\ref*{eq:equation1}m}\label{eq:equation2}
\end{equation}

Equations \eqref{eq:equation1} and \eqref{eq:equation2}
\end{document}

It does work with the article class (with hyperref added), so it appears to be a bug on Beamer's part. Commenting out the label with the second equation solves the problem, but then I can't refer to my modified equation elsewhere.

samcarter commented 1 year ago

The original definition of \ref is still available as \beamer@origref:

\documentclass{beamer}

\makeatletter
  \long\def\myref#1{%
    \beamer@origref{#1}%
  }
\makeatother

\begin{document}
\begin{frame}
\begin{equation}
y = x^2 \label{eq:equation1}
\end{equation}
\begin{equation}
y = x^2+2 
\tag{\myref{eq:equation1}m}
\label{eq:equation2}
\end{equation}

Equations \eqref{eq:equation1} and \eqref{eq:equation2}
\end{frame}
\end{document}