# \triangleleft and \bowtie

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?

-
I don't think it's a good idea to redefine \triangleleft; it's just a generic name and you should use a new name that reflects the meaning of the green symbol. –  egreg Mar 2 '13 at 20:27
@egreg I appreciate your comment. However, I'm still curious as to whether there's a way to get around the problem I mentioned :) –  Mika H. Mar 2 '13 at 20:32
@Qrrbrbirlbel Why the additional braces with \textcolor? There no need for it and it's surely preferable to \color in math mode. –  egreg Mar 2 '13 at 20:41

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.

-

Redefining commands always carries some risks, if that command is used by other ones. This is one case.

There's no general rule, unfortunately, for telling whether a redefinition can harm other commands. You've found that \triangleleft is used by \bowtie and it's almost obvious that there's a problem, because \bowtie is defined by

\DeclareRobustCommand{\bowtie}{%
\mathrel\triangleright\joinrel\mathrel\triangleleft}


in fontmath.ltx. What you should do is thus

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

\DeclareRobustCommand{\bowtie}{%
\mathrel\triangleright\joinrel\mathrel\oldtriangleleft}


and \bowtie will use the "uncolored" triangle.

However, I don't recommend this path. Rather, define a new command for the green triangle, reflecting its intended meaning.

If the green triangle left is to be used in the same way as the black one, I suggest to declare it as a binary operation (\triangleleft is a binary relation symbol):

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

-