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 07:09howit breaks. If you have a look at\clearpagethere is nothing, however theinlabeltest fromnewpagecould be duplicated in theincludedefinition? – yannisl Apr 12 '13 at 07:19\hspace*{...}instead of\clearpagemaybe you would be able to get right working variant of\include. The argument of\hspacemust be height of text on the page before\include. – Eddy_Em Apr 12 '13 at 07:23\writeas egreg said. – David Carlisle Apr 12 '13 at 08:15\clearpageso that\writeand 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 08:17\writepart and thinking that one should maybe experiment with writing the label part in the fileN.aux. How can one trick the floats? – yannisl Apr 12 '13 at 08:35\clearpage– David Carlisle Apr 12 '13 at 08:40