# [R-pkg-devel] Macros in Rd files.

Georgi Boshnakov georgi.boshnakov at manchester.ac.uk
Fri Nov 10 10:57:47 CET 2017

>http://developer.r-project.org/parseRd.pdf

I would add that it is best to think of "Rd markup" as a subset of TeX/LaTeX markup (with some extentions) defined in
"Writing R Extensions" and Duncan's reference above.

The "subset" is important - if a feature is not mentioned in these references, it is not available.
I once inadvertently used a modifier in the tabular environment (maybe something like {l|l|l} which was fine for 'R CMD check', the pdf manual and CRAN but the package failed to install on a system setup for static installation of html documentation.

Georgi Boshnakov

-----Original Message-----
From: R-package-devel [mailto:r-package-devel-bounces at r-project.org] On Behalf Of Duncan Murdoch
Sent: 09 November 2017 23:08
To: Rolf Turner
Cc: r-package-devel at r-project.org
Subject: Re: [R-pkg-devel] Macros in Rd files.

On 09/11/2017 3:05 PM, Rolf Turner wrote:
> On 09/11/17 23:40, Duncan Murdoch wrote:
>> On 09/11/2017 5:06 AM, Uwe Ligges wrote:
>>> Note the % may be a comment?
>>>
>>
>> Yes, and the body should be written in Rd markup, not R.  Working out
>> the appropriate number of escapes is painful; I recommend trial and error.
>>
>> This worked for me:
>>
>>
>> \newcommand{\today}{\Sexpr{format(Sys.Date(),"\\\%d/\\\%m/\\\%Y")}}
>
> Now that is a bit more subtle!  I don't understand what "written in Rd
> markup" really means, and I don't understand the "\Sexpr" construction.
> I'd seen it when looking at the example macros in
>
>      /usr/local/lib64/R/share/Rd/macros/system.Rd
>
> but I figured if you know nothing about it, don't mess with it.
>
> Is there anywhere that I could read up about writing "in Rd markup"?

Not sure this would be helpful, but there's

http://developer.r-project.org/parseRd.pdf

The short summary is this:

Rd files are a mess.  There are several different modes of parsing that
apply:  at the top level you have Rd code, and in different contexts you may have R code (or something close to it), or verbatim code (just kidding!  There are ways to signal you want out).  Table 1 in that document says what syntax is expected within what macro.  In \newcommand, it says it wants "verbatim" input, but really it's going to interpret that as Rd input, i.e. LaTeX-like.

Duncan Murdoch

>
> Anyway, thanks for giving me the recipe, which is what I really need.
>
> cheers,
>
> Rolf
>

______________________________________________
R-package-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel