[Tex/LaTex] Change document class per page

document-classes

Let's say I have a document that has many pages and some pages have different formats. For example, most of the pages are fine with \documentclass{article} but there may be pages in the middle that I want to be \documentclass{letter}. I want my letter pages to be numbered inline with the other pages and have them show up in the Table of Contents.

Is it possible to change the class used for an individual or range of pages while still keeping things like page numbering consistent across them?

EDIT
I'm trying to create a "welcome to the company" sort of document that has a cover page, table of contents, welcome letter, then various sections of information. I've never tried this in anything other than a word processor where it's easy to set "master pages" or "template pages" for individual pages in the document. So I could use a letterhead template page for the welcome letter part and a standard article-type template for the rest and still have the letter numbered/referenced in the ToC.

So the idea was to take advantage of the classes written, if possible, rather than have to format a single page by hand differently from the rest.

Best Answer

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 TOC Entire document output of code