[Tex/LaTex] How to typeset an isomorphism symbol ($\simeq$) with a long bar

math-modemath-operatorsstacking-symbolssymbols

Is there any way to typeset in LaTeX a \simeq with a longer bar, or equivalently \stackrel{\sim}{\longrightarrow} without the arrowhead?

Best Answer

The following constructs the math symbol \isomorphism similar to \simeq, but with a longer line:

\documentclass{article}

\makeatletter
\newcommand*{\isomorphism}{%
  \mathrel{%
    \mathpalette\@isomorphism{}%
  }%
}
\newcommand*{\@isomorphism}[2]{%
  % Calculate the amount of moving \sim up as in \simeq
  \sbox0{$#1\simeq$}%
  \sbox2{$#1\sim$}%
  \dimen@=\ht0 %
  \advance\dimen@ by -\ht2 %
  %
  % Compose the two symbols
  \sbox0{%
    \lower1.9\dimen@\hbox{%
      $\m@th#1\relbar\isomorphism@joinrel\relbar$%
    }%
  }%
  \rlap{%
    \hbox to \wd0{%
      \hfill\raise\dimen@\hbox{$\m@th#1\sim$}\hfill
    }%
  }%
  \copy0 %
}
\newcommand*{\isomorphism@joinrel}{%
  \mathrel{%
    \mkern-3.4mu %
    \mkern-1mu %
    \nonscript\mkern1mu %
  }%
}
\makeatother

\begin{document}
\[ A \isomorphism B \simeq C = D \sim E \]
\[ A \isomorphism B^{C \isomorphism D^{E \isomorphism F}} \]
\end{document}

Result

Remarks:

  • The line is constructed similar to \longrightarrow. There a line \relbar is joined a \rightarrow. The joining removes the side bearings, which means the glyphs can have white margins at the left and the right. LaTeX's \joinrel adds a negative space of 3mu to move the relational symbols together. The test file uses the symbol in smaller math styles, there -3mu leaves a gap, therefore \isomorphism@joinrel is defined with customized settings (-3.4mu for \displaystyle and \textstyle, -4.4mu for scriptstyle and \scriptscriptstyle).

  • The symbol \sim is horizontally centered and set in the same math style and size. It is raised to the same height as aymbol \simeq.

  • The vertical position of the line in \simeq is unhappily not available in TeX, therefore a guessed value is used (the shift of \sim multiplied by 1.9). If you want the line a little higher, then you can decrease the factor.

  • \mathpalette is used to support the symbol in all math styles. Then the internal macro \@isomorphism gets the math style (\displaystyle, \textstyle, \scriptstyle, \scriptscriptstyle) as first argument. The second argument is not used and left empty.

  • The measuring and glyph composing is done with many low level plain TeX macros for efficiency (and fun).

  • \m@th sets \mathsurround to 0pt. Usually the value is 0pt, but if set, then the space that should surround math expressions should not occur inside a formula or math symbol.