似乎该\only
命令不能用于显示R
块。以下是产生错误的 MWE:
\documentclass[11pt]{beamer}
\usetheme{Warsaw}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
<<setup, include=FALSE>>=
library(knitr)
@
\title{Title}
\begin{document}
\section{Section name}
\begin{frame}[fragile]
\frametitle{\insertsection}
Add \verb!\only<1>{ ... }! around the code chunk to produce crash
<<>>=
2+2
@
\end{frame}
\end{document}
我收到此错误消息
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, : Running 'texi2dvi' on 'KnitrOnly.tex' failed. LaTeX errors: ! Paragraph ended before \@xverbatim was complete. <to be read again> \par l.16 } ! LaTeX Error: \begin{kframe} on input line 16 ended by \end{beamer@framepauses }. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ! Missing } inserted. <inserted text> } l.85 \end{frame}
! Extra }, or forgotten \endgroup. \endbeamer@frameslide ...amer@framepauses}\egroup \ifx \beamer@frametitle \@... l.85 \end{frame} ! LaTeX Error: \begin{knitrout} on input line 16 ended by \end{beamer@frameslid e}. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ! LaTeX Error: \begin{beamer@framepauses} on input line 85 ended by \end{docume nt}. See the LaTeX manual or LaTeX Companion