From murdoch.duncan at gmail.com  Thu Nov  3 13:19:44 2011
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Thu, 03 Nov 2011 08:19:44 -0400
Subject: [Rd] R CMD check and error in an \Sexpr in an Rd file
In-Reply-To: <4EB281F4.3060109@cbio.uct.ac.za>
References: <4EB281F4.3060109@cbio.uct.ac.za>
Message-ID: <4EB286E0.7070504@gmail.com>

On 11-11-03 7:58 AM, Renaud Gaujoux wrote:
> Georgi, I tried with paste() instead of cat(), but I then get the
> following in my PDF manual:
>
> [1] "line\nnext line"
>
> i.e. what would be printed in the R console, which is not what I want.
> I would like to get something like this in the Latex code:
>
> \begin{verbatim}
> line
> next line
> \end{verbatim}

I don't think you want that:  it forces display mode.  You might want 
verbatim text displayed inline, like \verb does.

>
> Using cat() I get the following in the Latex code:
>
> \AsIs{
> line
> next line}
>
> which does not render as a new line in the PDF and breaks if empty lines
> are present in the output text.

So the problem is with the \AsIs macro.  You can see the definition in 
the Rd.sty file in R_HOME/share/texmf/tex/latex.  Can you suggest an 
improvement?

Duncan Murdoch

> Besides it will also break on \Sexpr[results=verbatim,
> stage=render]{list("text", 3)}.
>
> But maybe this is not what 'results=verbatim' is supposed to do nor to
> be used for?
>
> Renaud
>
> Another test Rd file.
>
> %%%%%%%%%
> \name{Sexpr}
> \alias{Sexpr}
> \title{Error and verbatim in Sexpr}
> \description{
>      Testing Sexpr in Rd files
>
>      %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")}
>
>      Verbatim:
>
>      1: \Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n")}
>
>      2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"}
>
>      3: \Sexpr[results=verbatim, stage=render]{list("line\nnext line", 3)}
>
>      Text:
>
>      1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")}
>
>      2: \Sexpr[results=text, stage=render]{"line\nnext line\n"}
>
>      3: \Sexpr[results=text, stage=render]{list("line\nnext line", 3)}
>
> }
> %%%%%
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] R CMD check and error in an \Sexpr in an Rd file
Duncan Murdoch