Overleaf error messages when compiling with \begin{align*} and \end{align*} and using \bm{\varphi}

aligncompilation errorequationserror barserrors

I'm getting error messages in overleaf such as "Missing } inserted.", "Extra }, or forgotten \endgroup.", "Misplaced alignment tab character &.", "Misplaced alignment tab character &.", "Misplaced \omit.", "Misplaced \cr.", "Misplaced \noalign.", "Missing $ inserted." and "Missing \cr inserted."

It compiling when I use equation instead of align but doesnt otherwise. My code also compiles if I remove \bm{\varphi} and just write \varphi. It doesnt miss a { or } and no alignment is missplaced. I cant understand why it wouldn't compile and I really would like to use align instead of equation since it is much better looking. My code is as follows

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{bm,mathtools}
\usepackage{amsthm}
\usepackage{chemist}
\newcommand{\rd}[1] {\ensuremath{\mathrm{d}#1}} %creates operator ds that makes it more clear that \frac{d}{dt} is an math operator 
\newcommand{\ham}{\mathcal{H}} %hamiltonian


\begin{document}


\begin{align*}
    \frac{\rd }{\rd t} \left( \left( \frac{\partial \bm{\varphi}_{t}}{\partial 
    \bm{y}_{0}} \right)^{T} J \left( \frac{\partial \bm{\varphi}_{t}}{\partial 
    \bm{y}_{0}} \right) \right) 
    &= \left(\frac{\rd}{\rd t} \frac{\partial \bm{\varphi}_{t} } {\partial \bm{y}_{0}}\right)^T J \left(\frac{\partial \bm{\varphi}_{t} } {\partial \bm{y}_{0}}\right) + \left(\frac{\partial \bm{\varphi}_{t} } {\partial \bm{y}_{0}} \right)^T J \left(\frac{\rd}{\rd t} \frac{\partial \bm{\varphi}_{t} } {\partial \bm{y}_{0}}\right)\\
    &=\left(\frac{\partial \bm{\varphi}_{t} } {\partial \bm{y}_{0}}\right)^T \nabla^2 \ham(\bm{\varphi}_t(\bm{y}_0)) J^T J \left(\frac{\partial \bm{\varphi}_{t} } {\partial \bm{y}_{0}}\right) + \left(\frac{\partial \bm{\varphi}_{t} } {\partial \bm{y}_{0}} \right)^T \nabla^2 \ham(\bm{\varphi}_t(\bm{y}_0)) \left( \frac{\partial \bm{\varphi}_{t} } {\partial \bm{y}_{0}}\right)\\
    &=0
\end{align*}

\end{document}

It seems that the code work if I put it into another blank overleaf document but doesn't work in my original document for some reason. So to be clear if you copy this it will work but my code is approximately 2000 lines of code so might be something else or some smaller error that stack up?

Best Answer

Having gotten access to the project in Overleaf, here are my observations.

The project cannot compile and the first error is

<inserted text> 
                }
l.439     \bm{\varphi}
                      _t (\bm{p}_0, \bm{q}_0) = (\bm{p}(t, \bm{p}_0, \bm{q}_...
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.

! Missing } inserted.
<inserted text> 
                }
l.439     \bm{\varphi}
                      _t (\bm{p}_0, \bm{q}_0) = (\bm{p}(t, \bm{p}_0, \bm{q}_..

That can be boiled down to

\documentclass[a4paper]{article}
\usepackage{bm,mathtools}
\usepackage{chemist}
\begin{document}
\begin{equation*}
    \bm{\varphi}
\end{equation*}
\end{document}

I don't think that chemist package is recommendable, one should probably use mhchem or chemmacros (I haven't looked into what chemist does other than it redefines \varphi and friends).

The next error was two labels in an equation. Lastly a missing comma in a .bib file. So in the end not too hard once I had access to the files.

The main take down here is: When Overleaf reports an error. Look at the first one. The rest can be accumulations that goes away once the first error is fixed.

Where the OP got the

Missing } inserted."...

error from I do not know, but it was not the first error listed when Overleaf compiled the project copy I had access to.