When running pgfSweave using a file with the following sample code:

In this example we embed parts of the examples from the
\texttt{kruskal.test} help page into a \LaTeX{} document :
kruskal.test(Ozone ~ Month, data = airquality)

and this command:


the following error occurs:

...(latex header)....
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty")))
! Missing \endcsname inserted.
<to be read again> 
...(latex crashing out)...

This file works fine with this command:


and then "latex sweave.tex" at the command line.


I found the answer here:

On Thu, Feb 11, 2010 at 6:36 PM, Yihui Xie wrote: If I understand pgfSweave correctly, a line like this


will be added to the preamble of your LaTeX document if you didn't explicitly add \usepackage{Sweave} by yourself.

That will cause the error like

Missing \endcsname inserted

When I add \usepackage{Sweave} to the above file it works fine.

  • 1
    This issue just bites users again and again. It is one tiny reason motivating the knitr package: if you like pgfSweave, you probably can experiment with library(knitr); knit('your_input.Rnw') too. – Yihui Xie Feb 13 '12 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.