[Tex/LaTex] How to get bigsqcap in the right size

fontsmath-modesymbols

I would like to use the upside-down version of \bigsqcup to denote its dual operation.
The stmaryrd package provides that symbol, \bigsqcap, but I have found that these two symbols are rendered in different sizes.

Below are sample code and its output.

\documentclass[12pt]{article}
\usepackage{mathptmx}
\usepackage{stmaryrd}
\begin{document}
$\bigsqcup \bigsqcap \bigcup \bigcap$
\end{document}

enter image description here

As you can see, \bigsqcap is clearly the odd one out, being slightly bigger than the rest.

Does anyone know how to get \bigsqcap in the same size as \bigsqcup?
I need to use the mathptmx font, so I would appreciate a solution that retains it.

Best Answer

A simple solution is to rotate \bigsqcup to get the missing \bigsqcap:

\documentclass[12pt]{article}
\usepackage{mathptmx}

\usepackage{graphicx}
\makeatletter
\providecommand{\bigsqcap}{%
  \mathop{%
    \mathpalette\@updown\bigsqcup
  }%
}
\newcommand*{\@updown}[2]{%
  \rotatebox[origin=c]{180}{$\m@th#1#2$}%
}
\makeatother

\begin{document}
\[\bigsqcup \bigsqcap \bigcup \bigcap\]
\[X\bigsqcup_0^\infty Y \bigsqcap_0^\infty Z\]
\[\bigsqcup\textstyle\bigsqcup
  \scriptstyle\bigsqcup\scriptscriptstyle\bigsqcup\]
\[\bigsqcup\textstyle\bigsqcap
  \scriptstyle\bigsqcap\scriptscriptstyle\bigsqcap\]
\end{document}

Result

Remarks:

  • The rotation switches to text mode (\hbox). \mathpalette is the method to get the current math style that we need, when we reenter math in the rotated box for \bigsqcup. The first argument of \@updown is the math style (\displaystyle, \textstyle, …), the second argument is the unrotated symbol. Thus \@updown can also be used for the rotation of other symbols.

  • \m@th suppresses \mathsurround for the case this value is set to avoid that space that should surround math formulas appears inside the formula.