![Beamer 中 Sweave 输出的 FancyVerb 错误](https://linux22.com/image/234880/Beamer%20%E4%B8%AD%20Sweave%20%E8%BE%93%E5%87%BA%E7%9A%84%20FancyVerb%20%E9%94%99%E8%AF%AF.png)
我在将 Sweave 输出包含到 Beamer 文件中时遇到了麻烦。具体来说,Soutput
环境导致了问题(如果我注释掉这些行,它就会运行,但当然,表格不会以单行和标准字体显示)。这是基本文件:
\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}
错误的细节如下:
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.
感谢您提供的任何帮助。
答案1
摘自 Beamer 手册(第 12.9 节逐字和脆弱的文本在版本 3.10 中):
如果您希望
{verbatim}
在框架中使用环境,则必须将选项添加[fragile]
到{frame}
环境中。在这种情况下,您确实必须使用环境{frame}
(而不是\frame
命令),并且\end{frame}
必须单独一行。
因此,您要做的就是用\begin{frame}
替换\begin{frame}[fragile]
。