I use the exam
class for exams. When I use equations in the solution
environment, the counter for equation numbering is updated, even when the solutions are not printed. Is it possible not to consider the counter inside the solution environment when solutions are not printed?
Below is a MWE. It produces a wrong equation numbering. The numbering is correct for the case in which the solutions are printed.
%\documentclass[11pt,answers]{exam}
\documentclass[11pt]{exam}
\usepackage{parskip}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{hyperref}
\begin{document}
\centerline{\bf Exam Class: Numbering Equations, MWE}
\begin{questions}
\question Answer the following questions.
\begin{parts}
\part Let $ a=3 $ and $ b=4 $. Consider the equation
\begin{equation}
a^{2} + b^{2} = c^{2},
\end{equation}
where all values are positive. Calculate the value of $ c $.
\begin{solution}
We have, given that $ c>0 $,
\begin{equation}
c^{2} = 3^{2} + 4^{2} \Rightarrow c = 5.
\end{equation}
\end{solution}
\part Let $ a=5 $. The variable $ b $ is given by
\begin{equation}
b = a^{2}.
\end{equation}
Calculate the value of $ b $.
\begin{solution}
We have
\begin{equation}
b = 5^{2} \Rightarrow b = 25.
\end{equation}
\end{solution}
\end{parts}
\end{questions}
\end{document}