6

I want to ask for something similar to Horizontal lines in \sqcup and \sqcap

But instead of the alignment asked in that question, I want the horizontal line to align vertically to a minus sign and the new symbol's spacing equal to a regular \sqcap's spacing, like this

enter image description here.

And if possible, I would also like to ask for a big version of this operator whose dimensions are the same as the dimensions of \bigsqcup.

FR09
  • 147

2 Answers2

7

You can overlap the \sqcap and minus with \ooalign. The mismatch in width can be cured by shrinking the minus sign only in the horizontal direction. For the “big” version, the same idea is used, but the minus sign is also stretched vertically to match the thickness (it maybe requires a different factor in scriptstyle, though).

\documentclass{article}
\usepackage{amsmath,stmaryrd,graphicx}

\makeatletter \newcommand{\semisqcap}{\mathbin{\mathpalette\semisqcap@\relax}} \newcommand{\semisqcap@}[2]{% \begingroup\m@th \sbox\z@{$#1\sqcap$}% \ooalign{\hidewidth\resizebox{\wd\z@}{\height}{$#1-$}\hidewidth\cr$#1\sqcap$\cr}% \endgroup }

\newcommand{\bigsemisqcap}{\DOTSB\mathop{\mathpalette\bigsemisqcap@\relax}\slimits@} \newcommand{\bigsemisqcap@}[2]{% \begingroup\m@th \sbox\z@{$#1\bigsqcap$}% \ooalign{\hidewidth\semisqbar@{#1}\hidewidth\cr$#1\bigsqcap$\cr}% \vphantom{\box\z@}% \endgroup } \newcommand{\semisqbar@}[1]{% \raisebox{-0.25\height}{\resizebox{\wd\z@}{2\height}{$#1-$}}% } \makeatother

\begin{document}

\begin{gather} a\semisqcap b \quad\scriptstyle a\semisqcap b \ a\sqcap b \quad\scriptstyle a\sqcap b \ \bigsemisqcap_{i=1}^n a_i \bigsqcap_{i=1}^n a_i \ \bigsemisqcap_{i=1}^n a_i \bigsqcap_{i=1}^n a_i \ \textstyle\bigsemisqcap_{i=1}^n a_i \bigsqcap_{i=1}^n a_i \ \scriptstyle\bigsemisqcap_{i=1}^n a_i \bigsqcap_{i=1}^n a_i \end{gather}

\end{document}

enter image description here

egreg
  • 1,121,712
  • Thank you, this is exactly what I want! However, I had a problem applying this to \bigsemisqcap using \newcommand{\bigsemisqcap}{\mathop{\mathpalette\bigsemisqcap@\relax}\slimits@} with \ooalign{\hidewidth\resizebox{\wd\z@}{\height}{$#1-$}\hidewidth\cr$#1\bigsqcap$\cr}%. The thickness of the minus sign appears to be a lot thinner than the thickness of the cap. Do you know how I can scale the minus sign to make its thickness equal to the thickness of the cap? – FR09 Jan 02 '21 at 08:24
  • @FR09 The new version deals with it. – egreg Jan 02 '21 at 10:49
3

You can literally take the answer you link to, and change a few values.

\documentclass{article}
\usepackage{amsmath}
\usepackage{scalerel}
\def\widen{\mathrel{\ThisStyle{\stretchrel*{\ooalign{%
  \raise0.45\LMex\hbox{$\SavedStyle\sqcup$}\cr%
  \raise-0.45\LMex\hbox{$\SavedStyle\sqcup$}}}{\sqcup}}}}
\def\narrow{\mathrel{\ThisStyle{\stretchrel*{\ooalign{%
  \raise0.75\LMex\hbox{$\SavedStyle\sqcap$}\cr%
  \raise-0.75\LMex\hbox{$\SavedStyle\sqcap$}}}{\sqcap}}}}
\def\Widen{\mathrel{\ThisStyle{\stretchrel*{\ooalign{%
  \raise0.6\LMex\hbox{$\SavedStyle\sqcup$}\cr%
  \raise-0.6\LMex\hbox{$\SavedStyle\sqcup$}}}{\bigsqcup}}}}

\begin{document} $a -\widen b \quad\scriptstyle a -\widen b \quad\scriptscriptstyle a -\widen b$

$a -\narrow b \quad\scriptstyle a -\narrow b \quad\scriptscriptstyle a -\narrow b$

$a -\Widen b \quad\scriptstyle a -\Widen b \quad\scriptscriptstyle a -\Widen b$

\end{document}

enter image description here

  • Thank you for your help. Though with this approach, there are gaps between the cups, and the alignment is not exact. I thought about using something like \newcommand{\semisqcap}{\sqcap\kern-0.95em{-}} but the minus sign is a bit too long, and the horizontal spacing is smaller on the right side. – FR09 Jan 01 '21 at 10:05