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.

I think this is a tough one. Have you ever wondered why TeX sometimes produces vertical spacing around equations that is far from satisfactory? An example:

\documentclass{article}
\setlength{\textheight}{2.93cm}
\begin{document}
A short line,
\[ a = b_{11}^2 b_{12}^2 b_{13}^2 b_{14}^2, \]
a long line containing superscripts $\delta^{22}\beta^{22}$,
almost touching the above formula,
\[ c = d, \]
and another short line,
\[ e = f. \]
\end{document}

produces

alt text

In my opinion, the vertical space after the first display is much too small, whereas after the second one it's too large.

Before I ask the question, I'd like to explain this behaviour: The first text line is short and doesn't overlap the diplay that follows, so TeX put only little vertical space in between, namely \abovedisplayshortskip. This is good. Now there is also \belowdisplayshortskip, but this doesn't behave as you might expect: It does control the vertical space after the display, but the space becomes small if the line above the display is short (which I find weird). This also explains why the space after the second display is large.

Now my question: Is there any way to obtain a \belowdisplayshortskip that becomes short if there is no overlap after the display? My fear is that in TeX/LaTeX the answer is no, but maybe with XeTeX or LuaTeX one can do something?

(I do have a fix for the problem, but this fix is also far from satisfactory. I set \belowdisplayshortskip=9pt plus 3pt minus 5pt, and then after each display where there is no overlap with the next line, I put a macro that makes the vertical space shorter. This is a real nuisance if one makes changes in the text.)

share|improve this question
    
I'd say that the behavior (like all behaviors of TeX) is intentional. You can modify it only in LuaTeX where you can edit the internal lists and hook into TeX's processing. –  Philipp Sep 23 '10 at 13:57
    
OK, I think Knuth himself said that every remaining bug in TeX is a feature. I still consider this one a bug since I strongly dislike the spacing in the output. –  Hendrik Vogt Sep 23 '10 at 15:08
    
@Hendrik: He said that will only be the case after he dies. From Wikipedia: ""absolutely final change (to be made after my death)" will be to change the version number to π, at which point all remaining bugs will become features" –  Billy ONeal Sep 23 '10 at 16:02
1  
I should add that this behavior is explicitly described in The TeXbook, so it seems like it was a design decision, rather than a bug. "If the predisplaysize is short enough so that it doesn’t overlap the displayed formula, the glue above and below the display will be “short” by comparison with the glue that is used when there is an overlap." –  TH. Sep 24 '10 at 0:33
1  
@TH2: I know that this is described in the TeXbook; this is where I understood what happens. But it is not explained there why it is done like this. I always thought it was a compromise since computers were a lot slower when TeX was written. –  Hendrik Vogt Sep 24 '10 at 10:08
show 4 more comments

2 Answers

up vote 5 down vote accepted

Finding better ways to handle displayed math including (sub)formulanumbers is on the todo list for luatex, but in the current situation even in luatex doing this is far from trivial.

The issue is that the engine puts the display on the page as a full-width line, and it takes considerable effort to extract the actual width(s) from that, even with luatex node processing.

share|improve this answer
    
I'm curious why that would be. I don't know anything about LuaTeX's node processing, but a display looks like an \hbox(0.0+0.0)x<width> followed by \penalty 10000, followed by \glue(\abovedisplayskip) followed by \glue(\baselineskip), followed by the \hbox containing the display, shifted some amount, followed by \penalty 0, followed by \glue(\belowdisplayskip). If you can pull apart boxes on the MVL, it should be doable. It's probably doable in Knuth's TeX if you stick the display in a \vbox (which is how I got that information) and using things like \lastbox and \lastskip. –  TH. Sep 24 '10 at 10:32
    
@TH: One problem I see is that the next piece of paragraph needs to get typeset in order to see if there is overlap. –  Hendrik Vogt Sep 24 '10 at 11:20
    
... as Hendrik says. Note that the paragraph itself is not a big issue, but the potential page break that it can introduce is disastrous. –  Taco Hoekwater Sep 24 '10 at 12:27
1  
I'm missing something here, if the line above the display is short, it is very logical to decrease the above skip, but why TeX is changing the below skip too? I don't see the point. –  Khaled Hosny Sep 24 '10 at 14:37
1  
Well, that is the point: nobody sees the point (except DEK, obviously) –  Taco Hoekwater Sep 24 '10 at 14:39
show 2 more comments

An edit pushed up this question to the front page, so here's my take:

\documentclass{article}
\begin{document}
A short line,
\[ a = b_{11}^2 b_{12}^2 b_{13}^2 b_{14}^2, \]
a long line containing superscripts $\delta^{22}\beta^{22}$,
almost touching the above formula,
\[ c = d, \]
and another short line,
\[ e = f \]
followed by a longer line that we want to go beyond the limit so it wraps.

\bigskip\hrule\bigskip

\belowdisplayshortskip=\belowdisplayskip

A short line,
\[ a = b_{11}^2 b_{12}^2 b_{13}^2 b_{14}^2, \]
a long line containing superscripts $\delta^{22}\beta^{22}$,
almost touching the above formula,
\[ c = d, \]
and another short line,
\[ e = f \]
followed by a longer line that we want to go beyond the limit so it wraps.
\end{document}

enter image description here

TeX uses \belowdisplayshortskip if it used \abovedisplayshortskip before the display, but the parameters are independent: there's no law that imposes

\belowdisplayshortskip=\abovedisplayshortskip

and the parameter can be set to whatsoever value one wants. Setting it equal to \belowdisplayskip seems quite drastic, though.

Doing automatic adjustments might be really difficult; one can think of changing the parameter locally.

\documentclass{article}
\begin{document}
A short line,
\begingroup\belowdisplayshortskip=\belowdisplayskip
\[
  a = b_{11}^2 b_{12}^2 b_{13}^2 b_{14}^2,
\]\endgroup
a long line containing superscripts $\delta^{22}\beta^{22}$,
almost touching the above formula,
\[ c = d, \]
and another short line,
\[ e = f \]
followed by a longer line that we want to go beyond the limit so it wraps.
\end{document}

enter image description here

share|improve this answer
    
Thanks for your take, but I'm afraid it doesn't really bring me further than what I wrote in the last paragraph of my question. My main problem is that there's still too much space below c=d in each of your sample outputs. By the way, by default, (La)TeX does not set \belowdisplayshortskip=\abovedisplayshortskip - that would be horrible! –  Hendrik Vogt Jan 17 '13 at 12:36
    
@HendrikVogt To tell you the truth, I don't see the problem. If "really" the two lines conflict, then use a strut in the line below the display to move it down. If the superscripts are not at the center of the line there wouldn't be any conflict. –  egreg Jan 17 '13 at 12:40
    
There's no conflict, but there's too much space. After "and another short line", a short skip is used, and that's good. What I don't like is the large skip before "and another short line". This is what my question is about, a "real" \belowdisplayshortskip, i.e., the line below c=d is short, so the skip should be short. Clearer now? –  Hendrik Vogt Jan 17 '13 at 12:48
    
using a gather* environment and \shortintertext from mathtools is a way out. But an automatized way would be much better. –  jfbu Jan 17 '13 at 14:00
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.