# Is newclude (still) a good package to use?

I came up with this very MWE while trying to organize my code into several section files to speed up compilation of a journal paper (sections, not chapters!):

\documentclass{article}
\usepackage{filecontents}
%\usepackage{newclude}
\begin{filecontents}{\jobname-ext.tex}
\section{A section}
\label{sec:A}
References to this section \ref{sec:A} do not work.
\end{filecontents}
\begin{document}
\begingroup
\let\clearpage\relax
\include{\jobname-ext}
\endgroup

\section{Another section}
No page break after section \ref{sec:A}, please!
\end{document}


Surprisingly (at first), the result lacks correct references. It is less surprising seeing Problem cross referencing when using include tcommand to include multiple files and Reference label with included file and relaxed clearpage, in particular, this answer.

Now, looking at those question above as well as Reactivating “\clearpage” in LaTeX after turning it off with “\let\clearpage\relax”, not a single answer or comment (or question) mentions the newclude package, which offers an \include* command that does not issue a \clearpage. I wonder if this is an OK package to use, since it has not been updated since 1999.

Here's another piece of code that works without redefining \clearpage:

\documentclass{article}
\usepackage{filecontents}
\usepackage{newclude}
\begin{filecontents}{\jobname-ext.tex}
\section{A section}
\label{sec:A}
References to this section \ref{sec:A} DO work.
\end{filecontents}
\begin{document}
\include*{\jobname-ext}

\section{Another section}
No page break after section \ref{sec:A}, please!
\end{document}


And here are two more that don't:

\documentclass{article}
\makeatletter
\def\include#1{\relax
\ifnum\@auxout=\@partaux
\@latex@error{\string\include\space cannot be nested}\@eha
\else \@include#1 \fi}
\def\@include#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
\@nameuse{cp@#1}%
\fi
\let\@auxout\@mainaux}
\makeatother
\usepackage{filecontents}
\begin{filecontents}{\jobname-ext.tex}
\section{A section}
\label{sec:A}
References to this section \ref{sec:A} do not work.
\end{filecontents}
\begin{document}
\include{\jobname-ext}

\section{Another section}
No page break after section \ref{sec:A}, please!
\end{document}


and

\documentclass{article}
\usepackage{xpatch}
\makeatletter
\patchcmd{\@include}{\clearpage}{}{}{error}
\patchcmd{\@include}{\clearpage}{}{}{error}
\makeatother
\usepackage{filecontents}
\begin{filecontents}{\jobname-ext.tex}
\section{A section}
\label{sec:A}
References to this section \ref{sec:A} do not work.
\end{filecontents}
\begin{document}
\include{\jobname-ext}

\section{Another section}
No page break after section \ref{sec:A}, please!
\end{document}

• I'm not sure newclude has ever worked as intended. – egreg Feb 15 '16 at 21:03
• where does this \let\clearpage\relax\include{... idiom come from? It keeps coming up, but it is completely broken. If there is a tutorial that recommends this it should be fixed. – David Carlisle Feb 15 '16 at 21:04
• @egreg do you have an example that fails? I have included newclude in my 25-page iopart document with figures, tables, lists of figures/tables, appendices and a bibliography, and I don't note any difference to the previous compilation output. – bers Feb 15 '16 at 21:15
• @bers You're being lucky, I believe. – egreg Feb 15 '16 at 21:31
• Am I missing something here? Why not just use \input instead of \include if you don't want a \clearpage? – Ian Thompson Feb 15 '16 at 21:31