I want to replace the circle in the symbol \circledast by a square. But i did not find the right command. It seems that the packages stmaryrd would help. But the package usually re-defines other basic symbols which is not desired.

The amssymb package seems not define such a symbol. Is there anyone know how to define some command like \boxdast or \squaredast? Or how to avoid other changes by introducing packages that already defines \boxdast or \squaredast?

  • you can use a package like savesym or noconflict to avoid unwanted redefining of symbols by stmaryrd – Nico Boni Jul 3 '13 at 9:13
  • As far as I know, stmaryrd redefines no symbol in the standard stock. Can you show an example? – egreg Jul 3 '13 at 9:18
  • As egreg says stmaryrd does not clash with standard latex symbols nor amssymb. stmaryrd has \boxast already. Alternatively mathabx has \boxasterisk and \boxcoasterisk and \bigboxasterisk – Andrew Swann Jul 3 '13 at 9:24
  • @egreg I got one mistake; you are correct, stmaryrd does not casue any confusion. Thanks. – Richie Jul 3 '13 at 16:30

The following example composes \boxast from \Box and * and only needs package amssymb because of \Box:


  \mathbin{% as \boxplus and \boxtimes
  % #1: math style (\displaystyle, \textstyle, ...)
  % #2: symbol to be boxed that is centered around the math axis
  % Manual correction for font bounding boxes:
  \ifx#1\displaystyle \ht0=\dimexpr\ht0+.05ex\relax \fi
  \ifx#1\textstyle \ht0=\dimexpr\ht0+.05ex\relax \fi
  \ifx#1\scriptstyle \ht0=\dimexpr\ht0+.04ex\relax \fi
  \ifx#1\scriptscriptstyle \ht0=\dimexpr\ht0+.065ex\relax \fi
  \sbox2{$#1\vcenter{}$}% \ht2 is positionn of math axis
    \hbox to \wd0{%

$A \boxplus B \boxast C^{D \boxast E^{F \boxast G}}$



  • Macro \@boxit assumes that the symbol to be boxed is centered around the math axis as some of the typical boxed symbols are (plus, minus, times, ast). Then the symbol is placed in the middle of the box. (There might be tiny deviations because glyph side bearings are not taken into account.)

  • The reason for \mathpalette is to get the actual math style in order to match the size of the symbol according to the current math style.

  • \m@th removes \mathsurround, because it should add space around the formula, not within, if \mathsurround is set.

  • Update: The font bounding box of \Box is a little too small in the height, therefore I have added a manual correction.

    The following file shows the font bounding boxes for \Box, first the unmodified font bounding box (red), then the corrected bounding box (green). (The larger width of the font bounding box does not matter, because the white space left and right seems to be the same and the symbol remains centered.)

      \fbox{\color{red}$\csname #1style\endcsname\Box$}%
        $\csname #1style\endcsname\Box$%
        \vphantom{\raisebox{#2}{$\csname #1style\endcsname\Box$}}%
      \fbox{\color{blue}$\csname #1style\endcsname\Box$}%

Font bounding boxes

  • It appears to me that the asterisks in the last box is not centered, i.e. in F \boxast G. Any idea what is causing that? A very nice solution though :-) – Mythio Jul 3 '13 at 11:15
  • @Mythio: There was an calculation error: -\dp0 instead of +\dp0, but \dp0 is 0.0pt, thus this had no impact on the result. The font bounding boxes however, are not entirely correct, see the updated answer. – Heiko Oberdiek Jul 3 '13 at 19:24

You could use Tikz to accomplish this.

Something like the following, which declares the command \boxast.


      \node [rectangle,scale=1,draw] {$\ast$};
And it looks like: $\boxast$

Which gives this as result:

enter image description here

I left the scale option in there, because you can use that the tweak the size a bit. For instance, try scale=0.7 to make it approximately the same height as the text. It depends a bit on how you want to use the symbol exactly.

  • 1
    Why \ensuremath in the command? Also it doesn't take an argument. And you don't need PGF package if you have TikZ and you don't need positioning for this too :) – percusse Jul 3 '13 at 9:09
  • @percusse; Thank you :-) The trouble of reusing code that I reused myself before for other commands. I've changed it. – Mythio Jul 3 '13 at 9:12

Here's a way (without tikz) that is quite brief (shown with super- and supersuperscript). The size of the box symbol will be scaled to the current size of a capital "B", regardless of what script mode you are in.

To explain the use of the packages, the asterisk is inset into the box via the stackengine package. The bottom (dead zone) of the box is clipped with \addvbuffer of the verbatimbox package, and the resulting symbol is scaled to the size of a capital B by way of the scalerel package.

\sbox\boxastcontent{\addvbuffer[0ex -.4ex]{\topinset{*}{$\Box$}{.25ex}{}}}
\(A\boxast B^{A\boxast B^{A \boxast B}}\)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.