1

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.

  • ---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 – David Carlisle May 10 '16 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.) – barbara beeton May 10 '16 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 ;) – boh717 May 12 '16 at 9:06
3

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}
  • it would be helpful to add a bit of explanatory prose. – barbara beeton May 10 '16 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.