[Tex/LaTex] Create symbol out of given symbols with same line width

symbols

I'm trying to create a new symbol out of a given one $\sqcup$ but it does not work as expected. Have a look at the following minimal example:

\documentclass{article}

\usepackage{graphicx}

\newcommand{\sqqcup}{\,{{\sqcup}\hspace*{-0.6em}\raisebox{-0.25ex}{--}}\;}

\begin{document}
\[
\scalebox{8}{$a \sqqcup b$}
\]
\end{document}

As you can see the extra horizontal line I'm trying to put over the squared cup symbol is not typeset in the same line width/strength.

Has someone an idea how to draw a line with the same line width than an already existing symbol?

Best Answer

Basically you have to just do it by eye, as you have done. TeX has no information about the line widths (or the shape of the glyph at all). Even if you look in to the type1 or metafont sources of the font and find out the original design widths, you can not ensure at small sizes that you get exactly the same width using a rule, as the lines in the font are subject to the renderer's font hinting mechanism which may snap the lines on to pixel boundaries, whereas rules are drawn by different mechanisms and not subject to the same hinting.

You might do better just offsetting the same character so the rules are subject to the same hinting:

enter image description here

\documentclass{article}

\usepackage{graphicx}

\newcommand{\sqqcup}{\,{{\sqcup}\hspace*{-0.6em}\raisebox{-0.25ex}{--}}\;}


\def\xsqqcupb#1#2{\mathbin{\rlap{\raisebox{.15em}{$#1#2$}}{#2}}}
\def\sqqcupb{\mathpalette\xsqqcupb\sqcup}

\begin{document}
\[
\scalebox{8}{$a \sqqcup b$}
\]
\[
\scalebox{8}{$a \sqqcupb b$}
\]
\end{document}

Update:

As discussed in the comments it would be possible to hide the extra height with a coloured rule, but beware that the colour may hide more than you intend 9note the top bar of the fbox in the modified example)

enter image description here

\documentclass{article}

\usepackage{graphicx,color}

\newcommand{\sqqcup}{\,{{\sqcup}\hspace*{-0.6em}\raisebox{-0.25ex}{--}}\;}


\def\xsqqcupb#1#2{\rlap{\raisebox{.15em}{$#1#2$}}{#2}}
\def\sqqcupb{\mathbin{\mathpalette\xsqqcupb\sqcup}}

\def\xsqqcupc#1#2{\smash{\rlap{\raisebox{.15em}{$#1#2$}}\rlap{\color{white}\rule[.3em]{0.7em}{1.1ex}}}{#2}}
\def\sqqcupc{\mathbin{\mathpalette\xsqqcupc\sqcup}}


\begin{document}

\fbox{\scalebox{8}{$a \sqqcup x$}}

\bigskip

\fbox{\scalebox{8}{$a \sqqcupb x$}}

\bigskip

\fbox{\scalebox{8}{$a \sqqcupc x$}}

\end{document}
Related Question