0

In my thesis (book class) I have a long table that spans two pages. I would like the table to span both an even and odd (left and right) page for clarity.

In the answer given here (https://tex.stackexchange.com/a/11709), the \cleardoublepage command is modified to provide the same functionality but forcing content to start on an even page. While this achieves the correct positioning of the table, it forces a blank page between the end of the text and the start of the table.

I would like to force the table to start on an even page, while not disrupting the flow of text that precedes it. I've compiled a MWE, that has the following output:

enter image description here

The table starts on page 4 (which is desired) however page 3 is mostly blank. I would like the text after the table (page 5) to be able to continue from page 3.

MWE:

\documentclass[12pt]{book}

\usepackage[bindingoffset=19mm]{geometry} \usepackage{longtable} \usepackage{lipsum} % dummy text only

% from https://tex.stackexchange.com/a/11709 \newcommand*\cleartoleftpage{% \clearpage \ifodd\value{page}\hbox{}\newpage\fi }

\begin{document}

\chapter{A}
\lipsum

% a long table over multiple pages
\cleartoleftpage
\begin{longtable}{ll}
    \caption{Caption}\\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
\end{longtable}

\lipsum

\end{document}

pikopiko
  • 430
  • 4
    given that you may spend some months or years writing the thesis, it's probably worth spending a few minutes just moving the table in the source so that it falls at a good point with text filling the previous page. Sorry longtable doesn't float (and suggestions to make it float a bit using afterpage are inherently fragile and I wouldn't use them on my thesis, and I wrote both those packages...) – David Carlisle Jun 21 '21 at 22:08
  • I see. If that's the best solution then that's OK - I was only curious if there was a more automatic solution. Thanks for the comment. – pikopiko Jun 21 '21 at 22:09
  • The (relatively) new package hvfloat provides facilities that exceed the usual float options. This might be there (I haven't checked) so it might be worth looking at the documentation. (@DavidCarlisle's suggestion, however, is tried and true, for many years.) – barbara beeton Jul 22 '21 at 19:44

1 Answers1

1

This solution uses \afterpage (even if it is fragile). Note that the caption number is not assigned until the page it appears on.

\documentclass[12pt]{book}

\usepackage[bindingoffset=19mm]{geometry} \usepackage{longtable} \usepackage{afterpage} \usepackage{lipsum} % dummy text only

\newcommand{\waitforit}[1]{% #1 = contents \ifodd\value{page}\afterpage{#1}% \else #1 \fi }

\begin{document}

\chapter{A}
\lipsum[1]

% a long table over multiple pages
\afterpage{\waitforit{\begin{longtable}{ll}
    \caption{Caption}\\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
    a & b \\
\end{longtable}}}

\lipsum[2-16]

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120