[Rd] Output multiline verbatim in Rd files with \Sexpr in PDF manual

Duncan Murdoch murdoch.duncan at gmail.com
Fri Oct 28 16:52:42 CEST 2011

On 28/10/2011 10:36 AM, Renaud Gaujoux wrote:
> Hi,
> I want to output some generated text in verbatim in a Rd file, but do
> not succeed in getting it render well in all versions (text, html and pdf).
> I tried something like:
> \Sexpr[results=verbatim, stage=render]{cat("line\nnext line")}
> I use Rdconv to render each version of the man page.
> This produced the expected effect in html, but resulted in a single line
> "line next line" in the pdf and text versions.
> Moreover, if I add an empty line as in:
> \Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n\nyet
> another line")}
> then the html is still correctly rendered, the text version correctly
> shows the empty newline (but still not the firts line break), and the
> pdf cannot be generated from the Latex code (because \AsIs breaks on the
> newline).
> I tried several combination of options (results=text, rd) and rd
> commands (\cr, \preformated) but these are always somehow escaped when
> generating the Latex file.
> Is there a way to go around these issues? Maybe I am not using the
> correct way.

Which version of R are you using?  There was a bug in 2.13.2 that caused 
some strange behaviour.

Duncan Murdoch

More information about the R-devel mailing list