[Tex/LaTex] How to type in these “circle” and “square”

amssymbsymbols

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

Best Answer

\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