Re: [R] inserting R code in a latex document

From: Uwe Ligges <>
Date: Wed 11 May 2005 - 18:09:07 EST

Thibaut Jombart wrote:

> Hello,
> I'm trying to insert R source code (functions) in an appendix of a latex
> document. I guess the easiest way to do so is to use the package Sweaved
> (file : Sweaved.sty) provided with the latest R version. Latex succeeds
> in loading the package, but my problem comes from the use of this very
> package. I tried to use the 'Schunk' environment, but '#' characters
> generate error (my R functions are annotated, and I want to keep those
> annotations). Under the 'Sinput' environment, no error is generated but
> the result is simply not different from what would be obtained under
> 'verbatim' environment : R code lines are cut as they don't fit in the
> page width.
> I tried to find answers in the latest Sweaved User Manual,
> unsuccessfully. I'm a recent latex user and I doubt I can quickly find a
> solution by myself.

I think we are talking about "Sweave" in package "utils"? If so, you will find that you have to re-read the manual, because you don't need to specify 'Schunk'/'Sinput' yourself: Sweave does it for you. Just write the code in code chunks such as

# comment
LaTeX code

and apply Sweave on your noweb document, the resulting LaTeX document has appropriate environments.

Uwe Ligges

> Thanks,
> Thibaut Jombart
> ______________________________________________
> mailing list
> PLEASE do read the posting guide!
> mailing list PLEASE do read the posting guide! Received on Wed May 11 18:13:12 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:41 EST