答案1
一种解决方案是将符号与 的截断版本\blacktriangleright
和完整符号组合在一起\rhd
。示例使用\mathrel
表示结果作为关系符号(如\blacktriangleright
)。如果最终符号最好是二进制符号(如\rhd
),则\mathrel
需要用 替换\mathbin
。幸运的是, 的两个符号amssymb
在三角形的形式和尺寸以及包括侧边距在内的字符宽度上都匹配。
\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}
\@ifdefinable
用于检查宏是否已定义的定义变体:
\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}