[Tex/LaTex] Article example inside beamer frame

beamerminipage

Let us assume that we have the following example code for an article

\documentclass{article}
\title{Sample title}
\author{Sample author}
\date{}
\begin{document}
\maketitle
\section{Sample section}
\end{document}

I wish to include the output of the above code as a minipage in my beamer frame. How can I do that? I would prefer a vector output rather than a PNG / JPG screenshot.

Best Answer

The easiest would be to create a separate document that contains the article content and include it as an image. Here's an example:

enter image description here

\documentclass{beamer}
\let\Tiny\tiny% http://tex.stackexchange.com/a/94159/5764
\usepackage{fancyvrb}
\usetheme{Warsaw}
\begin{document}

\begin{SaveVerbatim}{CodeBox}
\documentclass{article}
\title{Sample title}
\author{Sample author}
\date{}
\begin{document}
\maketitle
\section{Sample section}
\end{document}
\end{SaveVerbatim}

\begin{frame}[fragile]
  \frametitle{\LaTeX{} code}

  \begin{columns}
    \begin{column}{.5\linewidth}
    \UseVerbatim{CodeBox}
    \end{column}

    \begin{column}{.5\linewidth}
      \includegraphics[width=\linewidth]{article}%
    \end{column}
  \end{columns}
\end{frame}

\end{document}

If you want to include a specific page from article.pdf, use the key-value page=<num> to include page <num> from article.pdf. You could also frame the page by using instead

\fbox{\includegraphics[width=\dimexpr\linewidth-2\fboxsep-2\fboxrule]{article}}

Note that code is stored in a box using fancyvrb and recalled inside the frame. Since you're dealing with beamer containing verbatim-like content, set the frame properties to [fragile].

Related Question