# Why is gathered undefined?

Using the gathered environment causes my ide (TexStudio) to report an error

Error: Undefined control sequence. \begin{gathered}


even though I'm using the package mathtools (I also tried it with amsmath). Also the PDF comes out exactly as desired. But my ide keeps moving the view to the location of the error which is rather annoying.

A minimal example is

\documentclass{report}
\usepackage{mathtools}

\begin{document}
$\begin{gathered} x \end{gathered}$
\end{document}


The error disappears if I replace mathtools with amsmath. But there are commands in mathtools that I need. And adding amsmath doesn't work. Also mathtools is supposed to load amsmath transitively.

The log file reports

! Undefined control sequence.
\\MT_gathered_env ...vir }}\fi \alignedspace@left
\if #1t\vtop \else \if #1b...
l.6 \begin{gathered}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., \hobx'), type I' and the correct
spelling (e.g., I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.


## 1 Answer

At some point you have updated mathtools without updating amsmath. So a full fix would be to update amsmath using your miktex or texlive package manager however

\makeatletter
\def\alignedspace@left{\null\,}
\makeatother


will give the old behaviour.

You have not shown it but your log file would have had a warning from LaTeX that your amsmath was too old as mathtools specifies a requirement

\RequirePackage{amsmath}[2016/11/05]


and your amsmath` must be older than 2016 or it would define this command.