[R-pkg-devel] RES: RES: MathJax for Rd files

Viechtbauer, Wolfgang (SP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Wed May 13 23:25:43 CEST 2020

I've added a preview_rd() function to the 'devel' version of mathjaxr:


If you want to give this a try:


Then set the working dir to the root of the package you are working on. Then use:


with the name of the Rd file given as a character string (either with or without the .Rd/.rd extension).

By default, the browser (or a new tab in your browser) should open up. But if you then make further changes to the Rd file, opening up a new tab each time is inconvenient. Use:

preview_rd(Rdfile, view=FALSE)

to prevent that (then just refresh the page in the open tab in your browser to see the updates).

One limitation: As far as I can tell, it will not be possible to load MathJax from the mathjaxr package when using preview_rd(). So, it will be loaded via the CDN, which means that you need an internet connection for equations to render.


>-----Original Message-----
>From: Tiago Olivoto [mailto:tiagoolivoto using gmail.com]
>Sent: Wednesday, 13 May, 2020 21:25
>To: 'Duncan Murdoch'; Viechtbauer, Wolfgang (SP); r-package-devel using r-
>Subject: RES: RES: [R-pkg-devel] RES: MathJax for Rd files
>Definitively this is a better way to find the macros.
>I think a function like 'preview_rd()' could be useful in mathjaxr
>Thanks for all support
>-----Mensagem original-----
>De: Duncan Murdoch <murdoch.duncan using gmail.com>
>Enviada em: quarta-feira, 13 de maio de 2020 16:16
>Para: tiagoolivoto using gmail.com; 'Viechtbauer, Wolfgang (SP)'
><wolfgang.viechtbauer using maastrichtuniversity.nl>; r-package-devel using r-
>Assunto: Re: RES: [R-pkg-devel] RES: MathJax for Rd files
>On 13/05/2020 2:30 p.m., Tiago Olivoto wrote:
>> Thank you so much! It works!
>> In my example, I've created a simple helper function, preview_rd()
>> preview_rd <- function(rdfile){ # without '.rd'
>> Rd <- file.path(paste("man/", rdfile, ".rd", sep = "")) # specify the
>> .Rd file you want to preview outfile <- tempfile(fileext = ".html")
>> browseURL(tools::Rd2HTML(Rd, outfile,
>> macros="D:/Documents/R/win-library/4.0/mathjaxr/help/macros/mathjax.Rd
>> "))
>> }
>Good to hear.  I'd suggest this way to find the macros:
>   browseURL(tools::Rd2HTML(Rd, outfile, macros =
>system.file("help/macros/mathjax.Rd", package = "mathjaxr")))
>so that it works if you use it on a different system that puts the library
>somewhere else.
>Duncan Murdoch

More information about the R-package-devel mailing list