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?}
\title{My R Poem}


R is my favoritest.


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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