4

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.

6
  • 1
    Welcome to tex.SX! I've inserted the example code into your question, I hope you don't mind.
    – Jake
    Mar 14, 2011 at 22:12
  • @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. Mar 14, 2011 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. Mar 14, 2011 at 22:30
  • @Martin Scharrer: that would be superb, thanks! the booktabs stuff (\toprule etc) makes the table lot more attractive (spacious), lot better than just \hlines.
    – JDoe
    Mar 14, 2011 at 22:35
  • 2
    @Martin: FYI, Jake did get a notification of JDoe's comment. Mar 15, 2011 at 8:02

1 Answer 1

3

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.

4
  • 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, 2011 at 13:54
  • 1
    @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, 2011 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, 2011 at 21:16
  • I tested the \shrinkheight{} command more thoroughly, it gives excellent results, problem solved, thanks again.
    – JDoe
    Mar 16, 2011 at 14:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .