# FancyVerb error for Sweave output in Beamer

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}
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.

-
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 4:48
Yes, thank you! I'll have to find out more about the fragile option for the frame environment. –  Charlie Feb 21 '11 at 5: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 7:09
Could you please accept my answer below (as it seems to be the solution to your question), so that we can get this question off the “Unanswerd” list. –  Caramdir Feb 23 '11 at 21:28

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]`.