8

I'm having trouble including Sweave output in my Beamer file. Specifically, the Soutput environment is causing problems (it runs if I comment those lines out, but, of course, the table is not presented as a single row and in standard font). Here is the basic file:

\documentclass{beamer}
\usepackage{Sweave}
\begin{document}

\begin{frame}{Comparison}
\begin{Schunk}
\begin{Soutput}
  Gender Admitted Rejected
1 Female        6        6
2   Male        6        6
\end{Soutput}
\end{Schunk}
\end{frame}

\end{document}

And the error in its gory detail:

ERROR: FancyVerb Error:

--- TeX said ---
  Extraneous input `Gender Admitted Rejected 1 Female 6 6 2 Male 6 6 \end {Soutput} \end {Schunk} \end {beamer@frameslide}\ifbeamer@twoscreenstext \beamer@dosecondscreennow {{Comparison} \begin {Schunk} \begin {Soutput} Gender Admitted Rejected 1 Female 6 6 2 Male 6 6 \end {Soutput} \end {Schunk} }\fi \ifbeamer@anotherslide \advance \beamer@slideinframe by 1\relax \relax \expandafter \iterate \fi \let \iterate \relax \beamer@writeslidentry \beamer@reseteecodes ' between \begin{Soutput}[<key=value>] and line end
.
\FV@Error ... {FancyVerb Error:
\space \space #1
}

l.13 \end{frame}

--- HELP ---
From the .log file...

This input will be discarded. Hit <return> to continue.

Thanks for any assistance that you can provide.

Hendrik Vogt
  • 37,935
Charlie
  • 781
  • 1
    I don't use sweave, so I can't test, but does starting the frame with \begin{frame}[fragile] help? – Caramdir Feb 21 '11 at 04:48
  • Yes, thank you! I'll have to find out more about the fragile option for the frame environment. – Charlie Feb 21 '11 at 05:33
  • Note that it is unusual around here to sign your questions (as there is already a box with your username below it) or to have any greeting. – Hendrik Vogt Feb 21 '11 at 07:09

1 Answers1

9

From the beamer manual (section 12.9 Verbatim and Fragile Text in version 3.10):

If you wish to use a {verbatim} environment in a frame, you have to add the option [fragile] to the {frame} environment. In this case, you really have to use the {frame} environment (not the \frame command) and the \end{frame} must be alone on a single line.

So all you have to do is to replace \begin{frame} by \begin{frame}[fragile].

Caramdir
  • 89,023
  • 26
  • 255
  • 291