# Half overlap two symbols from amssymb

I am using the empty and filled triangle amssymb but i need a third one. It should look like the \blacktriangleright in the first half and like \rhd in the second half.

MWE

\documentclass{article}
\usepackage{amssymb}
\begin{document}

$\rhd$

$\blacktriangleright$

% half \blacktriangleright and half \rhd

\end{document}


A solution, which composes the symbol with a clipped version of \blacktriangleright and the full symbol \rhd. The example uses \mathrel for the result as relational symbol (like \blacktriangleright). If the final symbol should be better a binary symbol (like \rhd), then \mathrel needs to be replaced by \mathbin. Luckily both symbols of package amssymb match in form and dimension of the triangle and in the character widths including side bearings.

\documentclass{article}
\usepackage{amssymb}

\usepackage{trimclip}
\makeatletter
\newcommand*{\halfblacktriangleright}{}%
\DeclareRobustCommand*{\halfblacktriangleright}{%
\mathrel{% like \blacktriangleright or \mathbin like \rhd
\mathpalette\@halfblacktriangleright{}%
}%
}
\newcommand*{\@halfblacktriangleright}[2]{%
% #1: math style
% #2: unused
\rlap{%
\clipbox{0 0 {.55\width} 0}{$#1\blacktriangleright\m@th$}%
}%
\rhd
}
\makeatother

\begin{document}

%$\rhd\quad\blacktriangleright$

$1\halfblacktriangleright 2\quad \scriptstyle 1\halfblacktriangleright 2\quad \scriptscriptstyle 1\halfblacktriangleright 2$

\end{document}


Definition variation which uses \@ifdefinable for checking, whether a macro is already defined:

\documentclass{article}
\usepackage{amssymb}

\usepackage{trimclip}
\makeatletter
\@ifdefinable{\halfblacktriangleright}{%
\@ifdefinable{\@halfblacktriangleright}{%
\protected\def\halfblacktriangleright{%
\mathrel{% like \blacktriangleright or \mathbin like \rhd
\mathpalette\@halfblacktriangleright{}%
}%
}%
\def\@halfblacktriangleright#1#2{%
% #1: math style
% #2: unused
\rlap{%
\clipbox{0 0 {.55\width} 0}{$#1\blacktriangleright\m@th$}%
}%
\rhd%
}%
}%
}
\makeatother

\begin{document}

%$\rhd\quad\blacktriangleright$

$1\halfblacktriangleright 2\quad \scriptstyle 1\halfblacktriangleright 2\quad \scriptscriptstyle 1\halfblacktriangleright 2$

\end{document}

• Very nice! I didnt know about the trimclip package before. Perhaps \newcommand should be \DeclareRobustCommand, because \rlap is not expandable (as \clipbox probably). Thus using \halfblacktriangleright will currently lead to nice surprises when used in section headings. – Henri Menke Jul 19 '16 at 21:02
• @HenriMenke Thanks, the updated answer makes it robust and fixes a smaller issue with the number of arguments for \@halfblacktriangleright. – Heiko Oberdiek Jul 19 '16 at 21:09
• @HenriMenke The additional \newcommand checks, whether the macro is already defined. I have appended a version, which instead uses \@ifdefinable and e-TeX's \protected. – Heiko Oberdiek Jul 19 '16 at 21:36
• @HenriMenke On the other hand \relax as "empty" argument is not empty, but is one token instead of no tokens. Also \relax is longer to write and less clear to read than {} for an empty argument. – Heiko Oberdiek Jul 19 '16 at 21:39