# Character with two colors

I realise that this is somewhat of a special question, but is it possible to have regular characters in formulas, where the left half is colored e.g. in red and the right half is colored in blue, similar to the image below?

• I once saw something similar in a german blogpost. This might already help you. Zweifarbige Buchstaben (Two-colored letters) – Johannes_B Sep 17 '14 at 6:51
• also this: tex.stackexchange.com/questions/192496/… – Nico Vecchio Sep 17 '14 at 7:06
• – David Carlisle Sep 17 '14 at 8:11
• @dcmst, though very similar, but in this case OP needs bicolor letters in math-mode. Bearing in mind my limited knowledge about this topic, I don't know if it is possible to extend those answers to formulas. – Pouya Sep 17 '14 at 9:08
• @pouya the accepted answer there works for both math and normal text. But I'm not suggesting this is an exact dupe, just related. – Nico Vecchio Sep 17 '14 at 9:13

I'm not sure what this would be used for, but the only method I see is to typeset two copies of the same glyph, clipped and differently colored.

\documentclass{article}
\usepackage{trimclip,xcolor}

\newcommand{\Atwo}{%
\mbox{%
\def\Ahalf##1{\dimexpr.5\width ##1 0.025em\relax}
\textcolor{red}{\clipbox{0 0 {\Ahalf+} 0}{A}}%
\textcolor{blue}{\clipbox{{\Ahalf-} 0 0 0}{A}}%
}%
}

\begin{document}
\Atwo
\end{document}


The little correction depends on the character: the vertex of the A doesn't lie at the exact half.

The risk of optical effects is very big: here the horizontal stem doesn't seem to connect properly, but just because of the choice of the colors.

• What do you mean by optical effect? There actually is a bright line between the two colors, it's not just an optical illusion. – Overv Sep 17 '14 at 18:08

Why not with tikz (I know for sure... it is heavy).

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand{\Atwo}[3][A]{%
\begin{tikzpicture}
\begin{scope}
\node[inner sep=0pt,outer sep=0pt] (a) {\phantom{#1}};
\clip (a.south west) rectangle ($(a.north)-(0.5\pgflinewidth,0)$);
\node[inner sep=0pt,outer sep=0pt,text=#2]  {#1};
\end{scope}
\clip (a.south east) rectangle ($(a.north)-(0.5\pgflinewidth,0)$);
\node[inner sep=0pt,outer sep=0pt,text=#3]  {#1};
\end{tikzpicture}
}

\begin{document}
\Atwo{blue}{red} \Atwo[B]{green}{magenta}
\end{document}