Why does the following work
\documentclass[answers]{exam}
\begin{document}
\begin{center}
\Large\textbf{
\shortstack{
Assignment 1
\ifprintanswers\\ (Answer)\fi
}
}
\end{center}
\end{document}
while this (after replacing the parenthesis with square brackets in the second printed line) doesn't?
\documentclass[answers]{exam}
\begin{document}
\begin{center}
\Large\textbf{
\shortstack{
Assignment 1
\ifprintanswers\\ [Answer]\fi
}
}
\end{center}
\end{document}
\\[3pt]adds 3pt after the linebreak and\\[answer]isn't a length, use\\{} [answer](or anything else to hide the[from the\\) – David Carlisle Feb 16 '22 at 00:00