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}
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.
If you want an operator to respect \limits
you should use \DeclareMathOperator*
. However, this is the wrong tool for the required symbol, because it would make an operator rather than a relation symbol, with wrong spacing. Then
\newcommand{\isEquivTo}[1]{\underset{#1}{\sim}}
seems better for your needs. Note that \underset
will “know” that \sim
is a relation symbol, so it will use the right spacing around it.
\documentclass{article}
\usepackage{amsmath}
\newcommand{\isEquivTo}[1]{\underset{#1}{\sim}}
\begin{document}
\[
\sin(n) + n \isEquivTo{+\infty} n
\]
\end{document}
On the other hand, setting the subscript under the symbol won't give good results when inline; here's a better definition that uses \underset
only in display style. Look carefully at the output to see why it's better not using the \underset
form for inline formulas.
\documentclass{article}
\usepackage{amsmath}
\newcommand{\isEquivTo}[1]{%
\mathpalette\isEquivToInner{#1}%
}
\newcommand{\isEquivToInner}[2]{%
\ifx#1\displaystyle
\underset{#2}{\sim}
\else
\sim_{#2}
\fi
}
\begin{document}
some text some text some text some text some text some text some text some text
some text some text some text some text some text some text some text some text
$\displaystyle\sin(n) + n \isEquivTo{+\infty} n$
some text some text some text some text some text some text some text
some text some text some text some text some text some text some text
$\sin(n) + n \isEquivTo{+\infty} n$
some text some text some text some text some text some text some text
some text some text some text some text some text some text some text
\[
\sin(n) + n \isEquivTo{+\infty} n
\]
\end{document}
If you want a syntax like \isEquivTo_{+\infty}
, you can do it with xparse
:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\NewDocumentCommand{\isEquivTo}{e{_}}{\isEquivToA#1}
\NewDocumentCommand{\isEquivToA}{m}{%
\IfNoValueTF{#1}
{\sim}
{\mathpalette\isEquivToB{#1}}%
}
\newcommand{\isEquivToB}[2]{%
\ifx#1\displaystyle
\underset{#2}{\sim}
\else
\sim_{#2}
\fi
}
\begin{document}
Here is the command without subscript $n \isEquivTo n$
some text some text some text some text some text some text some text some text
some text some text some text some text some text some text some text some text
$\displaystyle\sin(n) + n \isEquivTo_{+\infty} n$
some text some text some text some text some text some text some text
some text some text some text some text some text some text some text
$\sin(n) + n \isEquivTo_{+\infty} n$
some text some text some text some text some text some text some text
some text some text some text some text some text some text some text
\[
\sin(n) + n \isEquivTo_{+\infty} n
\]
\end{document}
You will see that the first call just does \sim
.
Best Answer
Based on my answer at Big tilde in math mode, in introduce
\reallywidesim
and\reallywidesimeq
.