
答え1
円は TikZ でも描画できます。次のオプションplot
も受け入れますmark
:
\documentclass{article}
\usepackage{tikz}
\newcommand*{\RedCircle}{}
\DeclareRobustCommand*{\RedCircle}{%
\tikz\path plot[
mark=*,
mark size=3,
mark options={solid, fill=red},
] coordinates {(0, 0)};%
}
\begin{document}
Circle: \RedCircle
\end{document}
数式軸を中心とした垂直方向のセンタリング
中央揃えの記号は括弧内にぴったり収まります。
\documentclass{article}
\usepackage{tikz}
\newcommand*{\RedCircle}{}
\DeclareRobustCommand*{\RedCircle}{%
\ensuremath{\vcenter{\hbox{%
\tikz\path plot[
mark=*,
mark size=3,
mark options={solid, fill=red},
] coordinates {(0, 0)};%
}}}%
}
\begin{document}
Circle (\RedCircle)
\end{document}
境界ボックスの補正
TikZ は境界ボックスのマークの線幅を考慮していないようです。次のコードはこれを補うために小さなフレームを追加します。
\documentclass{article}
\usepackage{tikz}
\newcommand*{\RedCircle}{}
\DeclareRobustCommand*{\RedCircle}{%
\ensuremath{\vcenter{\hbox{%
\setlength{\fboxsep}{.21pt}%
% 0.2pt (half line width)
% + 0.01pt to get some rounding tolerance
\setlength{\fboxrule}{0pt}%
\fbox{%
\tikz\path plot[
mark=*,
mark size=3,
mark options={solid, fill=red, draw=black},
] coordinates {(0, 0)};%
}%
}}}%
}
\begin{document}
% Show bounding box:
\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{.1pt}
(\textcolor{cyan}{\fbox{\RedCircle}})
\end{document}
TikZ 内に余白を追加します (外部化によって画像がクリップされる可能性があります):
\documentclass{article}
\usepackage{tikz}
\newcommand*{\RedCircle}{}
\DeclareRobustCommand*{\RedCircle}{%
\ensuremath{\vcenter{\hbox{%
\def\BoundingBoxCorrection{.55\pgflinewidth}%
% .5\pgflinewidth: half the line width, forgotten by TikZ
% .05\pgflinewidth: some tolerance for rounding errors
\tikz\path plot[
mark=*,
mark size=3,
mark options={solid, fill=red, draw=black},
] coordinates {(0, 0)}
(current bounding box.south west)
++(-\BoundingBoxCorrection, -\BoundingBoxCorrection)
(current bounding box.north east)
++(\BoundingBoxCorrection, \BoundingBoxCorrection)
;%
}}}%
}
\begin{document}
% Show bounding box:
\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{.1pt}
(\textcolor{cyan}{\fbox{\RedCircle}})
\end{document}