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
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel