From murdoch at stats.uwo.ca  Thu Oct  1 18:50:22 2009
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Thu, 01 Oct 2009 12:50:22 -0400
Subject: [Rd] Rd.sty question: LaTeX expert needed
Message-ID: <4AC4DDCE.2000203@stats.uwo.ca>

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

\dQuote{
   ...
   \preformatted{
     line 1
     line 2
   }
}

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

\dQuote{
   ...
   \begin{alltt}
     line 1
     line 2
   \end{alltt}
}

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

\newcommand{\dQuote}[1]{``#1''}

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 
limitation.

Any help would be appreciated.

Duncan Murdoch



[Rd] Rd.sty question: LaTeX expert needed
Duncan Murdoch