Re: [R-pkg-devel] RES: MathJax for Rd files
Glad to hear that. I might consider adding a function along those lines to mathjaxr itself, to make it easier to preview files while working on a help page. Best, Wolfgang >-Original Message- >From: Tiago Olivoto [mailto:tiagooliv...@gmail.com] >Sent: Wednesday, 13 May, 2020 20:31 >To: Viechtbauer, Wolfgang (SP); 'Duncan Murdoch'; r-package-devel@r- >project.org >Subject: RES: [R-pkg-devel] RES: MathJax for Rd files > >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")) >} > >I added the macros \loadmathjax and \mjsdeqn in the mgidi.R file, ran >devtools::document() and then preview_rd("mgidi") >The html was rendered nicely (in my browser) and shows the equation without >installing the package. >That's what I was looking for. >Thanks again! >Olivoto > >-Mensagem original- >De: Viechtbauer, Wolfgang (SP) > >Enviada em: quarta-feira, 13 de maio de 2020 14:41 >Para: Duncan Murdoch ; tiagooliv...@gmail.com; r- >package-de...@r-project.org >Assunto: RE: [R-pkg-devel] RES: MathJax for Rd files > >Thanks, Duncan. I was about to respond to suggest the same thing. > >One way of getting this to work: > >Sys.setenv(MATHJAXR.USECDN = "TRUE") >Rd <- file.path("/.Rd") # specify the .Rd file you want to >preview outfile <- tempfile(fileext = ".html") browseURL(tools::Rd2HTML(Rd, >outfile, macros="installed>/mathjaxr/help/macros/mathjax.Rd")) > >Best, >Wolfgang > >>-----Original Message- >>From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] >>Sent: Wednesday, 13 May, 2020 19:30 >>To: tiagooliv...@gmail.com; Viechtbauer, Wolfgang (SP); 'Helmut >>Schütz'; r- package-de...@r-project.org >>Subject: Re: [R-pkg-devel] RES: MathJax for Rd files >> >>On 13/05/2020 12:35 p.m., Tiago Olivoto wrote: >>> Thanks, Wolfgang and Helmut for the explanations. >>> When I was trying to use >>> >>> #'\if{html}{\out{'>> #''src="<a rel="nofollow" href="https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-chtml-full">https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-chtml-full</a> >>> .js >>> #' }} >>> #' >>> #'And then typing >>> #' \ifelse{html}{\out{\[\sqrt{a^2}\]}}{\deqn{\sqrt{a^2}}} >>> My mgidi.Rd file was produced with devtools::document(); then, I just >>> used ?mgidi, and the html page was rendered nicely. >>> >>> If I could do the same with mathjaxr, It would be nice, because I >>> wouldn't >>need to install the package to see if the equations are as I expect >>> Anyway, mathjaxr is a very useful package. >>> Congratulations on the efforts for developing it. >> >>Sounds like it's a devtools issue. I don't know how they are >>simulating the install, but it needs to say to use the mathjaxr macros >>when converting the Rd pages. >> >>Duncan Murdoch >> >>> Best >>> Olivoto >>> >>> -Mensagem original- >>> De: Viechtbauer, Wolfgang (SP) >> >>> Enviada em: quarta-feira, 13 de maio de 2020 13:14 >>> Para: Helmut Schütz ; >>> tiagooliv...@gmail.com; r- >>package-de...@r-project.org >>> Assunto: RE: [R-pkg-devel] MathJax for Rd files >>> >>> Thanks for the info! Can confirm now that I tried this (I don't >>> usually >>use RStudio). That's an RStudio issue then. My guess is that 'Preview' >>uses >>tools::Rd2HTML() and that indeed won't automatically understand macros >>coming from mathjaxr (or any add-on package for that matter). This >>would be an issue to raise with the RStudio folks then. >>> >>> But once a package is installed, the equations are nicely rendered >>> also in >>the RStudio help browser, so that part works. >>> >>> Best, >>> Wolfgang >>> >>>> -Original Message- >>>> From: Helmut Schütz [mailto:helmut.schu...@bebac.at] >>>> Sent: Wednesday, 13 May, 2020 17:01 >>>> To: Viechtbauer, Wolfgang (SP); tiagooliv...@gmail.com; >>>> r-package-devel@r- project.org >>>> Subject: Re: [R-pkg-devel] MathJax for Rd files >>>> >>>> Hi Wolfgang, >>>> >>>> Viechtbauer, Wolfgang (SP) wrote on 2020-05-13 16:53: >>>>> Seems like you are using roxygen2. I have little experience with >>>>> that, as >>>> all my Rd files are 'handcrafted' (plus 100% organic and biodegradable). >>>> >>>> As are mine. ;-) >>>> In the HTML-preview of RStudio the LaTeX is indeed not parsed. I get >>>> it only (in the HTML man-page and the PDF) if I build the package. >>>> >>>> Helmut >>>> >>>> -- >>>> Ing. Helmut Schütz >>>> BEBAC – Consultancy Services for >>>> Bioequivalence and Bioavailability Studies Neubaugasse 36/11 >>>> 1070 Vienna, Austria >>>> E helmut.schu...@bebac.at >>>> W https://bebac.at/ >>>> F https://forum.bebac.at/ __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] RES: MathJax for Rd files
Thanks, Duncan. I was about to respond to suggest the same thing. One way of getting this to work: Sys.setenv(MATHJAXR.USECDN = "TRUE") Rd <- file.path("/.Rd") # specify the .Rd file you want to preview outfile <- tempfile(fileext = ".html") browseURL(tools::Rd2HTML(Rd, outfile, macros="/mathjaxr/help/macros/mathjax.Rd")) Best, Wolfgang >-Original Message- >From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] >Sent: Wednesday, 13 May, 2020 19:30 >To: tiagooliv...@gmail.com; Viechtbauer, Wolfgang (SP); 'Helmut Schütz'; r- >package-de...@r-project.org >Subject: Re: [R-pkg-devel] RES: MathJax for Rd files > >On 13/05/2020 12:35 p.m., Tiago Olivoto wrote: >> Thanks, Wolfgang and Helmut for the explanations. >> When I was trying to use >> >> #'\if{html}{\out{'> #''src="<a rel="nofollow" href="https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-chtml-full.js">https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-chtml-full.js</a> >> #' }} >> #' >> #'And then typing >> #' \ifelse{html}{\out{\[\sqrt{a^2}\]}}{\deqn{\sqrt{a^2}}} >> My mgidi.Rd file was produced with devtools::document(); >> then, I just used ?mgidi, and the html page was rendered nicely. >> >> If I could do the same with mathjaxr, It would be nice, because I wouldn't >need to install the package to see if the equations are as I expect >> Anyway, mathjaxr is a very useful package. >> Congratulations on the efforts for developing it. > >Sounds like it's a devtools issue. I don't know how they are simulating >the install, but it needs to say to use the mathjaxr macros when >converting the Rd pages. > >Duncan Murdoch > >> Best >> Olivoto >> >> -Mensagem original- >> De: Viechtbauer, Wolfgang (SP) > >> Enviada em: quarta-feira, 13 de maio de 2020 13:14 >> Para: Helmut Schütz ; tiagooliv...@gmail.com; r- >package-de...@r-project.org >> Assunto: RE: [R-pkg-devel] MathJax for Rd files >> >> Thanks for the info! Can confirm now that I tried this (I don't usually >use RStudio). That's an RStudio issue then. My guess is that 'Preview' uses >tools::Rd2HTML() and that indeed won't automatically understand macros >coming from mathjaxr (or any add-on package for that matter). This would be >an issue to raise with the RStudio folks then. >> >> But once a package is installed, the equations are nicely rendered also in >the RStudio help browser, so that part works. >> >> Best, >> Wolfgang >> >>> -Original Message- >>> From: Helmut Schütz [mailto:helmut.schu...@bebac.at] >>> Sent: Wednesday, 13 May, 2020 17:01 >>> To: Viechtbauer, Wolfgang (SP); tiagooliv...@gmail.com; >>> r-package-devel@r- project.org >>> Subject: Re: [R-pkg-devel] MathJax for Rd files >>> >>> Hi Wolfgang, >>> >>> Viechtbauer, Wolfgang (SP) wrote on 2020-05-13 16:53: >>>> Seems like you are using roxygen2. I have little experience with >>>> that, as >>> all my Rd files are 'handcrafted' (plus 100% organic and biodegradable). >>> >>> As are mine. ;-) >>> In the HTML-preview of RStudio the LaTeX is indeed not parsed. I get it >>> only (in the HTML man-page and the PDF) if I build the package. >>> >>> Helmut >>> >>> -- >>> Ing. Helmut Schütz >>> BEBAC – Consultancy Services for >>> Bioequivalence and Bioavailability Studies Neubaugasse 36/11 >>> 1070 Vienna, Austria >>> E helmut.schu...@bebac.at >>> W https://bebac.at/ >>> F https://forum.bebac.at/ __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
Re: [R-pkg-devel] RES: MathJax for Rd files
On 13/05/2020 12:35 p.m., Tiago Olivoto wrote: Thanks, Wolfgang and Helmut for the explanations. When I was trying to use #'\if{html}{\out{'https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-chtml-full.js #' }} #' #'And then typing #' \ifelse{html}{\out{\[\sqrt{a^2}\]}}{\deqn{\sqrt{a^2}}} My mgidi.Rd file was produced with devtools::document(); then, I just used ?mgidi, and the html page was rendered nicely. If I could do the same with mathjaxr, It would be nice, because I wouldn't need to install the package to see if the equations are as I expect Anyway, mathjaxr is a very useful package. Congratulations on the efforts for developing it. Sounds like it's a devtools issue. I don't know how they are simulating the install, but it needs to say to use the mathjaxr macros when converting the Rd pages. Duncan Murdoch Best Olivoto -Mensagem original- De: Viechtbauer, Wolfgang (SP) Enviada em: quarta-feira, 13 de maio de 2020 13:14 Para: Helmut Schütz ; tiagooliv...@gmail.com; r-package-devel@r-project.org Assunto: RE: [R-pkg-devel] MathJax for Rd files Thanks for the info! Can confirm now that I tried this (I don't usually use RStudio). That's an RStudio issue then. My guess is that 'Preview' uses tools::Rd2HTML() and that indeed won't automatically understand macros coming from mathjaxr (or any add-on package for that matter). This would be an issue to raise with the RStudio folks then. But once a package is installed, the equations are nicely rendered also in the RStudio help browser, so that part works. Best, Wolfgang -Original Message- From: Helmut Schütz [mailto:helmut.schu...@bebac.at] Sent: Wednesday, 13 May, 2020 17:01 To: Viechtbauer, Wolfgang (SP); tiagooliv...@gmail.com; r-package-devel@r- project.org Subject: Re: [R-pkg-devel] MathJax for Rd files Hi Wolfgang, Viechtbauer, Wolfgang (SP) wrote on 2020-05-13 16:53: Seems like you are using roxygen2. I have little experience with that, as all my Rd files are 'handcrafted' (plus 100% organic and biodegradable). As are mine. ;-) In the HTML-preview of RStudio the LaTeX is indeed not parsed. I get it only (in the HTML man-page and the PDF) if I build the package. Helmut -- Ing. Helmut Schütz BEBAC – Consultancy Services for Bioequivalence and Bioavailability Studies Neubaugasse 36/11 1070 Vienna, Austria E helmut.schu...@bebac.at W https://bebac.at/ F https://forum.bebac.at/ __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
[R-pkg-devel] RES: MathJax for Rd files
Thanks, Wolfgang and Helmut for the explanations. When I was trying to use #'\if{html}{\out{'https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-chtml-full.js #' }} #' #'And then typing #' \ifelse{html}{\out{\[\sqrt{a^2}\]}}{\deqn{\sqrt{a^2}}} My mgidi.Rd file was produced with devtools::document(); then, I just used ?mgidi, and the html page was rendered nicely. If I could do the same with mathjaxr, It would be nice, because I wouldn't need to install the package to see if the equations are as I expect Anyway, mathjaxr is a very useful package. Congratulations on the efforts for developing it. Best Olivoto -Mensagem original- De: Viechtbauer, Wolfgang (SP) Enviada em: quarta-feira, 13 de maio de 2020 13:14 Para: Helmut Schütz ; tiagooliv...@gmail.com; r-package-devel@r-project.org Assunto: RE: [R-pkg-devel] MathJax for Rd files Thanks for the info! Can confirm now that I tried this (I don't usually use RStudio). That's an RStudio issue then. My guess is that 'Preview' uses tools::Rd2HTML() and that indeed won't automatically understand macros coming from mathjaxr (or any add-on package for that matter). This would be an issue to raise with the RStudio folks then. But once a package is installed, the equations are nicely rendered also in the RStudio help browser, so that part works. Best, Wolfgang >-Original Message- >From: Helmut Schütz [mailto:helmut.schu...@bebac.at] >Sent: Wednesday, 13 May, 2020 17:01 >To: Viechtbauer, Wolfgang (SP); tiagooliv...@gmail.com; >r-package-devel@r- project.org >Subject: Re: [R-pkg-devel] MathJax for Rd files > >Hi Wolfgang, > >Viechtbauer, Wolfgang (SP) wrote on 2020-05-13 16:53: >> Seems like you are using roxygen2. I have little experience with >> that, as >all my Rd files are 'handcrafted' (plus 100% organic and biodegradable). > >As are mine. ;-) >In the HTML-preview of RStudio the LaTeX is indeed not parsed. I get it >only (in the HTML man-page and the PDF) if I build the package. > >Helmut > >-- >Ing. Helmut Schütz >BEBAC – Consultancy Services for >Bioequivalence and Bioavailability Studies Neubaugasse 36/11 >1070 Vienna, Austria >E helmut.schu...@bebac.at >W https://bebac.at/ >F https://forum.bebac.at/ __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
[R-pkg-devel] RES: 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 \loadmathjax \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 Olivoto -Mensagem original- De: Viechtbauer, Wolfgang (SP) Enviada em: quarta-feira, 13 de maio de 2020 04:40 Para: tiagooliv...@gmail.com; r-package-devel@r-project.org Assunto: RE: [R-pkg-devel] MathJax for Rd files Dear Olivoto, There is a package now for this purpose: https://cran.r-project.org/package=mathjaxr https://github.com/wviechtb/mathjaxr Best, Wolfgang >-Original Message- >From: R-package-devel [mailto:r-package-devel-boun...@r-project.org] On >Behalf Of Tiago Olivoto >Sent: Wednesday, 13 May, 2020 8:55 >To: r-package-devel@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 >(https://cran.r-project.org/package=metan) > >I have success with the following approach: > >Including the following call > >#'\if{html}{\out{ > >#' >#'src="https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-chtml-full.js >"> > >#' > >#'}} > >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 offline? > >Thanks in advance > >Olivoto __ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel