It is quit difficult to get the two symbols scaled and align correctly in all four math modes. Better draw it using TikZ. One difficulty is to properly scale the size and line width. This can be best done using amsmath
\text
macro.
I made two versions which are slightly different.
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\newcommand{\sqdiamond}{\mathbin{\text{\tikz [x=1ex,y=1ex,line width=.1ex,line join=round] \draw (0,0) rectangle (1,1) (0,.5) -- (.5,1) -- (1,.5) -- (.5,0) -- (0,.5) -- cycle;}}}
\newcommand{\varsqdiamond}{\mathbin{\text{\tikz [x=1ex,y=1ex,line width=.1ex,line join=round] \draw (0,0) rectangle (1,1) (.5\pgflinewidth,.5) -- (.5,1ex-.5\pgflinewidth) -- (1ex-.5\pgflinewidth,.5) -- (.5,.5\pgflinewidth) -- (.5\pgflinewidth,.5) -- cycle;}}}
\begin{document}
% Test code:
.. $a \sqdiamond b$ ..
\[a \sqdiamond b \]
.. $X_{a \sqdiamond b}$ ..
.. $X_{X_{a \sqdiamond b}}$ ..
.. $a \varsqdiamond b$ ..
\[a \varsqdiamond b \]
.. $X_{a \varsqdiamond b}$ ..
.. $X_{X_{a \varsqdiamond b}}$ ..
\end{document}
Zoomed:
Variant 1:
Variant 2:
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.
Best Answer
There are three simple options. One is
\fbox{}
, the content of which is typeset in text mode, but can handle math mode as well. Loading theamsmath
package provides\boxed{}
, the content of which is typeset in math mode. Both of these can be used in text or math mode (i.e., you don't need to enter math mode first). Loading themathtools
package provides\Aboxed{}
, which is for placing part of analign
environment in a box.