# A single command to return control to the parent document

I have a parent document and several "child" documents which I incorporate into the parent document with the \input command.

I'd like a single command that would enable me to return to the parent document half way through one of the child documents.

Obviously I can do this with an \iffalse ... \fi statement but that's clumsy, would be much nicer to have one command, after all, every other program does.

Here's an MWE.

The parent doc:

\documentclass{article}
\begin{document}
\input{child}
foo
\end{document}


The child doc:

Hello
World


Without using \iffalse ... \fi, I'd like to be able to insert a command like \return between Hello and World in the child, forcing an exit and thus producing output Hello foo

~

• I just tested \endinput and it worked (albeit with an extra space). – John Kormylo Apr 3 '17 at 1:18
• \endinput is the obvious thing to try. Surprised about the space. – cfr Apr 3 '17 at 1:56
• @JohnKormylo Did you use Hello\endinput? That shouldn't insert a space, surely? – cfr Apr 3 '17 at 1:56
• @cfr - No, separate lines. Wasn't particularly concerned. – John Kormylo Apr 3 '17 at 2:03
• Thanks guys! \endinput worked without any spaces for me! – Leo Simon Apr 3 '17 at 5:02

\endinput stops at the end of the line. Therefore if you have something like a \hspace after the \endinput it will be inserted:

\documentclass{article}
\usepackage{filecontents}
\setlength{\parindent}{0em}
\setlength{\parskip}{.6em}

\begin{filecontents}{hello.tex}
hello\endinput\hspace{1cm}
\end{filecontents}

\begin{filecontents}{hello-world.tex}
hello \endinput world
earth

universe
\end{filecontents}

\begin{filecontents}{hello-world-commented.tex}
hello \endinput world%
earth%
%
universe%
\end{filecontents}

\begin{document}
\section{hello}
\input{hello}world

\section{hello-world}
\input{hello-world}\par
\verb|\endinput| stops at the end of the line\ldots

\section{hello-world-commented}
\input{hello-world-commented}\par
\ldots even if the line break is commented out.
\end{document}