# unwanted blank page inserted before tabular

i have a document that consists of a single multi-page table. Unfortunately it gets a blank page inserted as the first page, I absolutely don't want this (it screws with page numbering, etc). If I remove rows, so the table can fit on a single page, then the blank page is not inserted.

Here is a minimal working example, the error is the blank page as the first page:

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{supertabular}
\usepackage{array}
\usepackage{booktabs}

\begin{document}

\pagestyle{empty}

\tabletail{\bottomrule}
\tablelasttail{\hline}

\toprule
\multicolumn{2}{c}{
}
\\ \midrule
}

\begin{supertabular}{@{}p{7cm}@{\extracolsep{\fill}}p{7cm}@{}}
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
\end{supertabular}
\end{document}


If you remove some rows from that table so it fits on a single page, you will see that the blank page is not inserted.

What causes this? Thanks.

-
Welcome to tex.SX! I've inserted the example code into your question, I hope you don't mind. –  Jake Mar 14 '11 at 22:12
Of course I don't, thank you. –  JDoe Mar 14 '11 at 22:20
@JDoe: Welcome to TeX.SX. If you add @ followed by the username to your comments the user gets notified. This only works for the first mentioned user. The author of the commented question or answer is always notified. –  Martin Scharrer Mar 14 '11 at 22:28
@JDoe: I had a look on your file and it seems related to the table rules (\toprule, \midrule, etc.). After removing them the page break is gone. I will post an answer if and when I find how to fix this without removing the rules. –  Martin Scharrer Mar 14 '11 at 22:30
@Martin: FYI, Jake did get a notification of JDoe's comment. –  Hendrik Vogt Mar 15 '11 at 8:02

As Martin points out, this is related to the booktabs rules. There really shouldn't be a \midrule between every line, but if you want to do it anyway, here's one way to fix the problem.

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{supertabular}
\usepackage{array}
\usepackage{booktabs}
\usepackage{geometry}
\usepackage{etoolbox}

\tabletail{\bottomrule}
\tablelasttail{\bottomrule}
\toprule
\multicolumn{2}{c}{\textbf{\huge Head row''}}%
\\ \midrule
}

\pagestyle{empty}%

\overfullrule5pt
\makeatletter
\appto\estimate@lineht{%
}
\makeatother
\begin{document}
\begin{supertabular}{@{}p{7cm}@{\extracolsep{\fill}}p{7cm}@{}}
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
foo & bar \\ \midrule
\end{supertabular}
\end{document}


The geometry package is just because your table was too wide and it was giving overfull rules. Changing the margins fixes that. The real fix here has to do with how supertabular estimates the height of each line. It uses \estimate@lineht to compute the height of a stretched line. Since you are using \midrule between every line, we can simply increase the estimate of the line height by incrementing \ST@lineht by \aboverulesep + \belowrulesep.

The real fix is to omit the \midrules. It makes the table look much better.

-
thanks, but this solution doesn't work when i have multi-line rows. For example change all foo and bar to some longer text, the blank page gets inserted yet again. Is it possible to solve this? I need the midrules, or maybe I just use LaTeX the wrong way here. –  JDoe Mar 15 '11 at 13:54
@JDoe: The documentation says, "When the last p-arg on a page gets more than 4 lines (probably even more than 3 lines) it will result in an overfull \vbox. Also some combinations of \baselinestretch \arraystretch and a large font may lead to one line too much." Maybe you're hitting that? It suggests that "[a] quick but not very elegant solution: shrink the allowed height of the table with the command \shrinkheight{...pt} after the first \\ of the supertabular." –  TH. Mar 15 '11 at 17:56
\shrinkheight{} indeed did help, thanks! Finding an optimal pt value may be a problem later (as I generate these docs programatically), but for now I will use a sufficiently big value and hope for the best. –  JDoe Mar 15 '11 at 21:16
I tested the \shrinkheight{} command more thoroughly, it gives excellent results, problem solved, thanks again. –  JDoe Mar 16 '11 at 14:27