[Tex/LaTex] \triangleleft and \bowtie

symbols

I want to redefine the command \triangleleft so that it always has the color green:

\let\oldtriangleleft\triangleleft
\renewcommand\triangleleft{\textcolor{green}{\oldtriangleleft}}


When I use the command $\bowtie$, it complains "Missing { inserted." It is because \bowtie is defined based on \triangleleft? In that case, is there a fix?

IMHO it is not a good idea to re-define it. But if you have a reason for that: \bowtie is defined robustly as

\mathrel \triangleright \joinrel \mathrel \triangleleft


So you can do the following:

\documentclass{article}

\pagestyle{empty}

\usepackage{amsmath}
\usepackage{xcolor}

\let\oldtriangleleft\triangleleft
\renewcommand\triangleleft{\mathbin{\color{green}\oldtriangleleft}}
\DeclareRobustCommand\bowtie{\mathrel\triangleright\joinrel\mathrel\oldtriangleleft}

\begin{document}

$A\oldtriangleleft B$
$A\triangleleft B$
$A\bowtie B$

\end{document}


Notice that I put the new \triangleleft inside \mathbin to make it a binary operator, conserving the spacing of the original one.