Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.