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}


equationsolution. – Jesse op den Brouw Oct 18 '18 at 14:23equationenvironment is not really an option because it has to know if it is in ansolutionenvironment or not. – Jesse op den Brouw Oct 18 '18 at 14:43align. A solution that involves the counter (\addtocounter,\setcounteretc) might be easier to implement. Ideally, the counter had not to work inside the solution environment if the answers are not being printed. – Andre Oct 19 '18 at 13:29