Duncan, it's the first example you provide that I'm looking to do. These Sexpr quickly exceed 80 columns and I was wanting to make them more readable in the latex code by blocking and indenting the R code. Dieter suggests putting the R code into a code block then Sexpr-ing that object. That seems like the way to go, but it seems not to take full advantage of the language. Thank you both. David
-----Original Message----- From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] Sent: Tuesday, June 30, 2009 1:16 PM To: David Huffer Cc: r-help@r-project.org Subject: Re: [R] Sweave: multiline Sexpr? On 30/06/2009 12:44 PM, David Huffer wrote: > Is there any way to have Sexpr span multiple lines? For input or output? I.e. do you want \Sexpr{x + y} or do you want the value to display on multiple lines? I think you can't do the first. To do the second, returning a character value with an embedded newline should work. For example, <<echo=FALSE>>= string <- "this goes on \\\\\\\\\n two lines" @ \Sexpr{string} (I think you really need all those escapes to get two backslashes in the output!) I don't know if it will happen for 2.10.x, but I would like to extend \Sexpr to be just as flexible as the <<>>= notation, by putting the Sweave options in a Latex-like option: \Sexpr[fig=true]{ plot(rnorm(1000))} You can do this now in R-devel in the new Sweave-like syntax in Rd files (except they don't support figs yet), but not yet in the original. Duncan Murdoch ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.