I have a command \newcommand{\shuprod}{\sqcup \hspace{-.137cm} \sqcup \;} that looks good most of the time (i.e. in big equations), but is sometimes "compressed" when inside text.
How do I force it to always be the same size ?
I have a command \newcommand{\shuprod}{\sqcup \hspace{-.137cm} \sqcup \;} that looks good most of the time (i.e. in big equations), but is sometimes "compressed" when inside text.
How do I force it to always be the same size ?
When TeX constructs a line it can scretch some horizontal dimensions, even those between your two \sqcups which both still act as binary symbols.
I propose the following change:
\newcommand{\shuprod}{\mathbin{{\sqcup}\mspace{-3mu}{\sqcup}}}
\mathbin to have the new construction act as one binary symbol.{\sqcup} to disable the symbol acting as a binary symbol.\mkern-3mu (or \mspace{-3mu} with amsmath) instead of \hspace to make the spacing dependent of the font size.This still doesn't solve the spacing when used in a different math-style.
For this, you can use \mathchoice to specify the space for the different math styles.
\newcommand{\shuprod}{\mathbin{{\sqcup}\mathchoice{\mspace{-3mu}}
{\mspace{-3mu}}
{\mspace{-3mu}}
{\mspace{-4mu}}{\sqcup}}}
Of course, these values are font-dependent.
\documentclass{article}
\usepackage{amsmath}
%\newcommand{\shuprod}{\mathbin{{\sqcup}\mspace{-3mu}{\sqcup}}}
\newcommand{\Shuprod}{\sqcup \hspace{-.137cm} \sqcup \;} % do not use
\newcommand{\shuprod}{\mathbin{{\sqcup}\mathchoice{\mspace{-3mu}}
{\mspace{-3mu}}
{\mspace{-3mu}}
{\mspace{-4mu}}{\sqcup}}}
\begin{document}
( \displaystyle A \sqcup B )
( A \sqcup B )
( {}{A \sqcup B} )
( {}{{}_{A \sqcup B}} )
( \displaystyle A \shuprod B )
( A \shuprod B )
( {}{A \shuprod B} )
( {}{{}_{A \shuprod B}} )
Abca Abca Abca Abca Abca Abca Abca Abca Abca Abca Abca Abca $ a \shuprod b $
Abca Abca Abca Abca Abca Abca Abca Abca Abca
Abca Abca Abca Abca Abca Abca Abca Abca Abca Abca Abca Abca $ a \Shuprod b $
Abca Abca Abca Abca Abca Abca Abca Abca Abca
\Huge
$ a \shuprod b $\par
Abca Abca Abca Abca Abca Abca Abca Abca Abca Abca Abc $ a \shuprod b $
$ a \Shuprod b $\par
Abca Abca Abca Abca Abca Abca Abca Abca Abca Abca Abc $ a \Shuprod b $ %‽
\end{document}
There is the shuffle package that provides the symbol, but only in bitmap format.
However, since this is a simple symbol like \sqcup, it's not difficult to draw it manually.
In the following, the height of the symbol is the same as of \sqcup, but the width is not double, because it seems too much.
\documentclass{article}
\usepackage{amsmath}
\usepackage{pict2e}
\makeatletter
\newcommand{\shuprod}{\mathbin{\mathpalette\shuprod@\relax}}
\newcommand{\shuprod@}[2]{%
\begingroup
\setlength{\dimen@}{\shuprod@width{#1}}%
\sbox\z@{$\m@th#1\sqcup$}%
\setlength{\unitlength}{\wd\z@}%
\raisebox{0.5\dimen@}{%
\begin{picture}(1.5,0.805)
\linethickness{\dimen@}%
\roundcap\roundjoin
\polyline(0.12,0.84)(0.12,0)(1.38,0)(1.38,0.84)
\Line(0.75,0)(0.75,0.84)
\end{picture}%
}%
\endgroup
}
\newcommand{\shuprod@width}[1]{%
\ifx#1\displaystyle \fontdimen8\textfont\else
\ifx#1\textstyle \fontdimen8\textfont\else
\ifx#1\scriptstyle 1.1\fontdimen8\scriptfont\else
1.25\fontdimen8\scriptscriptfont\fi\fi\fi 3
}
\makeatother
\begin{document}
$A\shuprod B$
$\shuprod \scriptstyle \shuprod \scriptscriptstyle \shuprod$
$\sqcup \scriptstyle \sqcup \scriptscriptstyle \sqcup$
\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{0.1pt}
\fbox{$\sqcup$}\fbox{$\shuprod$}
\end{document}
\newcommand{\shuprod}{\mathrel{{\sqcup}\mkern-3mu{\sqcup}}}is possibly a safer definition. TeX scretches some horizontal space so that text fits better on a line. This also happens between the\sqcups. How are you using your command? If the font changes, the value-.137cmwon't be right anymore. – Qrrbrbirlbel Dec 10 '22 at 17:04-.38embut tried withcmthinking it would fix the length. – Louis-Amand Dec 10 '22 at 17:12