A puzzling choice made by Leslie Lamport was to define \include
in such a way as to issue a \clearpage
before reading the file. This has been puzzling me for sometime as it is not a very good choice in terms of the author interface. This question has two parts:
- Are there any valid reasons for this decision?
- What can possibly break if the command is redefined?
The MWE below shows such a redefinition (I named the command \includex
but works just fine even, if it is named \include
). My own suspicion that this was introduced early on
to resolve problems with twocolumns
, but there is nothing in the source2e
explaining this decision.
\documentclass{book}
\usepackage{filecontents}
\makeatletter
\def\includex#1{\relax
\ifnum\@auxout=\@partaux
\@latex@error{\string\include\space cannot be nested}\@eha
\else \@includex#1 \fi}
\def\@includex#1 {%
%\clearpage
\if@filesw
\immediate\write\@mainaux{\string\@input{#1.aux}}%
\fi
\@tempswatrue
\if@partsw
\@tempswafalse
\edef\reserved@b{#1}%
\@for\reserved@a:=\@partlist\do
{\ifx\reserved@a\reserved@b\@tempswatrue\fi}%
\fi
\if@tempswa
\let\@auxout\@partaux
\if@filesw
\immediate\openout\@partaux #1.aux
\immediate\write\@partaux{\relax}%
\fi
\@input@{#1.tex}%
%\clearpage
\@writeckpt{#1}%
\if@filesw
\immediate\closeout\@partaux
\fi
\else
\deadcycles\z@
\@nameuse{cp@#1}%
\fi
\let\@auxout\@mainaux
}
\begin{filecontents}{A.tex}
This is file A
This is the A file
\end{filecontents}
\begin{filecontents}{B.tex}
This is the B file
\end{filecontents}
\begin{filecontents}{C.tex}
This is the C file
\end{filecontents}
\includeonly{A,C}
\begin{document}
\includex{A}
\includex{B}
\includex{C}
\end{document}
\clearpage
. – egreg Apr 12 '13 at 7:09how
it breaks. If you have a look at\clearpage
there is nothing, however theinlabel
test fromnewpage
could be duplicated in theinclude
definition? – Yiannis Lazarides Apr 12 '13 at 7:19\hspace*{...}
instead of\clearpage
maybe you would be able to get right working variant of\include
. The argument of\hspace
must be height of text on the page before\include
. – Eddy_Em Apr 12 '13 at 7:23\write
as egreg said. – David Carlisle Apr 12 '13 at 8:15\clearpage
so that\write
and float positioning works correctly. As a historical note it wasn't a "team" it has always done this so this is Leslie's doing before we got involved:-) – David Carlisle Apr 12 '13 at 8:17