将长表水平居中放置在两页横向页面上

将长表水平居中放置在两页横向页面上

我有一个longtable横跨两页的横向环境,我在内容方面最合适的位置引入了分页符。包含描述的表格太长,无法在一页上显示,但实际上也无法填满两页。因此,我将其分成两半,这样就可以向左对齐。这看起来不太吸引人,所以我尝试将其水平居中(即在纵向模式下查看时)。对于第一页,我成功做到了这一点,但对于第二页却没有。这是我的代码:

\begin{landscape}
  \begin{centering}
    \begin{longtable}{lcccccccc}
      \noalign{\vspace*{\fill}} % This is to center "from the left-hand side" (from a portrait POV)
      \caption{My caption}\\
      \label{MYLABEL}
      ...
      \multicolumn{9}{c}{(continued on next page)}\\
      \noalign{\vspace*{\fill}} % This is to center "from the right-hand side" (from a portrait POV)
      \pagebreak % Manual page break so it "looks better"
      \noalign{\vspace*{\fill}} % This is to center "from the left-hand side" on the second page, which doesn't work.
      \caption*{My caption (continued)}\\
      ...
    \end{longtable}
  \end{centering}
  \noindent {\scriptsize \textit{Notes} --- Here's a more detailed description of the table.
  }
\end{landscape}

正如评论中所述,\noalign{\vspace*{\fill}}第二页没有任何变化,而第一页上的 vspacing 工作正常。我做错了什么/遗漏了什么?

答案1

longtable框住最后一页(这样可以防止胶水拉伸)。可能不应该,这样可以删除有问题的框。

\documentclass{article}
\usepackage{lscape,longtable}

\makeatletter
\let\zzLT@output\LT@output
\def\unboxlastpage#1\@colht\vbox{#1\@colht}
\def\LT@output{\expandafter\unboxlastpage\zzLT@output}
\makeatother
\begin{document}


\begin{landscape}
  \begin{centering}
    \begin{longtable}{lcccccccc}
      \noalign{\vspace*{\fill}} % This is to center "from the left-hand side" (from a portrait POV)
      \caption{My caption\label{MYLABEL}}\\
      \multicolumn{9}{c}{(continued on next page)}\\
      \noalign{\vspace*{\fill}} % This is to center "from the right-hand side" (from a portrait POV)
      \pagebreak % Manual page break so it "looks better"
      \noalign{\vspace*{\fill}} % This is to center "from the left-hand side" on the second page, which doesn't work.
      \caption*{My caption (continued)}\\
      ...\\
 \noalign{\vspace*{\fill}}
    \end{longtable}
  \end{centering}
  \noindent {\scriptsize \textit{Notes} --- Here's a more detailed description of the table.
  }
\end{landscape}

\end{document}

相关内容