[Tex/LaTex] Square version of \cdot (small black square)

amsmathmath-modesymbols

I'm looking for the symbol that's similar to \cdot in math mode, but instead of a small circle, it's a square. Like this:

enter image description here

Best Answer

There are several ways for doing this. One idea could be \centerdot from amssymb, but this has the defect of sitting on the baseline, despite its name.

One can fix this by observing that the apparent height of the glyph is three times the real height. So smashing the height to one third and using \vcenter will raise the symbol up to the formula axis.

\documentclass{article}
\usepackage{amssymb}

\makeatletter
\DeclareRobustCommand{\sqcdot}{\mathbin{\mathpalette\morphic@sqcdot\relax}}
\newcommand{\morphic@sqcdot}[2]{%
  \sbox\z@{$\m@th#1\centerdot$}%
  \ht\z@=.33333\ht\z@
  \vcenter{\box\z@}%
}
\makeatother

\begin{document}

$\bar{f} \sqcdot f\simeq c_{a\sqcdot b}$

\end{document}

enter image description here

Second way: import \sqbullet from the mathabx fonts.

\documentclass{article}

\DeclareFontFamily{U}{mathb}{}
\DeclareFontShape{U}{mathb}{m}{n}{
  <-5.5> mathb5
  <5.5-6.5> mathb6
  <6.5-7.5> mathb7
  <7.5-8.5> mathb8
  <8.5-9.5> mathb9
  <9.5-11.5> mathb10
  <11.5-> mathb12
}{}
\DeclareSymbolFont{mathb}{U}{mathb}{m}{n}
\DeclareMathSymbol{\sqcdot}{\mathbin}{mathb}{"0D}% name to be checked

\begin{document}

$\bar{f} \sqcdot f\simeq c_{a\sqcdot b}$

\end{document}

One could avoid wasting a symbol font with the help of \text:

\documentclass{article}
\usepackage{amsmath}

\DeclareFontFamily{U}{mathb}{}
\DeclareFontShape{U}{mathb}{m}{n}{
  <-5.5> mathb5
  <5.5-6.5> mathb6
  <6.5-7.5> mathb7
  <7.5-8.5> mathb8
  <8.5-9.5> mathb9
  <9.5-11.5> mathb10
  <11.5-> mathbb12
}{}
\DeclareRobustCommand{\sqcdot}{%
  \mathbin{\text{\usefont{U}{mathb}{m}{n}\symbol{"0D}}}%
}

\begin{document}

$\bar{f} \sqcdot f\simeq c_{a\sqcdot b}$

\end{document}

Both examples typeset the same

enter image description here

For using the glyph in the MnSymbol font, it is similar:

\documentclass{article}
\usepackage{amsmath}

\DeclareFontFamily{U}{MnSymbolC}{}
\DeclareFontShape{U}{MnSymbolC}{m}{n}{
  <-5.5> MnSymbolC5
  <5.5-6.5> MnSymbolC6
  <6.5-7.5> MnSymbolC7
  <7.5-8.5> MnSymbolC8
  <8.5-9.5> MnSymbolC9
  <9.5-11.5> MnSymbolC10
  <11.5-> MnSymbolCb12
}{}
\DeclareRobustCommand{\sqcdot}{%
  \mathbin{\text{\usefont{U}{MnSymbolC}{m}{n}\symbol{"69}}}%
}

\begin{document}

$\bar{f} \sqcdot f\simeq c_{a\sqcdot b}$

\end{document}

enter image description here

Take your pick.