5

I have a longtable in a landscape environment that ranges over two pages, and where I have introduced a page break where it is most appropriate contentwise. The table including descriptions is too long to be displayed on one page only but doesn't really fill two full pages either. I therefore split it in half, which gives me a leftward alignment. This doesn't look too appealing, so I'm trying to center it horizontally (i.e., when viewed in portrait mode). For the first page, I have succeeded in doing that, but not for the second. Here's my code:

\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}

As already stated in the comments \noalign{\vspace*{\fill}} doesn't change anything on the second page, whereas the vspacing works just fine on the first page. What am I doing wrong/missing?

3
  • Please always post complete documents not just a fragment \noalign{\vspace*{\vfill} generates an error (you meant \fill) Dec 9, 2013 at 17:18
  • Sorry, that was a typo. Corrected it. There are no errors when compiling the file. ... indicates standard table content (&'s, \\'s \hline's), nothing fancy.
    – user41800
    Dec 9, 2013 at 17:23
  • It doesn't matter that there are no errors when compiling your file as we can't see that, the point is that it is best if there are no errors when running the example (there are several here with position of \label etc, most likely because you didn't test the version you posted (with ...) Dec 9, 2013 at 17:29

1 Answer 1

5

longtable boxes the last page (which stops your glue stretching). It probably shouldn't, this removes the offending box.

\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}

You must log in to answer this question.

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