Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the last time I used TikZ and i was a bit surprised in the spacing in some nodes,

\documentclass{standalone}
\begin{document}
$-\alpha \qquad 
 {}-\alpha \qquad 
 \underbrace{\alpha}\cdot \omega \qquad 
 \underbrace{\alpha} {} \cdot \omega$
\end{document} 

which gives me

enter image description here

where the second solution is the wanted solution. David mentioned in chat that the {} makes it to a binary expression which gives me an infix spacing. But I am still a bit confused about the following, why does

{\underbrace{\alpha}}\cdot \omega

gives the same as

\underbrace{\alpha} {} \cdot \omega

but

\underbrace{\alpha} \cdot \omega

gives a different spacing.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

egreg beat me to the post with the answer but one thing I was going to mention is debugging aids for that kind of thing. If you modify your MWE to

\documentclass{standalone}
\begin{document}
\showboxdepth1
\showboxbreadth100
\tracingonline1
$-\alpha \qquad 
 -{} \alpha \qquad 
 \underbrace{\alpha}\cdot \omega \qquad 
 \underbrace{\alpha} {} \cdot \omega
\showlists$
\end{document} 

You see in the log

### math mode entered at line 6
\mathbin
.\fam2 ^^@
\mathord
.\fam1 
\glue 20.00003
\mathbin
.\fam2 ^^@
\mathord
.{}
\mathord
.\fam1 
\glue 20.00003
\mathop\limits
.\vbox(4.30554+7.19997)x18.00018 []
\mathbin
.\fam2 ^^A
\mathord
.\fam1 !
\glue 20.00003
\mathop\limits
.\vbox(4.30554+7.19997)x18.00018 []
\mathord
.{}
\mathbin
.\fam2 ^^A
\mathord
.\fam1 !
### restricted horizontal mode entered at line 2

which tells you the mathbin mathop etc status of each atom in your math list.

share|improve this answer
add comment

A {} in math mode inserts an (empty) ordinary atom, which can influence the spacing. Let's see how.

$ - \alpha {} - \alpha \underbrace{\alpha} \cdot 
  \omega \underbrace{\alpha} {} \cdot \omega $

Note that the \quad spaces don't influence the automatic math spacings, so we can disregard them. This becomes the following sequence of atoms:

Bin Ord Ord Bin Ord Op Bin Ord Op Ord Bin Ord

and two "Bin" atoms are transformed into "Ord" because they're not between two atoms which they can operate on. Indeed the \underbrace macro creates an Op atom:

\def\underbrace#1{\mathop{\vtop{\m@th\ialign{##\crcr
   $\hfil\displaystyle{#1}\hfil$\crcr
   \noalign{\kern3\p@\nointerlineskip}%
   \upbracefill\crcr\noalign{\kern3\p@}}}}\limits}

Thus the spacings are those dictated by the rules:

{Bin} 0 Ord 0 Ord 2 Bin 2 Ord 1 Op 1 {Bin} 0 Ord 1 Op 1 Ord 2 Bin 2 Ord

where {Bin} means a Bin atom transformed into Ord, 0 is no space, 1 is thin space and 2 is medium space.

Let's see your final examples:

  1. ${\underbrace{\alpha}}\cdot \omega$
    This is "Ord Bin Ord", because the braces around the Op atom transform it into an Ord one.

    Ord 2 Bin 2 Ord

  2. $\underbrace{\alpha} {} \cdot \omega$
    This is "Op Ord Bin Ord", so we get a thin space after the Op, a medium space after the Ord and a medium space after the Bin:

    Op 1 Ord 2 Bin 2 Ord"

  3. $\underbrace{\alpha} \cdot \omega$
    This is a bit harder. We have "Op Bin Ord", but the Bin becomes Ord for spacing purposes, because it's similar to $\log+2$. So we get a thin space after the underbraced alpha and no space between \cdot and \omega.

    Op 1 {Bin} 0 Ord

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.