对齐 \blacksquare

对齐 \blacksquare

我怎样才能将\blacksquare符号对齐\Circle

在此处输入图片描述

答案1

我猜那是\Circle来自wasysym

\documentclass{article}
\usepackage{amsmath,amssymb}

\DeclareSymbolFont{wasysym}{U}{wasy}{m}{n}
\DeclareMathSymbol{\Circle}{\mathord}{wasysym}{35}

\makeatletter
\newcommand{\BlackSquare}{{\mathpalette\adapt@to@Circle\blacksquare}}
\newcommand{\adapt@to@Circle}[2]{%
  \sbox\z@{$#1\Circle$}%
  \sbox\tw@{$#1#2$}%
  \raisebox{-0.5\dimexpr\ht\tw@-\ht\z@+\dp\z@}{$\m@th#1#2$}%
}
\makeatother

\begin{document}

$P\{X,Y \mid \Circle,\BlackSquare\}$

\setlength{\fboxsep}{0pt}\setlength{\fboxrule}{0.1pt}% for the demonstration
\fbox{$\Circle\BlackSquare$}
\fbox{$\scriptstyle\Circle\BlackSquare$}
\fbox{$\scriptscriptstyle\Circle\BlackSquare$}

\end{document}

在此处输入图片描述

请注意,符号wasysym在下标和上标中不会缩放,因此我选择\Circle以不同的方式实现。

相关内容