An accented symbol is treated by TeX as an ordinary one; you have to tell it that you want a relation symbol:
\( w_{1} \mathrel{\tilde{\in}} w_{2} \)
The commands for declaring a math symbol are
\mathord
(ordinary)
\mathbin
(binary operation)
\mathrel
(binary relation)
\mathop
(operator, use with care)
An ordinary symbol is typeset without any spacing around it. A binary operation is something like +
; for example, if one wanted to define a "mod" operation, a correct way would be
\newcommand{\bmod}{\mathbin{\textrm{mod}}}
(amsmath does it in a quite different way, but that's not the point). A binary relation is like <
; the spacing around binary relation symbols is larger than around operation symbols. Moreover the space around relation symbols is uncompressible, while it is for operations.
As already said, putting an accent over a symbol makes it lose its predefined nature: the accented cluster is considered as an ordinary symbol; therefore we have to state explicitly its nature.
The next example only adds some boxes to make the spacing more visible:
\documentclass{article}
\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{.1pt}
\begin{document}
$\fbox{$\fbox{$u$}^{\fbox{$\scriptstyle*$}}$}\mathpunct{\fbox{$,$}}\fbox{$x$}$
\end{document}
The spacing between the superscript *
and the comma ,
has three causes:
- TeX adds
\scriptspace
after super- and subscripts. Default is 0.5pt
in LaTeX and plain TeX. It is the space between the box around *
and the surrounding box.
- Inside the boxes for
*
and ,
there is some horizontal padding, called side bearings. It is a font property and not accessible in TeX.
- The superscript and the comma have quite a large vertical distance, thus there is no need to have much horizontal space to avoid the glyphs to get too close. It looks indeed better, if the comma is moved leftwards.
However, caution is needed for the negative spacing, LaTeX defines (pseudo code):
\! = \mskip-\thinmuskip
\thinmuskip = 3mu
\medmuskip = 4mu plus 2mu minus 4mu
\thickmuskip = 5mu plus 5mu
and package amsmath
adds (pseudo code):
\negmedspace = -\medmuskip
\negthickspace = -\thickmuskip
\thinmuskip
and therefore \!
are not using stretchability. However, the others are. Then the spacing can become quite ugly, if stretching/shrinking is applied.
The negative sign causes the opposite effect making the spacing worse:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\hbox{$u^*\negmedspace,x+y$}
\hbox spread -5pt{$u^*\negmedspace,x+y$}
\hbox spread 5pt{$u^*\negmedspace,x+y$}
\end{document}
For this, \!
can be used. However, \negthickspace
and \negmedspace
should be avoided, they cancel the effect of \thickmuskip
and \thinmuskip
.
\negthickspace
and \negmedspace
The following macros \negmed
and \negthick
add a negative space in math mode using the values from \medmuskip
and \thickmuskip
without the stretch and shrink components:
\def\negstrip#1 #2\relax{-#1}
\newcommand*{\negmed}{%
\mkern-\medmuskip
}
\newcommand*{\negthick}{%
\mkern-\thickmuskip
}
The question, how much negative spacing could be used is also partly a matter of taste. I tend to something inbetween \!
and \negmed
, perhaps \mkern-3.5mu\relax
.
Best Answer
Spacing around operators and relations in math mode are governed by specific skip lengths:
\thinmuskip
(default is3mu
),\medmuskip
(default is4mu plus 2mu minus 4mu
) and\thickmuskip
(default is5mu plus 5mu
). All are given inm
athu
nits.Here is an illustration of how a modification (setting them to
0mu
) to these lengths affect the output (I've removed the forced space after\times
):Grouping (
\begingroup
...\endgroup
) localizes the effect of the length modification.\medmuskip
is used around binary operators (like\times
) and\thickmuskip
is used around binary relations (like=
). It's best to stick to the standard LaTeX spacing rather that insert your own.A good source of reading material on this is Herbert Voss' mathmode document. In particular, section 11 Space (p 28 onward).
Inline math forms part of the regular text construction. That's why there is some stretch in
\medmuskip
and\thickmuskip
, which allows spacing around math operators/operands to change depending on their location within the paragraph text. Removing this glue allows for a more consistent setting of inline expressions. See Keeping the distance between mathematical symbols consistent?However, it can also have some problematic effects with regards to line breaking, as is shown below: