The problem has nothing to do with mathtools it self, but rather to it loading the calc package`. So we can reduce the problem to
\documentclass{thesis-umich}
\usepackage{calc}
\begin{document}
test
\appendix
test
\end{document}
which produces the error
! Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next
{\calc@error #1}\fi \fi \f...
l.11 \appendix
When using Overleaf, please never ever ignore compilation errors. Overleaf, like many LaTeX editors run in a mode that tries to complete the compilation even if there are errors. This may cause issues in the PDF with things not being typeset correctly. Often a single error causes many others ...
The problem her is this definition in thesis-umich.cls
\renewcommand{\appendix}{ %
% Move to new page.
\clearpage %
% Renew the counters.
\renewcommand*{\thechapter}{\Alph{chapter}} %
% Start over the chapter counter.
\setcounter{chapter}{0} %
% Add a pdf anchor.
\phantomsection %
% Add blank space to table of contents
\addtocontents{toc}{\vspace{3.9ex}}
% Add the page to the table of contents.
\addcontentsline{toc}{backchapter}{Appendices}
% Stop adding sections to the table of contents.
\addtocontents{toc}{\setcounter{tocdepth}{1}} %
% Header for appendices.
\renewcommand{\@chapapp}{APPENDIX} %
% Renew the chapter and section labels.
\let\@chapter\@chapter@appendix %
}
especially the line
\addtocontents{toc}{\setcounter{tocdepth}{1}} %
whenever calc is loaded, \setcounter becomes a fragile command, and this it needs protection (from premature expansion) when being written to a file.
So here the fix is to add this to your preamble (don't change the cls file, rather send those maintaining it a message and ask them to fix it).
\makeatletter
\renewcommand{\appendix}{ %
% Move to new page.
\clearpage %
% Renew the counters.
\renewcommand*{\thechapter}{\Alph{chapter}} %
% Start over the chapter counter.
\setcounter{chapter}{0} %
% Add a pdf anchor.
\phantomsection %
% Add blank space to table of contents
\addtocontents{toc}{\vspace{3.9ex}}
% Add the page to the table of contents.
\addcontentsline{toc}{backchapter}{Appendices}
% Stop adding sections to the table of contents.
\addtocontents{toc}{\protect\setcounter{tocdepth}{1}} % <-----
% Header for appendices.
\renewcommand{\@chapapp}{APPENDIX} %
% Renew the chapter and section labels.
\let\@chapter\@chapter@appendix %
}
\makeatother
mathtoolsit self, but bycalc. One can cut the error down to `\documentclass{thesis-umich} \usepackage{calc} \begin{document} test\appendix
test \end{document}` and btw this generates an error. Don't ignore errors just because it produces a PDF, the PDF may contain the wrong output.
– daleif May 04 '22 at 06:59