[Tex/LaTex] How to include a document into another document

include

I have two documents A and B. Both of them are separate documents. But document A also has to include document B.

Now if I use \include{B} i get the following error:

! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.1 \documentclass
                  [11pt]{article}
? 

So how can I force to include document B with the "style" and "template" of document A?

Best Answer

Cut the content (the part between \begin{document}...\end{document} of B.tex into a new file B-content.tex.

Change B.tex to be:

\documentclass{...}
% your preamble here
\begin{document}
\include{B-content}
\end{document}

Then put \include{B-content} into A.tex.