I would like \forall to trigger a certain behavior (for the purpose of the example below: change the text color to red), which is cancelled when the next ( is encountered. I can make this work when the ( in question is not within a command, but not when it is. Here is an MWE:
\documentclass{article}
\usepackage{color}
\let\oldforall\forall
\renewcommand{\forall}{%
\oldforall%
\color[rgb]{1,0,0}%
\catcode`(=\active%
}
\let\lparen=(
\catcode`(=\active
\renewcommand{(}{%
\color[rgb]{0,0,0}%
\catcode`(=12\relax%
\lparen}%
\catcode`(=12
\newcommand{\acommand}[1]{#1}
\begin{document}
This works: $\forall x(x^2\geq0)$
This doesn't: \acommand{$\forall x(x^2\geq0)$}
\end{document}
I need a solution that doesn't involve changing the definition of \acommand, as this has to work for any macro that ( may find itself in.
I can understand from “Activate” active characters in argument passed as macro that the issue is that the ( is passed as a passive character to the macro, at which point it is too late to make it active. But I do not understand the solution, so I'm not able to adapt it to my problem.


(with\boldsymbol(fromamsmath) is a known issue related to\resetMathstrut@inner macro ofamsmath. You can check the source code of packagemathastextto find a way to redefine\resetMathstrut@in a way which solves that problem. The code inmathastext.styhowever needs some adjustment for general use, as it makes use of math groups defined bymathastext. – Apr 02 '16 at 16:28