Here is my code:
\documentclass{beamer}
\usepackage{amsfonts}
\usepackage{amsmath}
\begin{document}
\frame{\titlepage}
\begin{frame}
\begin{gather}\label{equation1}
a^2 + b^2 = c^2
\end{gather}
Consider \eqref{equation1}. This is fine.
\end{frame}
\begin{frame}
But then:
\begin{gather}\label{equation2}
x^2 + y^2 = z^2\nonumber\\
r + s + t
\end{gather}
\begin{equation}
x = 2
\end{equation}
Equation (2) is referenced as \eqref{equation2}. Why???
\end{frame}
\end{document}
I do not understand why in the last line, \eqref(equation2) shows up as (3) despite clearly being designated as (2). How do I work around this in an efficient manner, particularly since I am going to have to code multiple slides with this sort of thing?
Best Answer
Amsmath environments
align
andgather
are intended to typeset multiple equations, so they require putting one\label{whatever}
per line you want to refer to.What happens if you put
\label{equation2}
at the line which is marked by\nonumber
(so, you don't want to number this equation) is that the label will pick up the previously stepped counter. In this case it's a frame number counter, so your (3) meant the frame number and not the equation number.Moving he label
\label{equation2}
definition to the second equation in thegather
environment helps.