yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.39k stars 878 forks source link

data.frame cannot be used in latex document with beamer class #517

Closed gangchen closed 11 years ago

gangchen commented 11 years ago

LaTeX codes:

 \documentclass[UTF8]{beamer}

 \begin{document}

 \begin{frame}
  \frametitle{test}
 %%begin.rcode
 % data.frame()
  %%end.rcode
  \end{frame}

  \end{document}

Processing command:

  knit("test.Rtex", encoding="UTF-8")

Compile command:

 xelatex test.tex

Error message:

 ! Illegal parameter number in definition of \beamer@doifinframe.
 <to be read again> 

  l.73 \end{frame}
yihui commented 11 years ago

That is not a problem of data.frame(), but a beamer problem: you have to use the [fragile] option when a frame contains verbatim code, e.g.

\begin{frame}[fragile]
\frametitle{test}
%%begin.rcode
% data.frame()
%%end.rcode
\end{frame}
gangchen commented 11 years ago

Thanks.

But it seems that some frames can work without [fragile] option.

yihui commented 11 years ago

Yes, they work when they do not contain verbatim code.

ghost commented 11 years ago

Thaks Yihui, you are a rock star!

github-actions[bot] commented 4 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.