TransWikia.com

Square version of cdot (small black square)?

TeX - LaTeX Asked by mr eyeglasses on January 26, 2021

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

7 Answers

sqbullet from mathabx perhaps?

documentclass{article}
usepackage{mathabx}

begin{document}

 $f sqbullet f$
end{document}

Answered by user31729 on January 26, 2021

Use amssymb package and centerdot.

documentclass{article}
usepackage{amssymb}

begin{document}
$bar{f} centerdot fsimeq c$
end{document}

Answered by ferahfeza on January 26, 2021

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 constantdots

end{document}

enter image description here

Answered by Manuel on January 26, 2021

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{mathpalettemorphic@sqcdotrelax}}
newcommand{morphic@sqcdot}[2]{%
  sboxz@{$m@th#1centerdot$}%
  htz@=.33333htz@
  vcenter{boxz@}%
}
makeatother

begin{document}

$bar{f} sqcdot fsimeq c_{asqcdot 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 fsimeq c_{asqcdot 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 fsimeq c_{asqcdot 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 fsimeq c_{asqcdot b}$

end{document}

enter image description here

Take your pick.

Answered by egreg on January 26, 2021

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}
defsq{mathbin{scalerel*{strutrule{1ex}{1ex}}{cdot}}}
begin{document}
$f$ by $bar f$ gives $bar f sq f simeq c$ for $c$ the constantdotspar
$scriptscriptstylebar f sq f simeq c$
end{document}

enter image description here

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}
defsq{mathbin{scalerel*{strutrule[-.5ex]{2ex}{2ex}}{cdot}}}
begin{document}
$f$ by $bar f$ gives $bar f sq f simeq c$ for $c$ the constantdotspar
$scriptscriptstylebar f sq f simeq c$
end{document}

enter image description here

Answered by Steven B. Segletes on January 26, 2021

You can use direct vrule with mathchoice TeX primitive.

newcountstylenum  newdimenstyledim 
defvarstyle#1{mathchoice{stylenum=0 #1}{stylenum=1 #1}{stylenum=2 #1}{stylenum=3 #1}}
defmathaxis{fontdimen22ifcasestylenum 
   textfontortextfontorscriptfontorscriptscriptfontfi2 }
defsetstyledim{styledim=ifcasestylenum .1emor.1emor.07emor.05emfirelax}

defsqdot{mathbin{varstyle{raisemathaxishbox{setstyledim
       kernstyledim 
       vrule width1.2styledim height.6styledim depth.6styledim
       kernstyledim}}}}

$fsqdot g, fcdot g, scriptstyle fsqdot g, fcdot g$

bye

Answered by wipet on January 26, 2021

Unicode-math fonts typically include the character smblksquare. If you have loaded such font then you can type:

$amathbinsmblksquare b$

or define

defsmallsquare{mathbinsmblksquare}

The result (when latinmodern-math.otf is loaded) looks like this:

small square

Answered by wipet on January 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP