beamer icon indicating copy to clipboard operation
beamer copied to clipboard

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

Open cejkiebo opened this issue 3 years ago • 1 comments

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.

cejkiebo avatar Dec 18 '22 22:12 cejkiebo

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}

samcarter avatar Dec 18 '22 22:12 samcarter