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.

As a follow-up to Why is \[ ... \] preferable to $$?, what really is wrong with the vertical spacing as stated in l2tabu introduced by using $$...$$ instead of \[...\]?

As there does not seem to be an elaboration of this in l2tabu except for the remark that vertical spacing is modified and rendered inconsistent, illustrative examples comparing the different outputs would be appreciated.

share|improve this question
5  
Since the bigger problem with $$...$$ is that it won't work with anything that modifies displayed math (e.g. the [fleqn] option) how important is it to worry about the vertical spacing issue? –  Alan Munn Jun 20 '11 at 3:43
1  
possible duplicate of Why is \[ ... \] preferable to $$?. Arg. I didn't see that you already cited this question. I am sleepy. –  Lev Bishop Jun 20 '11 at 4:47
5  
I think this is a fine question and you got a good answer to it. –  TH. Jun 20 '11 at 10:21
add comment

2 Answers

up vote 10 down vote accepted

You should avoid empty lines before and after displayed equations. Compare:

\documentclass[twocolumn,a5paper,12pt]{article}
\begin{document}

Equation using \LaTeX\ notation
%
\[ y = x^{2} \]
%
Equation using \TeX\ notation
%
$$ y = x^{2} $$
%
end of the part without empty lines\newpage

Equation using \LaTeX\ notation

\[ y = x^{2} \]

Equation using \TeX\ notation

$$ y = x^{2} $$

end of the part with empty lines
\end{document}

...

share|improve this answer
1  
in this case there is no difference. But as already mentioned in some other cases there will be a difference. –  Herbert Jun 21 '11 at 7:00
    
"You should avoid empty lines before and after displayed equations." Is this advice intended strictly, or is it acceptable to skip a line after a displayed equation if you actually want to start a new paragraph? –  Charles Staats Aug 20 '12 at 22:46
add comment

The only difference as far as spacing is concerned is that \[...\] will use \abovedisplayskip and \belowdisplayskip instead of \abovedisplayshortskip and \belowdisplayshortskip that would be used by $$...$$ in case the math display is started in vertical mode. The code

\setbox0=\vbox{\hrule height 0pt % to avoid gobbling vskips
\[a=b\]
A word.}
\showthe\ht0

\setbox0=\vbox{\hrule height 0pt % to avoid gobbling vskips
$$a=b$$
A word.}
\showthe\ht0
\showthe\abovedisplayskip
\showthe\belowdisplayskip
\showthe\abovedisplayshortskip
\showthe\belowdisplayshortskip

will give the following information:

?
> 44.0pt.
l.27 \showthe\ht0

? 
> 30.0pt.
l.32 \showthe\ht0

? 
> 10.0pt plus 2.0pt minus 5.0pt.
l.33 \showthe\abovedisplayskip

? 
> 10.0pt plus 2.0pt minus 5.0pt.
l.34 \showthe\belowdisplayskip

? 
> 0.0pt plus 3.0pt.
l.35 \showthe\abovedisplayshortskip

? 
> 6.0pt plus 3.0pt minus 3.0pt.
l.36 \showthe\belowdisplayshortskip

The 14pt difference is exactly the result of (10+10)-(0+6). Actually the \hrule height 0pt here does almost nothing because of \abovedisplayshortskip=0pt.

This doesn't happen when amsmath is loaded (the "short" skips are used in this case).

The definition of \[ in the LaTeX kernel is

\def\[{%
\relax\ifmmode
  \@badmath
\else
  \ifvmode
    \nointerlineskip\makebox[.6\linewidth]{}
  \fi
  $$
\fi}

that explains why the "non short" skips are used at the beginning of a paragraph: the LaTeX kernel starts a paragraph with an empty line long enough to prevent the use of the "short" skips. I believe that this has been added by Lamport to cope with authors that leave an empty line before \[.

share|improve this answer
    
Seems like a better choice for Lamport would have been to just make \abovedisplayshortskip equal to \abovedisplayskip. –  TH. Jun 20 '11 at 10:20
    
@TH I'd say no: when the document is properly written, the settings are good. Setting the "short" skip equal to the "normal" one would be wrong, causing a big hole when the line preceding the paragraph is short. –  egreg Jun 20 '11 at 10:55
    
@TH: I'd also say no, for the same reasons. @egreg: Does your answer mean that the accepted answer to the question behind the link in the OP is wrong? (By the way, I do agree with your comment, but I think the implementation of \belowdisplayshortskip is rather strange.) –  Hendrik Vogt Jun 20 '11 at 17:07
1  
@Hendrik: it's not wrong, but incomplete. The real reason why $$ should not be used is that it hinders LaTeX (and amsmath) in doing what they should do to displays. –  egreg Jun 20 '11 at 20:24
1  
@Jasper: with amsmath the two vboxes would give the same result; but using $$ with amsmath can break many other things. –  egreg Jun 20 '11 at 23:45
show 3 more comments

Your Answer

 
discard

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