I have a complicated document containing files with a letter as the first document followed by several article type documents. I have done this by setting up a master tex file with all the frontpeice information, defining common style elements and whatnot, then adding the documents with \include statements. Is there a way to use the letter document class for the first file then switch to the article class for the rest of the files?
[Tex/LaTex] Combining Document Classes
document-classesinclude
Related Solutions
Using the pdfpages
package it's easy to build documents from many different sources (and therefore created with different classes) The only limitation of this approach is that the inserted pages will start on a new page (i.e. it's not possible to insert a PDF starting at the middle of a page of the main document.)
The pdfpages
package has a pagecommand
key which allows you to add material such as headers and footers to the included pages. Here's a small example. First, let's create the included document. I've made this red and with big margins just to show it clearly. Compile this and you will end up with myletter.pdf
.
myletter.tex
\documentclass{article}
\usepackage[margin=2.5in]{geometry}
\usepackage{xcolor}
\usepackage{kantlipsum}
\pagestyle{empty}
\begin{document}
\color{red}
\kant
\end{document}
Now let's make our main document. In this document, we use the fancyhdr
package to set the pagestyle for the entire document. We then use pdfpages
and the pagecommand={\pagestyle{fancy}}
to add the footers to the included pages. TeX keeps track of the page numbering correctly.
main document
\documentclass{report}
\usepackage{kantlipsum}
\usepackage{pdfpages}
\usepackage{fancyhdr}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}
\lfoot{\emph{My footer}}
\rfoot{\thepage}
\begin{document}
\tableofcontents
\chapter{A chapter}
\section{Introduction}
\kant[1-4]
\includepdf[pages=1-,pagecommand={\thispagestyle{fancy}}]{myletter.pdf}
\section{Another section}
\kant[5-8]
\end{document}
Table of contents Entire document
use a main file of the form
\documentclass[12pt]{article}
\usepackage{lipsum}
\title{dsjgk}%
\author{gfdl}%
\date{today}%
\begin{document}
\maketitle
\section{first file}
\input{body1}
\section{second file}
\input{body2}
\end{document}
then to have a document for just section 1 have
\documentclass[12pt]{article}
\usepackage{lipsum}
\title{first section as a document}%
\author{gfdl}%
\date{today}%
\begin{document}
\maketitle
\input{body1}
\end{document}
and the shared body of the section is in body1.tex
\subsection{zzz}
hello.....
\subsection{zzzz}
hello again.....
and of course for section2 and any other sections have a body2.tex
with the shared content and a wrapper document that includes it. Note that the wrapper document including the individual sections might use a different class or options to the main document, depending on requirements.
Best Answer
This FAQ answer discusses some solutions to this type of problem. The only one that I think is likely to work for you in this case, is the
pdfpages
based solution.