I have used \theta hundreds of times in my document. Now I decided that I would like all thetas to be in red color.
So I would like to redefine the command \theta to create a red theta.
MWE:
\documentclass{article}
\usepackage{xcolor}
\let\oldtheta\theta
\renewcommand{\theta}{\mathcolor{red}{\oldtheta}}
\newcommand{\thetaWrongSpacing}{{\mathcolor{red}{\oldtheta}}}
\begin{document}
$M^\theta$ %gives error message
$\theta_1\oldtheta_1$ %works perfectly
$M^\thetaWrongSpacing$ %works perfectly
$\thetaWrongSpacing_1$ %wrong spacing
$M^\alpha$ % seems to work perfectly, but David Carlisle says this should not be used according to the LaTeX manual
\end{document}
but then $M^\theta$ results in an error. I can fix this by enclosing the definition of the command with {}, but then the spacing is not correct.
How can I redefine \theta in the preamble without making any change within the document?
PS:
\renewcommand{\theta}{\begingroup\mathcolor{red}{\oldtheta}\endgroup} does also produce an error for $M^\theta$ and flaws the spacing of \theta_1.


^\thetais not supported latex syntax (you are supposed to use braces) – David Carlisle Nov 16 '23 at 12:30$M^\oldtheta$and$M^\thetaWrongSpacing$. – Stephen Nov 16 '23 at 12:35$\thetaWrongSpacing_1$has wrong spacing. – Jakob Nov 16 '23 at 12:36\newcommand\hmm{10} $M^{\hmm} = M^\hmm$– David Carlisle Nov 16 '23 at 12:37^\thetaby^{\theta}and to convince my coauthors not to use^\thetaanymore. – Jakob Nov 16 '23 at 12:49^\thetain future. – Jakob Nov 16 '23 at 15:10