3

How to make a symbol like Unicode Character 'WHITE VERTICAL RECTANGLE' (U+25AF) in LaTeX?

I tried this:

\documentclass{article}
\usepackage{stix}
\begin{document}
$a \vrectangle b $
\end{document}

– it works, but makes my PDF change its look entirely (which is uglier than usual).

I also tried to adapt the \newcommand answers from this question, but failed.

Context

This symbol is needed to typeset a paper about Communicating Sequential Processes (CSP). According to my professor, this symbol is read as "fetbar" (misspelling of "fat bar") and is used to signify choice by channel. Like this:

MACHINE = (coinslot.$5 → (tea_button.press → hatch.tea → MACHINE ▭ icetea_button.press → hatch.icetea → MACHINE ) )

(But instead of horizontal white rectangle, should have a vertical one.)

2 Answers2

2

Just the first two ideas I came up with:

\documentclass{article}

\newcommand*{\vrectangleA}{{\ooalign{\lower.3ex\hbox{$\sqcup$}\cr\raise.4ex\hbox{$\sqcap$}}}}

\newcommand*{\vrectangleB}{{\setlength{\fboxsep}{0pt}\fbox{\phantom{l}}}}

\begin{document}

a \vrectangleA\ b

a \vrectangleB\ b

\end{document}

enter image description here

campa
  • 31,130
1

A version that scales in subscripts and superscripts, also changing the line thickness according to the thickness of the fraction line in the corresponding math style (which is stored in \fontdimen8 of the font in family 3).

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\providecommand{\vrectangle}{\mkern1mu\mathpalette\v@rectangle\relax\mkern1mu}
\newcommand{\v@rectangle}[2]{%
  \hbox{%begingroup
  \fboxrule=0.5\fontdimen 8
    \ifx#1\displaystyle\textfont\else
    \ifx#1\textstyle\textfont\else
    \ifx#1\scriptstyle\scriptfont\else
    \scriptscriptfont\fi\fi\fi 3
  \fboxsep=-\fboxrule
  \fbox{$\m@th#1\phantom{(}$}%
  }%\endgroup
}
\makeatother


\begin{document}

$a \vrectangle b_{\vrectangle_{\vrectangle}}$

\end{document}

Change the factor 0.5 in front of \fontdimen to suit your taste.

You may want to change the type, say by also doing

\newcommand{\bvrectangle}{\mathbin{\vrectangle}} % for a binary operation

or

\newcommand{\rvrectangle}{\mathrel{\vrectangle}} % for a binary relation

enter image description here

egreg
  • 1,121,712
  • "...according to the width of the fraction line...". Shouldn't width be thickness? – campa Dec 18 '19 at 17:43
  • @campa Yes, of course. Although the thickness can be called width. – egreg Dec 18 '19 at 17:45
  • Ah, British terminology, right? :-) I remember some remark in the booktabs documentation... – campa Dec 18 '19 at 17:47
  • Sorry to bother, but I've got a (probably dumb) question: amsmath is necessary in order to have the scalable cmex fonts, i.e. the scalable rule width, right? Without it the three boxes would have the same line thickness. If yes, it might be an important thing to mention. – campa Dec 19 '19 at 13:12
  • 1
    @campa Yes, that's completely true. But whenever math is used in a document, amsmath is very recommended. – egreg Dec 19 '19 at 14:05
  • I know, I'm a theoretical physicist ;-) – campa Dec 19 '19 at 14:06