# Two column layout with text and knitr chunk

When making presentations (with latex beamer class), I often go for a frame layout with text and equations on the left and a corresponding figure on the right. My standard solution has been to wrap the text in a minipage and figure in another minipage and add a small space in between, but it does not work when replacing the figure with a knitr chunk.

As this is a common slide design I hope someone out there knows how to produce it.

%-------------------------------[ Text + pdf on disk works fine ]
\begin{frame}
\begin{minipage}{5cm}
Text
\end{minipage}
\hspace{.5cm}
\begin{minipage}{5cm}
\begin{figure}
\includegraphics{my_figure.pdf}
\end{figure}
\end{minipage}
\end{frame}

%-------------------------------[ Text + knitr chunk does not work ]
\begin{frame}
\begin{minipage}{5cm}
Text
\end{minipage}
\hspace{.5cm}
\begin{minipage}{5cm}
<<echo=FALSE,eval=TRUE,out.width='4cm',out.height='4cm'>>=
plot(1:10)
@
\end{minipage}
\end{frame}

-
i've had some success with \begin{columns}... in beamer+ knitr. –  baptiste Nov 16 '12 at 10:02
Thanks! I got it working now. I was experimenting with it too earlier, but couldn't figure out how and abandoned it. There is just such a vast amout of possibilities in LaTeX you can't follow every lead through, unless you know it can do the job. If you want some rep I'd be happy to accept an answer from you. Just post anything and I'll edit it to the solution I arrived at. –  Backlin Nov 16 '12 at 10:17
@Backlin one tiny tip: use results='asis' when you only want to show the figure and nothing else; it will make the knitr output cleaner –  Yihui Nov 16 '12 at 17:43
Aye-aye! I tried that first, but the popup made me think editing my original questian was preferred by the community. –  Backlin Nov 20 '12 at 10:12

## migrated from stackoverflow.comNov 19 '12 at 15:46

This question came from our site for professional and enthusiast programmers.

This is the answer I arrived at with the help of @baptiste and it works just like I wanted it to.

\begin{frame}
\begin{columns}
\begin{column}{.5\linewidth}
Text
\end{column}
\begin{column}{.5\linewidth}
<<echo=FALSE,eval=TRUE,out.width='4cm',out.height='4cm'>>=
plot(1:10)
@
\end{column}
\end{columns}
\end{frame}

-