I would like a letter at the start of my report, but it would be a different document class.
Could I use the same .tex file, with \begin{document}\end{document}\begin{document}\end{document}?
I would like a letter at the start of my report, but it would be a different document class.
Could I use the same .tex file, with \begin{document}\end{document}\begin{document}\end{document}?
I would write the letter as a different document, compile it into a PDF and include it in the report using \includepdf{<filename>} from the pdfpages package. This avoids the double documentclass, but only works with full pages. However, this seem what you want anyway.
Just for fun, you can have it all in "one file" (note that shell-escape must be active).
\documentclass{report}
\usepackage{filecontents,pdfpages}
\begin{filecontents*}{myletter.tex}
\documentclass{letter}
\begin{document}
This is my letter.
\end{document}
\end{filecontents*}
\immediate\write18{pdflatex myletter}
\begin{document}
\IfFileExists{myletter.pdf}{\includepdf{myletter.pdf}}{}
My report.
\end{document}
filecontents package as well (before the environment of course) to ensure that the external file is outdated when you change the content changes. Otherwise an existing file will never be overwritten.
– Martin Scharrer
Mar 09 '12 at 17:43
filecontents environment has bothered me for a while. Updated answer.
– cjorssen
Mar 09 '12 at 18:50
makefile isn't really the way to got -- is there a way to pass commands from the first document to the second such as \newcommand{\EMAIL}{cccc@sss.com} ?
– jlk
Aug 23 '15 at 13:13
There are command-line tools that can combine several PDF files into one, such as pdftk:
pdftk a.pdf b.pdf output a_plus_b.pdf
Combine this with a Makefile or a similar mechanism to compile only what's necessary. latexmk can do a nice job here, too:
latexmk -pdf a
latexmk -pdf b
will run pdflatex, bibtex etc. on both a.tex and b.tex as often as necessary.
TeXwill stop the compilation process the first time it sees\end{document}(non verbatim). So, no you cannot use\begin{document}\end{document}\begin{document}\end{document}. – cjorssen Mar 09 '12 at 17:32