我有一个文档,其中包含一个多页表格。不幸的是,它会将一个空白页插入为第一页,我绝对不想这样(它会影响页码等)。如果我删除行,以便表格可以放在一页上,则不会插入空白页。
这是一个最小的工作示例,错误是第一页是空白页:
\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}
如果您从该表中删除一些行以使其适合单个页面,您将看到未插入空白页。
这是什么原因造成的?谢谢。
答案1
正如 Martin 指出的,这与规则有关booktabs
。实际上,每行之间不应该有一个\midrule
,但如果您无论如何都想这样做,这里有一种解决问题的方法。
\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}
该geometry
包只是因为您的表格太宽,并且给出了过多的规则。更改边距可以解决这个问题。这里真正的修复与如何supertabular
估计每行的高度有关。它用于\estimate@lineht
计算拉伸线的高度。由于您在每行之间使用,我们可以通过增加+\midrule
来增加行高的估计值。\ST@lineht
\aboverulesep
\belowrulesep
真正的解决方法是省略\midrules
。它使表格看起来好多了。