# Beamer presentation with page containing Latex output

Latex newbie here. Let's say I create a page with some Latex code, and I want to have the following beamer slide contain the output of that code. how can I do that?

\begin{frame}[fragile]{How does \mbox{\LaTeX} work?}
\begin{verbatim}
\title{My R Poem}
\author{Dude}

\begin{document}

R is my favoritest.

\end{document}
\end{verbatim}
\end{frame}


I assume there's a package for this, but I'm not aware of it and can't find it via google.

-
Do you want to show code and result side-by-side or just the output? – Martin Scharrer Jul 2 '11 at 18:06
I'd have the code on one slide, which is done with the verbatim package (see code above), and another slide for the output. – ATMathew Jul 2 '11 at 18:07

To include the output of a different, full document with own preamble you would have to include the output as PDF (or PS if you insist using non-PDF latex). I would recommend you to store the code in an external file and use the standalone class to produce a tightly cut PDF (the preview package is internally used to do this). Then simply include the PDF as graphic using \includegraphics[width=...]{filename}. You can also include the source using the listings package and \lstinputlisting. It also allows you to remove the first or last code lines if you want to remove the \documentclass[class=<realclass>]{standalone} part.
The v1.0 of the standalone package allows to automatically compile sub-files as standalone documents and include them as images to the main document.