3

I would expect the following code:

\documentclass{article}
\begin{document}
\newcommand{\foo}{NO!}
\begin{tabular}{ll}
FILLER & \foo \\
\renewcommand{\foo}{YES!}%
FILLER & \foo \\
\end{tabular}
\end{document}

to produce

FILLER NO!
FILLER YES!

but instead I get

FILLER NO!
FILLER NO!

Can anyone tell me what is going on here?

0

1 Answer 1

0

Shamelessly copied from this answer.

Inside a tabular cell everything is local, so changes to macros are not recognized outside the cell. Use \gdef\foo{YES!} instead of \renewcommand in the tabular environment.