How can I create a rectangle symbol?

This is U+25AD (▭) and available as \hrectangle in unicode-math (if using xelatex or lualatex) or stix if using pdflatex (and will be available in other font packages that cover the Unicode math blocks)

enter image description here

\documentclass{article}

\usepackage{stix}

\begin{document}

$a \hrectangle b $

\end{document}

A good occasion for \ooalign, one of the best tricks in my toolbox:

\documentclass{article}
\usepackage{amssymb}

\newcommand{\rectangle}{{%
  \ooalign{$\sqsubset\mkern3mu$\cr$\mkern3mu\sqsupset$\cr}%
}}

\begin{document}
$S(\rectangle)$
\end{document}

enter image description here

Experiment changing 3mu for different ratios between width and height.


\documentclass[12pt]{report}
\usepackage{amsmath,amssymb}
\newcommand{\rectangle}{\fboxsep0pt\fbox{\rule{1em}{0pt}\rule{0pt}{1ex}}}
\begin{document}
  $s\rectangle$

\end{document}

enter image description here

Tags:

Symbols