# Wider vertical space with some tables (those causing overfull \hboxes?)

With the following code:

\documentclass[a4paper]{report}
\usepackage{lipsum}

\begin{document}
a
\begin{center}
\begin{tabular}{|c|c|c|}
\hline
0 & & $y_{n+1}=y_n+hf_{n+1}$ Eulero implicito \\\hline
1 & $y_{n+1}=y_n+hf_n$, Eulero esplicito & $y_{n+1}=y_n+\frac{h}{2}(f_{n+1}+f_n)$ Greg-Nickolson \\\hline
2 & $y_{n+1}=y_n+\frac{h}{2}(2f_n-f_{n-1})$ & $y_{n+1}=y_n+\frac{h}{12}(5f_{n+1}+8f_n-f_{n-1})$ \\\hline
3 & $y_{n+1}=y_n+\frac{h}{12}(23f_n-16f_{n-1}+5f_{n-2})$ & \\\hline
\end{tabular}
\end{center}
\lipsum[1]
\begin{center}
\begin{tabular}{|c|c|c|}
\hline
0 & & $y_{n+1}=y_n+hf_{n+1}$ Eulero implicito \\\hline
2 & $y_{n+1}=y_n+\frac{h}{2}(2f_n-f_{n-1})$ & $y_{n+1}=y_n+\frac{h}{12}(5f_{n+1}+8f_n-f_{n-1})$ \\\hline
3 & $y_{n+1}=y_n+\frac{h}{12}(23f_n-16f_{n-1}+5f_{n-2})$ & \\\hline
\end{tabular}
\end{center}
b
\begin{center}
\begin{tabular}{|c|c|c|}
\hline
0 & & $y_{n+1}=y_n+hf_{n+1}$ Eulero implicito \\\hline
2 & $y_{n+1}=y_n+\frac{h}{2}(2f_n-f_{n-1})$ & $y_{n+1}=y_n+\frac{h}{12}(5f_{n+1}+8f_n-f_{n-1})$ \\\hline
\end{tabular}
\end{center}
c
\end{document}


I get:

The examples make me suspect the greater vertical space, which is what troubles me, is due to the overfull \hbox generated by the tables with the greater vertical space (which is between text above the table and the table). Why does that happen? Is my suspicion right?

• I think it is from the center environment, use \centering instead. See When should we use \begin{center} instead of \centering?. – Peter Grill Sep 26 '14 at 16:17
• But using \centering would remove all the whitespace, while I'me perfectly happy with keeping part of it. The point is the tables with overfull \hboxes have more whitespace above them (but curiously not below them) than the last one which has no Overfull \hbox. And in any case in my specific case the suspicion has proven right, so the question is essentially theoretical, not practical. – MickG Sep 26 '14 at 16:21
• @PeterGrill note that the question is not «Why is there vertical space?», which I "know" (from practical experience, not from reading definitions, though that would require understanding what happens with \trivlist which I failed to do once) to be «because of center», but «Why is there more v.s. in some cases than others, where "some" seems to be the case of Overfulls in center?». – MickG Sep 26 '14 at 16:28

The space is obviously caused by the overfull table and it may be fruitful to understand the reason. What you see as an excess vertical space is an empty line.

When you do \\ inside center you're closing a paragraph, so the effect is reproducible just by

\documentclass{article}
\begin{document}
a
\begin{center}\tracingparagraphs=1
\vrule height 1pt depth 0pt width 1.2\textwidth % an overlong indivisible object
\end{center}
b
\end{document}


The \tracingparagraph=1 will make TeX report in the .log file its computations, which are

@firstpass
[]
@\penalty via @@0 b=0 p=0 d=100
@@1: line 1.2 t=100 -> @@0
@secondpass
[]
@\penalty via @@0 b=0 p=0 d=100
@@1: line 1.2 t=100 -> @@0
|
@\par via @@1 b=* p=-10000 d=*
@@2: line 2.3- t=100 -> @@1


The first pass over the paragraph, that consists just of the box represented by | doesn't obviously succeed. The [] bit represents the indentation box (which is 0pt wide).

The second pass shows a feasible break at the start of the paragraph (@@0, always present, because a new paragraph starts on new line) and then a penalty (which is inserted by the \item command implicitly inserted by \begin{center}). This penalty provides a line break point, which is then used because it allows a non overfull line to be typeset. However, the overlong rule causes TeX to throw in the towel.

A very different situation is when just \centering is used:

\documentclass{article}
\begin{document}
a
\begingroup\centering \tracingparagraphs=1
\vrule height 1pt depth 0pt width 1.2\textwidth
\par\endgroup
b
\end{document}


that reports

@firstpass
[]\OT1/cmr/m/n/10 a
@ via @@0 b=0 p=0 d=100
@@1: line 1.2 t=100 -> @@0
@secondpass
[]\OT1/cmr/m/n/10 a
@ via @@0 b=0 p=0 d=100
@@1: line 1.2 t=100 -> @@0
|
@\par via @@1 b=* p=-10000 d=*
@@2: line 2.3- t=100 -> @@1


Here no penalty is added in the paragraph, so the only feasible break point is at the end. No “vertical space” (actually an empty line) is added.

However you shouldn't be making overfull lines to begin with, so the discussion is just academic.

I conjecture that the problem really stems from the center environment, which is based on trivlist with an opening \item. When the first “letter” in the item is too wide to fit on the line, TeX inserts a line break. Suggested solution:

\newenvironment{senter}{\par\centering\medskip}{\par\medskip}


Then use senter instead of center. Change the \medskips to something larger or smaller if desired.

• Your conjecture is right. ;-) – egreg Sep 26 '14 at 17:45