I need \mathbbm to print a colored output.
I tried:
\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{bbm}
\let\oldmathbbm\mathbbm
\def\mathbbm#1#{\mathbbmaux{#1}}
\newcommand*\mathbbmaux[2]{{\color{red}\oldmathbbm#1{#2}}}
\pagestyle{empty}
\begin{document}
$\mathbbm{i}$
${\mathbbm i}$
\end{document}
but the string ${\mathbbm i}$ returns an error. Where Am I wrong?
I need this trick to spot if authors used \mathbbm, directly in the pdf file. (I pass this strings to the pdflatex engine without modifying the source .tex file.)


\def\mathbbm#1#{...}you are defining\mathbbmso that it must find an opening brace. Why are you doing that at all? – campa Mar 12 '21 at 21:20#1#{. – campa Mar 12 '21 at 21:30\renewcommanddidn't work. – Gabriele Mar 12 '21 at 21:35