[Tex/LaTex] how to use \input{file.tex} correctly

input

Suppose I have two latex files file1 and file2 with the same preamble and so on. Then I want to create a file called bigfile which just puts the two files together. This is not working for some reason. Therefore I first tried to include just file1, this is what I have done:

\documentclass .... %% same as file1 ...
same preamble as file1
\begin{document}
\input{file1}
\end{document}

The result is that I not only get file1, but also the preamble and so on. This is my first experience with putting files together in 1 file. Kindly provide me a solution 🙂

Best Answer

The best thing is probably to leave out the document preamble and the \begin{document} and \end{document} from the included files and have one master file that sets up the style.

Master file:

\documentclass{article}
% preamble.
\begin{document}
    \input{file1}
    \input{file2}
\end{document}    

First included file:

\section{Blah}
% more stuff.

Second included file

\section{More stuff}
% blah blah