7

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

2 Answers 2

7
\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

3
  • 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? Nov 17, 2015 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. Nov 17, 2015 at 20:03
  • 1
    @ChenStatsYu See follow up. Nov 17, 2015 at 20:11
8

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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .