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
.
there is stretchable space inserted before and after any multi-line display structure
when amsmath
is used. (stretchable space is similarly inserted around single-line
displays, but they aren't as susceptible to the surrounding context.)
take a look at what appears on the following page. if there is another large multi-line
display near the top (preceded by only one or two lines of text), it isn't by default
allowed to break the display if it doesn't fit on the previous page. instead, the
stretchable gaps (around displays, before section headings, between paragraphs -- all
to a different degree) are stretched to produce a bottom-aligned page.
this isn't really what you usually want, as you have observed.
if you are willing to allow the long display on the second page to break, you can approach
this in the following ways:
- if you are willing to allow breaks in displays throughout the whole document, place
the command
\allowdisplaybreaks
in the preamble;
- if you want to be selective about where a long display breaks, insert
\displaybreak
immediately before the \\
in the display where it is to take effect.
additional possibilities are described in the amsmath
documentation (texdoc amsmath
).
another possibility is that a box of some sort (e.g. a minipage) or other large
unbreakable element appears near the top of the "second" page. the tactics for
dealing with such a situation depend on what kind of element it is.
Best Answer
Easy fix: Just surround the unary minus and plus signs in curly brackets
{
}
:The rules for binary atoms are a little special to distinguish a binary minus (
a + b
) from a unary minus (-1
). In the binary case, there is additional space around the operator, which is missing in the latter case.TeX allows to stay a binary operator, if it is surrounded by compatible context:
a + b
,4 + \int
, ... Other atoms like an open parentheses on the left prevents the binary spacing:(-9)
is set without additional spaces. However, the property of the open parentheses does not go outside the\phantom
. In this case TeX considers the whole subformula\phantom{(}
as acceptable partner for a binary minus and the spacing increases.\mathord{-}
or the shorter{-}
forces TeX to set a unary minus. The latter works, because standalone curly braces in math mode make a subformula, whose acts as\mathord
.