I would like to put R code into a parameter of a newcommand in LaTeX. To do it, I make the following:
%Define the newcommand:
\newcommand\solution[1]{\sf #1}
%Then, after the \begin{document}, I write:
\solution{
<<echo=T>>=
x=rnorm(100)
@
}
in my .Rnw file.
After I do R CMD Sweave file.Rnw, all is OK but when I do
pdflatex file.tex, the response is:
! FancyVerb Error:
Extraneous input `> x=rnorm(100) \end {Sinput} \end {Schunk} ' between \begin
{Sinput}[<key=value>] and line end
.
\FV@Error ... {FancyVerb Error:
\space \space #1
}
l.12 }
Somebody can help me?
{}) or select your code and hit Ctrl+K. – Claudio Fiandrino Feb 7 at 12:09\sfwould fail. It will probably be easier to debug by working on the LaTeX file produced by Sweave ... – Ben Bolker Feb 7 at 13:54