% main.tex
\documentclass{article}
\def\allfiles{}
\begin{document}
\title{A LaTeX Book}
\author{cohomo@blogbus}
\date{}
\maketitle
\input{chap1}
\input{chap2}
\end{document}
% chap1.tex
\ifx\allfiles\undefined
\documentclass{article}
\begin{document}
\title{Something in Title}
\author{cohomo@blogbus123}
\date{}
\maketitle
\else
\fi
\section{First Section 123}
\section{Second Section 222333}
\ifx\allfiles\undefined
\end{document}
\fi
好的,我重新调试了一下。