I want to patch the newline command \\ in an align environment provided by amsmath. The patched version should execute some custom code and finally call the original definition, like in the following example.
\documentclass{minimal}
\usepackage{amsmath}
\begin{document}
\begin{align}
\let\old\\%
\def\\{1\old}%
%
a\\
b\\
c
\end{align}
\end{document}
This results in:

So it works only for the first call (the "b" is missing a "1"). Why is this and how can I make it work for all newlines?

alignuses the same mechanism astabularand all cells are implicit groups, so that a local definition doesn't survive the cell in which it's given. Can you please give more motivation for what you're trying to do? – egreg Jun 1 '12 at 22:15\globalbefore the\letand the\defdoes not solve the problem. Then an error about the exceeded memory capacity of TeX is thrown. I was just guessing anyways ... – MMM Jun 1 '12 at 22:27