2

I have a weird problem with the longtable environment.

Once the table finishes near the end of the page, it forces the generation of a new blank page which is left totally empty.

Here's the MWE:

\documentclass[11pt,oneside]{book}
\usepackage{longtable}
\usepackage{lipsum}

\begin{document}
\chapter*{First chapter}
    \begin{center}
        \scriptsize
        \begin{longtable}{|c|c|c|}

                \hline \multicolumn{1}{|c|}{First} & \multicolumn{1}{c|}{Second} & \multicolumn{1}{c|}{Third}
                \\ \hline \hline
                \endhead

                \endlastfoot
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\

                \hline
        \caption*{Wonderful caption} \\
        \end{longtable}
    \end{center}
\chapter*{Second chapter}
\lipsum
\end{document}

Here's the screenshot of the output produced:

Showing MWE

Any idea on why this is happening?

I must use the longtable package because the table is dinamically generated, thus its length is variable and can span over multiple pages.

3
  • ---I get the caption on page 2--- (sorry was using v5:-) , also don't put longtable in a center environment, it can't be centred that way so it just adds spurious vertical space Commented May 10, 2016 at 16:20
  • the comments in this may help, although it doesn't have an answer: Extra page appended after long table even if it fits on one page (the older one should probably be closed as a duplicate, since this one does have an answer. i've suggested that in the chat.) Commented May 10, 2016 at 16:25
  • @DavidCarlisle your suggestion perfectly works! Please add an answer so I can accept it :) Maybe add some extra details to make it more complete ;) Commented May 12, 2016 at 9:06

1 Answer 1

5

Just remove the \begin{center}...\end{center} -- a longtable is already centered by default, the \begin{center}...\end{center} introduces too much vertical spacing which leads to an additional empty page then!

\documentclass[11pt,oneside]{book}
\usepackage{longtable}
\usepackage{lipsum}

\begin{document}
\chapter*{First chapter}
        \scriptsize
        \begin{longtable}{|c|c|c|}
          \hline \multicolumn{1}{|c|}{First} & \multicolumn{1}{c|}{Second} & \multicolumn{1}{c|}{Third}
                \\ \hline \hline
                \endhead
                \endlastfoot
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                One & Two & Three \\
                \hline
        \caption*{Wonderful caption}
      \end{longtable}
%    \end{center}
    \chapter*{Second chapter}
\lipsum
\end{document}
1
  • it would be helpful to add a bit of explanatory prose. Commented May 10, 2016 at 16:26

You must log in to answer this question.

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