# Change document class per page

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.

-
You can't change the class in between. You can, however, change certain settings. If you specify why exactly you would want to change the class, we might find ways to change corresponding settings. –  mafp Jan 8 '13 at 0:37
Alternatively, if you don't mind the pages starting on a new page, you can insert the PDF versions of the letters into your document with pdfpages. These can have the same header and footer as your main document etc. –  Alan Munn Jan 8 '13 at 0:40
@mafp I updated to explain a little more the type of document I'm trying to create. –  tpg2114 Jan 8 '13 at 0:41
@AlanMunn How do I ensure that the page numbering would be consistent if I want the letters to be numbered in series with the rest? Would I have to build the main document telling it to skip a number, then see what that number is and hardwire it into the page I want to insert? –  tpg2114 Jan 8 '13 at 0:43
If this is acceptable I can post an example. –  Alan Munn Jan 8 '13 at 0:43

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{}
\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}
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8308810591697693, "perplexity": 1143.8872768496612}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-18/segments/1429246652114.13/warc/CC-MAIN-20150417045732-00035-ip-10-235-10-82.ec2.internal.warc.gz"}