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:
7 Answers
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}
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
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}
Take your pick.
- 1,121,712
-
Great answer, thanks. You may want to check the name
mathbb12... I eventually ran into compile errors, which I resolved by changing it tomathb12(only oneb). – 808sound May 03 '17 at 02:57 -
Great answer! Is there a simple way to modify it for an unfilled square rather than a filled square? Simply using
\squareis not good enough, since I need the square to be the same size as\bulletand\textopenbullet, whereas\squareis too big. – Evan Aad Nov 12 '18 at 10:38 -
Handcraft it.
\documentclass{scrartcl}
\newcommand*\sq{\mathbin{\vcenter{\hbox{\rule{.3ex}{.3ex}}}}}
\begin{document}
$f$ by $\bar f$ gives $\bar f \sq f \simeq c$ for $c$ the constant\dots
\end{document}
- 27,118
-
1Is it the case that this does not automatically handle different math styles (e.g.,
\scriptstyle, etc.)? – Steven B. Segletes Oct 15 '15 at 02:32 -
1It looks good for me in different styles, but you could, as always, develop some
\mathpalette\sqaux\relaxthen\if\scriptstyle#1.2ex\else\if\scriptscriptstyle#1.15ex\else.3ex\fi\fi(or whatever dimensions you choose) in place of the dimensions of\rule. – Manuel Oct 15 '15 at 07:24
Here, I use a \scalerel* to make a strutted rule scale to the size of \cdot. scalerel package macros work in all math styles automatically (unless disabled).
\documentclass{article}
\usepackage{scalerel}
\def\sq{\mathbin{\scalerel*{\strut\rule{1ex}{1ex}}{\cdot}}}
\begin{document}
$f$ by $\bar f$ gives $\bar f \sq f \simeq c$ for $c$ the constant\dots\par
$\scriptscriptstyle\bar f \sq f \simeq c$
\end{document}
Changing the size/vertical position of the \rule allows any size/position of box to be made. Here, I double the size of the square dot by using \rule[-.5ex]{2ex}{2ex}.
\documentclass{article}
\usepackage{scalerel}
\def\sq{\mathbin{\scalerel*{\strut\rule[-.5ex]{2ex}{2ex}}{\cdot}}}
\begin{document}
$f$ by $\bar f$ gives $\bar f \sq f \simeq c$ for $c$ the constant\dots\par
$\scriptscriptstyle\bar f \sq f \simeq c$
\end{document}
- 237,551
-
Is there a simple way to modify your answer to obtain an unfilled square rather than a filled square? – Evan Aad Nov 12 '18 at 10:40
-
1@EvanAad You could adapt this answer, https://tex.stackexchange.com/questions/459167/typesetting-dalembertian-symbol/459179#459179, except changing the scale from that of
\Deltato instead the scale of\cdot. – Steven B. Segletes Nov 12 '18 at 13:13
\sqbullet from mathabx perhaps?
\documentclass{article}
\usepackage{mathabx}
\begin{document}
$f \sqbullet f$
\end{document}
-
3
-
1
-
1No: while
mathabxsymbols somewhat match CM ones, those in MnSymbol are very distinct from them. There's a canonical answer about “importing a single symbol”, though. – egreg Oct 14 '15 at 20:39
Use \amssymb package and \centerdot.
\documentclass{article}
\usepackage{amssymb}
\begin{document}
$\bar{f} \centerdot f\simeq c$
\end{document}
-
Unfortunately it sits on the baseline, rather than be vertically centered to the formula axis. – egreg Oct 14 '15 at 20:48
-
-
3
You can use direct \vrule with \mathchoice TeX primitive.
\newcount\stylenum \newdimen\styledim
\def\varstyle#1{\mathchoice{\stylenum=0 #1}{\stylenum=1 #1}{\stylenum=2 #1}{\stylenum=3 #1}}
\def\mathaxis{\fontdimen22\ifcase\stylenum
\textfont\or\textfont\or\scriptfont\or\scriptscriptfont\fi2 }
\def\setstyledim{\styledim=\ifcase\stylenum .1em\or.1em\or.07em\or.05em\fi\relax}
\def\sqdot{\mathbin{\varstyle{\raise\mathaxis\hbox{\setstyledim
\kern\styledim
\vrule width1.2\styledim height.6\styledim depth.6\styledim
\kern\styledim}}}}
$f\sqdot g, f\cdot g, \scriptstyle f\sqdot g, f\cdot g$
\bye
- 74,238
Unicode-math fonts typically include the character \smblksquare. If you have loaded such font then you can type:
$a\mathbin\smblksquare b$
or define
\def\smallsquare{\mathbin\smblksquare}
The result (when latinmodern-math.otf is loaded) looks like this:
- 74,238








\sqbulletfrommathabxusing Importing a single symbol from a different font. – Werner Oct 14 '15 at 20:59