Help me please redefine & command inside a table. When I try to do it, I get an error:
! Misplaced alignment tab character &.
Probably problem with catcodes, but I dont know how to solve it.
\documentclass{article}
\usepackage{expl3,etoolbox}
\ExplSyntaxOn
\makeatletter
\cs_set_eq:NN \orig@& &
\AtBeginEnvironment{table}{
\cs_new_protected:npn{&}{\orig@&\message{amp command}}
}
%return original &
\AtEndEnvironment{table}{\cs_gset_protected:npn{&}{\orig@&}
\ExplSyntaxOff
\begin{document}
\begin{table}
test&new test\\
\end{table}
\end{document}
\begin{table}\begin{tabular}{cc}test&new test\end{tabular}\end{table}with no crazy hijinks. – Teepeemm Apr 07 '20 at 00:25