[R-pkg-devel] 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 16:53:42 CEST 2020

Seems like you are using roxygen2. I have little experience with that, as all my Rd files are 'handcrafted' (plus 100% organic and biodegradable).

But what specifically do you mean by "when I try to preview the current document as HTML"? Is this some particular functionality of roxygen2 / devtools / RStudio? Or do you simply mean using tools::Rd2HTML()? Then you will have to use permissive=TRUE so that the macros from mathjaxr (which will not be recognized by default by parse_Rd()) are just passed through as text. Or you could try adjusting the 'macros' argument, maybe in combination with loadPkgRdMacros(), to specify that the mathjaxr macros should be loaded. See help(Rd2HTML, package="tools") and help(parse_Rd, package="tools") for details.

But if I want to see the HTML help file, I just install and load the package and call up the help file on some function. That works for sure.

As for the more complex equation - it includes a lot of curly braces. See the note I added recently to the 'devel' version about this:



>-----Original Message-----
>From: Tiago Olivoto [mailto:tiagoolivoto using gmail.com]
>Sent: Wednesday, 13 May, 2020 16:20
>To: Viechtbauer, Wolfgang (SP); r-package-devel using r-project.org
>Subject: RES: [R-pkg-devel] MathJax for Rd files
>Dear Wolfgang,
>Thank you so much for the awesome package
>I've installed mathjaxr and it worked.
>I have some more questions, with a short example bellow
>I created an equation in my mgidi.R file as follows
>#' \loadmathjax
>#' \mjsdeqn{MGIDI_i = \sum\limits_{j = 1}^f}
>And then I ran devtools::document()
>The mgidi.Rd contains
>\mjsdeqn{MGIDI_i = \sum\limits_{j = 1}^f}
>But when I try to preview the current document as HTML, the equation is not
>rendered and the help page shows
>\loadmathjax \mjsdeqnMGIDI_i = \sum\limits_j = 1^f
>The equation is only rendered after I install my package locally with
>devtools::install(). Is this an expected behavior?
>Another question is regarding more complex formulae.
>I tried using
>#' \loadmathjax
>#' \mjsdeqn{MGID{I_i} = {\left[ {\sum\limits_{j = 1}^f {{{\left( {{F_{ij}} -
>{F_j}} \right)}^2}} } \right]^{0.5}}}
>Even after installing the package locally the equation is not rendered in
>the html help page, which shows the tex command.
>I tested the same equation with https://www.mathjax.org/#demo and it seems
>to be ok.
>Have I missed anything or used any code not supported by mathjaxr?
>Thanks in advance
>-----Mensagem original-----
>De: Viechtbauer, Wolfgang (SP)
><wolfgang.viechtbauer using maastrichtuniversity.nl>
>Enviada em: quarta-feira, 13 de maio de 2020 04:40
>Para: tiagoolivoto using gmail.com; r-package-devel using r-project.org
>Assunto: RE: [R-pkg-devel] MathJax for Rd files
>Dear Olivoto,
>There is a package now for this purpose:
>>-----Original Message-----
>>From: R-package-devel [mailto:r-package-devel-bounces using r-project.org] On
>>Behalf Of Tiago Olivoto
>>Sent: Wednesday, 13 May, 2020 8:55
>>To: r-package-devel using r-project.org
>>Subject: [R-pkg-devel] MathJax for Rd files
>>Dear all,
>>I'm not sure if this is the correct place to make this question, but
>>here I am.
>>I'm trying to use MathJax for html help files in my package metan
>>I have success with the following approach:
>>Including the following call
>>#'<script id="MathJax-script" async
>>#'  </script>
>>And then typing the equations I need. A simple example bellow
>>#' \ifelse{html}{\out{\[\sqrt{a^2}\]}}{\deqn{\sqrt{a^2}}}
>>Is there any way to put "tex-chtml-full.js" locally so that everyone
>>that has my package installed see the equations rendered properly even
>>Thanks in advance

More information about the R-package-devel mailing list