LaTeX 表格被截断,输出页面多余,为空白。如何修复?

LaTeX 表格被截断,输出页面多余,为空白。如何修复?

我正在尝试制作一个表格,但是当我制作 PDF 时,表格的顶部和底部被截断了。一开始我还得到了一个空白的输出页,但我可以处理它。我尝试过只运行表格的一部分,我得到了直到某个点的所有输出,之后我生成的 PDF 中只显示表格的中间部分。我尝试过使用这个longtable选项,但当我这样做时,我甚至无法让它制作 PDF。我是 LaTeX 的新手,不太确定我做错了什么。我正在尝试创建类似于下面的内容。任何建议都非常感谢。

\documentclass{article}
\usepackage{rotating}
\usepackage[margin=.25in]{geometry} % 1 inch margins all around

%\usepackage{longtable}

\begin{document}
\pagenumbering{gobble}

\begin{center}

\begin{sidewaysfigure}



\begin{tabular}{lllccccccc}
\hline
& & & \multicolumn{7}{c}{C2} \\ 
 & C1 &  & r & s & t & u & v & w & \multicolumn{1}{c}{y} \\ 
\hline
a1 & \nopagebreak a & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X3  & $0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X4  & $0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X5  & $0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X6  & $0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 & \nopagebreak b & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $0$ & $\phantom{0}0$ & $0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X3  & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X4  & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X5  & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X6  & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 & \nopagebreak c & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X3  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X4  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X5  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X6  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 & \rule{0pt}{1.7\normalbaselineskip}d & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X3  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X4  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X5  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X6  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 & \nopagebreak e & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $0$ & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X3  & $0$ & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X4  & $0$ & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X5  & $0$ & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X6  & $0$ & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 & \nopagebreak f & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X3  & $0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X4  & $0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X5  & $0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X6  & $0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 & \rule{0pt}{1.7\normalbaselineskip}g & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X3  & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X4  & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X5  & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X6  & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 & \nopagebreak h & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X3  & $0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X4  & $0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X5  & $0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X6  & $0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 & \nopagebreak j & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X3  & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X4  & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X5  & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X6  & $\phantom{00}0$ & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 & \rule{0pt}{1.7\normalbaselineskip}k & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X3  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X4  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X5  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X6  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 & \nopagebreak l & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X3  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X4  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X5  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X6  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 & \nopagebreak m & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X3  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X4  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X5  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X6  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 & \rule{0pt}{1.7\normalbaselineskip}n & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X3  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X4  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X5  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X6  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 & \nopagebreak o & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X3  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X4  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X5  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 &  & X6  & $\phantom{00}0$ & $\phantom{00}0$ & $0$ & $0$ & $0$ & $\phantom{00}0$ & $\phantom{00}0$ \\
 & \nopagebreak p & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X3  & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X4  & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X5  & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X6  & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 & \rule{0pt}{1.7\normalbaselineskip}q & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ \\
 &  & X2  & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X3  & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X4  & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X5  & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
 &  & X6  & $\phantom{00}0$ & $0$ & $0$ & $0$ & $0$ & $0$ & $0$ \\
\hline 
\end{tabular}

\end{sidewaysfigure}

\end{center}

\end{document}

答案1

我认为不可能让这样的表格适合横向模式。你确实提到你尝试过这个longtable包,所以我假设你更喜欢使用 的解决方案longtable

下面我编辑了您的示例,以获得解决方案longtable。为了使示例简短,我只在表体中放入一行,并省略了所有其他行。

如果这个解决方案有问题,请告诉我,我会看看是否能找到更好的解决方案。

\documentclass{article}
\usepackage[margin=.25in]{geometry} % 1 inch margins all around

\usepackage{longtable}
\usepackage{booktabs}

\newcommand*\PHZ{$\phantom{00}0$}
\newcommand*\ZO{$0$}

\begin{document}

\begin{longtable}{lllccccccc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \toprule
  \multicolumn{10}{r}{\textbf{Start of Table}}
\\\midrule
    & & & \multicolumn{7}{c}{C2}
\\  & C1 &  & r & s & t & u & v & w & \multicolumn{1}{c}{y}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \endfirsthead
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \toprule
  \multicolumn{10}{r}{\textbf{Table Continued}}
\\\midrule
    & & & \multicolumn{7}{c}{C2}
\\  & C1 &  & r & s & t & u & v & w & \multicolumn{1}{c}{y}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \endhead
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\\\bottomrule
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \endfoot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\\\bottomrule
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \endlastfoot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\\\midrule
  a1 &a & X1  & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$ & $\phantom{0}0$
\\   &  & X2  & \ZO & \PHZ & \ZO & \ZO & \ZO & \PHZ & \PHZ
% snip
\end{longtable}

\end{document}

相关内容