答案1
TikZ 的解决方案:
大小适应当前数学样式。示例使用 letter 的大小
A
。线型越小,线宽越小。
完整示例:
\documentclass{article}
\usepackage{tikz}
\makeatletter
\newcommand*{\twohalfcircle}[2]{%
\ensuremath{%
\mathord{% change accordingly to the symbol type
\mathpalette{\@twohalfcircle{#1}{#2}}{}%
}%
}%
}
\newdimen\@twohalfcircle@dimen
\newdimen\@twohalfcircle@linewidth
\newdimen\@twohalfcircle@radius
\newcommand*{\@twohalfcircle}[4]{%
% #1: bottom color
% #2: top color
% #3: math style
% #4: unused
\sbox0{$#3A$}%
\@twohalfcircle@dimen=\ht0 %
\@twohalfcircle@linewidth=.06\@twohalfcircle@dimen
\pgfmathsetlength\@twohalfcircle@radius{%
.5\@twohalfcircle@dimen
- .5\@twohalfcircle@linewidth
}%
\begin{tikzpicture}[
baseline=-.5\@twohalfcircle@dimen,
x=\@twohalfcircle@dimen,
y=\@twohalfcircle@dimen,
radius=\@twohalfcircle@radius,
line width=\@twohalfcircle@linewidth,
]
\filldraw[fill={#1}] circle[];
\filldraw[fill={#2}]
(-\@twohalfcircle@radius, 0)
arc(180:360:\@twohalfcircle@radius)
-- cycle
;
\end{tikzpicture}
}
\makeatother
\begin{document}
\[
\twohalfcircle{green}{yellow}
^{\twohalfcircle{blue}{red}^{\twohalfcircle{orange}{cyan}}}
\]
\end{document}