如何用颜色填充符号?

如何用颜色填充符号?

\diamond像、\circ和这样的 LaTeX 符号\square在编译时是透明符号的形式。我如何将黑色填充到这些形状中?例如,\circ阴影黑色是\bullet。是否有类似的命令用于\diamond\square

答案1

amssymb有它们,否则,例如,你可以使用fdsymbol

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{fdsymbol}
\begin{document}
\noindent With \texttt{amsmath}:
\[
\blacklozenge \quad \blacksquare
\]
With \texttt{fdsymbol}:
\[
\medblackdiamond \quad \medblacksquare \quad
\smallblackdiamond \quad \smallblacksquare \quad
\]
\end{document}

在此处输入图片描述

编辑: 由于\nabla受到 的影响fdsymbol,因此您可以改用stix

\documentclass{article}
\usepackage{amsmath}
\usepackage{stix}
\usepackage{array}
\setlength\extrarowheight{4pt}

\begin{document}
    \begin{tabular}{>{\ttfamily\textbackslash}l>{$}l<{$}}
        \multicolumn{2}{l}{With \texttt{stix} package:}\\
        mdblkdiamond & \mdblkdiamond \\
        mdblksquare & \mdblksquare \\
        mdlgblkdiamond & \mdlgblkdiamond \\
        mdlgblksquare \textnormal{or its alias} \textbackslash\texttt{blackquare} & \mdlgblksquare \quad \blacksquare\\
        nabla \textnormal{is correct}& \nabla
    \end{tabular}
\end{document}

在此处输入图片描述

答案2

简单起点的选项(符号的用途不明确(例如数学/文本/图形符号?):

\documentclass{article}
\usepackage{tikz}
\begin{document}
  \tikz\shadedraw (0, 0) rectangle (1, 1);
  \tikz[rotate=45]\shadedraw (0, 0) rectangle ({1/sqrt(2)}, {1/sqrt(2)});
  \tikz[rotate=45]\shadedraw[shading angle=45]
    (0, 0) rectangle ({1/sqrt(2)}, {1/sqrt(2)});
\end{document}

结果

答案3

使用xelatex或运行lualatex

\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{XITSMath}
\begin{document}
$\mdwhtcircle\mdblkcircle$
$\mdlgwhtdiamond\mdlgblkdiamond$
$\mdlgwhtsquare\mdlgblksquare$
\end{document}

在此处输入图片描述

相关内容