9

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

6

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.

  • See tex.stackexchange.com/questions/343599/…. It works if the joining macro is redefined to take an argument (or if you give it something else to eat like an x). But I have no idea if this is wise .... It looks OK, but that's not much to go by. I've answered because it looks like a reasonable workaround, but .... – cfr Dec 12 '16 at 4:18
2

I made this for our students how need a similar symbol for statistics

\newcommand\DistTo{\xrightarrow{
   \,\smash{\raisebox{-0.65ex}{\ensuremath{\scriptstyle\sim}}}\,}}

enter image description here

  • Thanks, but this still has the arrowhead! – user573 Jun 27 '13 at 14:15
  • Sorry, didn't read the question correctly. Though I think the placement is better than just using \stackrel, try combining them – daleif Jun 27 '13 at 14:24
2

Combining some ideas from the answers of @Ian Thompson and @daleif, I think the following is pretty good.

\newcommand{\iso}{\ \raisebox{0.5ex}{\ensuremath{\stackrel{\sim}{\rule{16pt}{0.7pt}}}\ \,}}

enter image description here

  • 1
    the rule looks a bit too thick, and the \sim is a bit farther from the rule (or arrow) than one might like. – barbara beeton Jun 27 '13 at 16:16
1

Try this.

\documentclass{article}
\begin{document}
\[
A \stackrel{\displaystyle\sim}{\smash{\rule[1.5pt]{2em}{0.5pt}}} B
\]
\end{document}

Adjust the parameters as required. You can use \raisebox to raise the whole symbol.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\[
A \raisebox{0pt}{$\stackrel{\displaystyle\sim}{\smash{\rule[1.5pt]{2em}{0.5pt}}}$} B
\]
\end{document}
  • Thanks. \textwidth is way too wide, about 16pt seems to be the same size as \longrightarrow. However, the vertical position is too low. See this picture: i.imgur.com/2qPcqUl.png – user573 Jun 27 '13 at 14:01
  • @Adeel --- I have edited my answer to allow vertical adjustment. – Ian Thompson Jun 27 '13 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy