[Tex/LaTex] unwanted blank page inserted before tabular

blank-pagesupertabulartables

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}

\tablehead {
\toprule
\multicolumn{2}{c}{
\textbf{\huge "Head row"}
}
\\ \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.

Best Answer

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}
\tablehead{%
        \toprule
        \multicolumn{2}{c}{\textbf{\huge ``Head row''}}%
        \\ \midrule
}

\pagestyle{empty}%

\overfullrule5pt
\makeatletter
\appto\estimate@lineht{%
        \global\advance\ST@lineht by\aboverulesep
        \global\advance\ST@lineht by\belowrulesep
}
\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.

Related Question