I have the following problem. When trying to compile the code

\newcommand{\system}{$\displaystyle \left\{
\end{aligned} \right.$}

    \newcommand{\sameas}{\\ \rotatebox{90}{$\Leftrightarrow$} \\}
    $\displaystyle y=0$
    $\displaystyle y^2=0$
    $\displaystyle y=0$

LaTeX displays the first call to \sameas correctly, but says it doesn't know what \sameas is in the following calls. Why does it suddenly forget the definition of \sameas?

Here's the error message:

l.94     \sameas
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.

I'm using Overleaf.

  • 1
    Welcome! Please add the necessary code (preamble, etc) so that we can compile your code: help us to help you!
    – Rmano
    Jun 17, 2023 at 18:16
  • 3
    Inside a tabular every cell is an implicit group, and TeX forgets local assignments at the end of a group.
    – Skillmon
    Jun 17, 2023 at 18:20
  • 1
    If you just move your definition of \sameas one line up it'll still not affect the rest of your document (it'll be local to center), but your tabular will work out.
    – Skillmon
    Jun 17, 2023 at 18:24

1 Answer 1


A table or alignment cell is a tex group, so

.... & \newcommand\foo{???}  &   \foo

is like

.... { \newcommand\foo{???}  }   \foo

and all non global assignments are discarded at a group end.

  • 1
    Maybe add the note that if the command is moved outside the tabular but inside the center environment it'll still not leak but affect all the cells?
    – Skillmon
    Jun 17, 2023 at 18:21
  • 1
    Also, 4 seconds too slow! :)
    – Skillmon
    Jun 17, 2023 at 18:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .