# Temporarily changing document class in LaTeX/resetting pdfLaTeX

How can I temporarily cause pdfLaTeX to forget everything that I've told it and start with a new document class?

I've modified the example environment from the lshort document:

\newwrite\examplesx@out
\newenvironment{examplesx}{%
\begingroup% Lets Keep the Changes Local
\@bsphack
\immediate\openout \examplesx@out \jobname.exa
\let\do\@makeother\dospecials\catcode`\^^M\active
\def\verbatim@processline{%
\immediate\write\examplesx@out{\the\verbatim@line}}%
\verbatim@start
}{%
\immediate\closeout\examplesx@out\@esphack\endgroup%
\noindent\makebox[\textwidth][l]{%
\begin{minipage}[c]{0.45\textwidth}%
\small\verbatiminput{\jobname.exa}
\end{minipage}%
\hspace*{0.1\textwidth}%
\framebox{%
\begin{minipage}{0.45\textwidth}%
\small\input{\jobname.exa}%
\end{minipage}
}%
}\vspace*{\parskip}%
}

and it mostly works, but I want to be able to do something like

\begin{examplesx}
\section{Section}
\end{examplesx}

and have it show up as a section in a box. I also would like it to typeset lists using the standard article style, even if I use it in beamer

-
–  Charles Stewart Nov 22 '10 at 10:05
I don't have a copy at hand, but I think the LaTeX companion has a section on how all the examples in it where typeset. –  Caramdir Nov 23 '10 at 1:51