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.sty question: LaTeX expert needed
3 messages · Duncan Murdoch, Romain Francois, Gábor Csárdi
Hi, I would not claim I'm a latex expert ... In the highlight package, I also use alltt environments the latex renderer of syntax highlighted code, and I ended up masquarading a set of character (#, \, ...) into latex boxes and then use \usebox for these characters. In this file : http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/highlight/R/renderer.R?rev=168&root=highlight&view=markup The functions boxes_latex and translator_latex might interest you. The list of boxed characters might not be complete. Hope this helps, Romain
On 10/01/2009 06:50 PM, Duncan Murdoch wrote:
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
Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc |- http://tr.im/yw8E : New R package : sos `- http://tr.im/y8y0 : search the graph gallery from R
On Thu, Oct 1, 2009 at 6:50 PM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
[...]
\dQuote{
?...
?\preformatted{
? ?line 1
? ?line 2
?}
}
[...] Oh, there was a dQuote as well, I must be an idiot for not noticing it. :( Anyway, for me, I will just remove the dQuote and everything will be fine. Sorry, this is not a solution for the more general problem.... Thanks for your help, Gabor
Gabor Csardi <Gabor.Csardi at unil.ch> UNIL DGM