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.

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.

enter image description here

%-------------------------------[ 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}
share|improve this question

migrated from stackoverflow.com Nov 19 '12 at 15:46

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

1  
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
2  
@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
    
We'd like to keep answers separate from questions, so you should write a separate answer instead of editing your answer into the question. Self-answers are perfectly admissible, and a well-written answer may earn you additional reputation. –  lockstep Nov 20 '12 at 10:04
    
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

1 Answer 1

up vote 5 down vote accepted

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}
share|improve this answer

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.