TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

migrated from stackoverflow.com Feb 13 '12 at 21:46

This question came from our site for professional and enthusiast programmers.

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.

share|improve this answer
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 Feb 13 '12 at 19:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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