5

Consider the following MWE. I have a chapter with a table in landscape mode. Together with the second chapter, this results in three pages. However, when adding \topskip 0pt to the landscape environment, then a blank page is added after it (in fact two, since the new chapter starts on an odd page).

\documentclass{book}
\usepackage{lscape}
\usepackage{array}
\begin{document}
\chapter{Table Test}
\begin{landscape}
  \topskip0pt % <<<< Without this line, no blank page.
  \begin{table}[htb!]
  \centering
  \begin{tabular}{>{\raggedright}p{3cm} >{\raggedright}p{3cm}}
  \hline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  1 & 2\tabularnewline
  \hline
  \end{tabular}
  \end{table}
\end{landscape}
\chapter{Potrait again}
Test2
\end{document}
  • I have removed some stuff. It seems that the problem is the \topskip0pt line. If you don't need this line, your problem might be solved. – gernot Oct 14 '16 at 14:33
  • Note that it is normal in book classes that a blank page is added if otherwise the next chapter would start on an even page (this was the case in your original example). If you don't want this, use the oneside option of the class. – gernot Oct 14 '16 at 14:45
  • 1
    What's the \topskip=0pt supposed to do? – egreg Oct 14 '16 at 21:39
3

This issue has nothing to do with the lscape package: indeed, you can reproduce it with the following simple program

\documentclass[a4paper,twoside]{article}
\begin{document}
A\par
\clearpage
% \setlength{\topskip}{0pt} % uncomment this line to see it happen
B\par
\clearpage
\cleardoublepage
C\par
\end{document}

(uncomment the commented line to see it happen).

I’ve made some investigations, and the culprit seems to be the \@doclearpage macro in LaTeX’s output routine, more precisely the following line of code

\setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa

(line 6696 in latex.ltx, latest version), which is meant to send back to the main vertical list “any left-over non-boxes (writes, specials, etc.)”, as the comments in ltoutput.dtx say. Unfortunately, if the \topskip glue is zero, the \vbox{} inserted by a \clearpage command is split off too, because it does fit in zero points, in that case; so, that box is returned to the main vertical list, where it causes the ensuing \cleardoublepage command to insert two extra pages.

To be honest, I’ve not checked all the details, but the following program can be used to confirm, more or less, the above analysis:

\documentclass[a4paper,twoside]{article}

\makeatletter

\def\clearpage{%
  \ifvmode
    \ifnum \@dbltopnum =\m@ne
      \ifdim \pagetotal <\topskip
        \hbox{\special{Comment: A}}%
      \fi
    \fi
  \fi
  \newpage
  \write\m@ne{}%
  \vbox{\special{Comment: B}}%
  \penalty -\@Mi
}
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
    \hbox{\special{Comment: C}}\newpage
    \if@twocolumn\hbox{\special{Comment: D}}\newpage\fi\fi\fi}

\makeatother

\showboxbreadth = 1000
\showboxdepth = 10
% \tracingoutput = 1

\begin{document}
A\par
\clearpage
% \setlength{\topskip}{0pt}
B\par
\clearpage
\showlists
% \vbox{} % <<< HERE <<<
\cleardoublepage
C\par
\end{document}

It redefines the \clearpage and the \cleardoublepage commands so that they produce boxes that can be unambiguously identified in trace listings (don’t worry if you get some warnings that say “Non-PDF special ignored!”). Run it first as it is, and look at the trace produced by \showlists; then uncomment the line that says

% \setlength{\topskip}{0pt}

and look again at the transcript: you’ll see that the result is the same as though you had a \vbox{} command in your source file at the point indicated by % <<< HERE <<<.

Uncomment \tracingoutput = 1 to get further diagnostic information.

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.