5

I am looking for an easy way to type in the square and the circle shown below: enter image description here

The circles are meant for operations like +,-,>,< or \neq or \geq,leq ect. So the circles should be small. But the squares should be big, because they are meant for the numbers.

I hope to have an easy way to implement them, with auto change of size when the font size changes.

I have been looking for packages that have squares and circles, but either the square are too small, or the circles are not big enough. Also I have not found a single package that can have the two shapes.

Thanks,

Chen

5
\documentclass{article}
\usepackage{scalerel,amssymb}
\def\mcirc{\mathbin{\scalerel*{\circ}{j}}}
\def\msquare{\mathord{\scalerel*{\Box}{gX}}}
\begin{document}
$47 + 5 \mcirc 54$

$47 + \msquare < 54$
\end{document}

enter image description here

...or, for a thinner circle:

\documentclass{article}
\usepackage{scalerel,amssymb}
\def\mcirc{\mathbin{\scalerel*{\bigcirc}{t}}}
\def\msquare{\mathord{\scalerel*{\Box}{gX}}}
\begin{document}
$47 + 5 \mcirc 54$

$47 + \msquare < 54$
\end{document}

enter image description here

FOLLOW UP

The OP asks about making the box "even bigger." Below, I show how to do that both vertically and horizontally. Vertically, I replace the gX in the \msquare definition with \strut, so that the \Box is scaled to the same vertical extent as a \strut. For horizontal expansion, one can use a asymmetric \scalebox to accomplish that.

\documentclass{article}
\usepackage{scalerel,amssymb,graphicx}
\def\mcirc{\mathbin{\scalerel*{\bigcirc}{t}}}
\def\msquare{\mathord{\scalebox{1.5}[1]{\scalerel*{\Box}{\strut}}}}
\begin{document}
$47 + 5 \mcirc 54$

$47 + \msquare < 54$
\end{document}

enter image description here

| improve this answer | |
  • I have been reading the document page. But I still dont understand what does the t and gX do here and how could I make the square even bigger? – Chen Stats Yu Nov 17 '15 at 19:59
  • 1
    @ChenStatsYu The t and gX are merely objects that span a certain vertical distance. The circle is scaled to the same vertical extent as a t and the box is scaled to the same vertical extent as gX. If you want the box bigger, you could replace gx with \strut and the box would scale to the vertical size of a \strut. – Steven B. Segletes Nov 17 '15 at 20:03
  • 1
    @ChenStatsYu See follow up. – Steven B. Segletes Nov 17 '15 at 20:11
6

How about using \bigcirc for the math relations, and a regular \fbox{$\phantom{..}$} for the numbers. The latter will size with the numbers:

enter image description here

\documentclass{article}
\usepackage{siunitx}

\setlength{\parindent}{0pt}% Just for this example
\setlength{\fboxsep}{.5\fboxsep}
\newcommand{\mrel}{\mathrel{\bigcirc}}% Some math relation

\begin{document}

$47 + 5 < 54$

$47 + 5 \mrel 54$

$47 + \fbox{$\phantom{5}$} < 54$

$\num{1234} + \num{56789} = \num{58023}$

$\num{1234} + \fbox{$\phantom{\num{56789}}$} = \num{58023}$

\end{document}
| improve this answer | |

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.