[Rd] Rd.sty question: LaTeX expert needed

Duncan Murdoch murdoch at stats.uwo.ca
Thu Oct 1 18:50:22 CEST 2009

The Rd.sty LaTeX package is used when building the R manuals, and by the 
  LaTeX pages produced from the man pages.

I have tracked down some problems Gábor Csárdi was having recently (see 
"Re: [R] preformatted and '#' in manual pages" in R-help) to a LaTeX 
problem, and am trying to work out how to fix it.

Specifically, the .Rd file he was using had a structure like

     line 1
     line 2

which tools::Rd2latex in R translates to the similar LaTeX code

     line 1
     line 2

The problem is that the alltt environment (which is a sort of verbatim 
environment, except macros are allowed) doesn't work when embedded like 
this in the \dQuote{} macro. Gábor was getting errors when his line 1 
contained a # symbol, and when I dealt with that, I found the formatting 
was getting messed up, and the section ended up being rendered as

line 1 line 2

  The \dQuote macro has a simple definition in Rd.sty as


so I expect the same error will happen with many other macros in Rd.sty.

So, my questions:  Is there a known workaround for this in alltt?

If not, I could skip the macro expansion of \dQuote by generating the 
quotes directly in Rd2latex, and most other macros could be handled 
similarly.  However, then nobody who uses Rd.sty would be able to 
redefine the look of those macros and have things display properly.

A third possibility is that we could make it illegal to nest 
\preformatted within other macros, but that seems to be an unfortunate 

Any help would be appreciated.

Duncan Murdoch

More information about the R-devel mailing list