Hello All, I am wondering if there has ever been any discussion/consideration given to incorporating MathJax (or something similar) into R for rendering equations in .Rd files. I know that equations are rendered beautifully in the pdf manuals, but I suspect the majority of users primarily look at the html help files when using R. While I am comfortable reading something like "B_x(a,b) = integral_0^x t^(a-1) (1-t)^(b-1) dt", it would definitely be nicer if this was shown as a 'proper' equation. Best, Wolfgang
Use of MathJax (or something similar) in .Rd files
7 messages · Gábor Csárdi, Duncan Murdoch, Wolfgang Viechtbauer +1 more
You can probably already do this using the \if{html} conditional, and
either including the matchjax js files in the package, or getting them
from a CDN.
Gabor
On Thu, Apr 30, 2020 at 9:13 AM Viechtbauer, Wolfgang (SP)
<wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:
Hello All, I am wondering if there has ever been any discussion/consideration given to incorporating MathJax (or something similar) into R for rendering equations in .Rd files. I know that equations are rendered beautifully in the pdf manuals, but I suspect the majority of users primarily look at the html help files when using R. While I am comfortable reading something like "B_x(a,b) = integral_0^x t^(a-1) (1-t)^(b-1) dt", it would definitely be nicer if this was shown as a 'proper' equation. Best, Wolfgang
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Interesting. I gave this a try, but couldn't make this work. One would have to infuse something like <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax at 3/es5/tex-mml-chtml.js"> </script> or <script id="MathJax-script" async src="<url-to-your-site>/mathjax/tex-chtml.js"> </script> into the .html file, but just adding this to the .Rd file (directly or wrapped with \if{html}{}) doesn't do that (it just gets printed). If somebody has already successfully done this, I would be interested in hearing how. Best, Wolfgang
-----Original Message-----
From: G?bor Cs?rdi [mailto:csardi.gabor at gmail.com]
Sent: Thursday, 30 April, 2020 11:51
To: Viechtbauer, Wolfgang (SP)
Cc: r-devel
Subject: Re: [Rd] Use of MathJax (or something similar) in .Rd files
You can probably already do this using the \if{html} conditional, and
either including the matchjax js files in the package, or getting them
from a CDN.
Gabor
On Thu, Apr 30, 2020 at 9:13 AM Viechtbauer, Wolfgang (SP)
<wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:
Hello All, I am wondering if there has ever been any discussion/consideration given
to incorporating MathJax (or something similar) into R for rendering equations in .Rd files. I know that equations are rendered beautifully in the pdf manuals, but I suspect the majority of users primarily look at the html help files when using R. While I am comfortable reading something like "B_x(a,b) = integral_0^x t^(a-1) (1-t)^(b-1) dt", it would definitely be nicer if this was shown as a 'proper' equation.
Best, Wolfgang
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
This sounds promising. Also remember that user-defined macros are possible, so even if you need a lot of contortions to enter the code, you can simplify it at the Rd level. Duncan Murdoch
On 30/04/2020 5:50 a.m., G?bor Cs?rdi wrote:
You can probably already do this using the \if{html} conditional, and
either including the matchjax js files in the package, or getting them
from a CDN.
Gabor
On Thu, Apr 30, 2020 at 9:13 AM Viechtbauer, Wolfgang (SP)
<wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:
Hello All, I am wondering if there has ever been any discussion/consideration given to incorporating MathJax (or something similar) into R for rendering equations in .Rd files. I know that equations are rendered beautifully in the pdf manuals, but I suspect the majority of users primarily look at the html help files when using R. While I am comfortable reading something like "B_x(a,b) = integral_0^x t^(a-1) (1-t)^(b-1) dt", it would definitely be nicer if this was shown as a 'proper' equation. Best, Wolfgang
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
On 30/04/2020 6:15 a.m., Viechtbauer, Wolfgang (SP) wrote:
Interesting. I gave this a try, but couldn't make this work. One would have to infuse something like <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax at 3/es5/tex-mml-chtml.js"> </script> or <script id="MathJax-script" async src="<url-to-your-site>/mathjax/tex-chtml.js"> </script> into the .html file, but just adding this to the .Rd file (directly or wrapped with \if{html}{}) doesn't do that (it just gets printed). If somebody has already successfully done this, I would be interested in hearing how.
You'd need to wrap that code in \out (inside the conditional, i.e.
something like
\if{html}{\out{<script id="MathJax-script" async
src="<url-to-your-site>/mathjax/tex-chtml.js"></script>}}
Duncan Murdoch
Best, Wolfgang
-----Original Message-----
From: G?bor Cs?rdi [mailto:csardi.gabor at gmail.com]
Sent: Thursday, 30 April, 2020 11:51
To: Viechtbauer, Wolfgang (SP)
Cc: r-devel
Subject: Re: [Rd] Use of MathJax (or something similar) in .Rd files
You can probably already do this using the \if{html} conditional, and
either including the matchjax js files in the package, or getting them
from a CDN.
Gabor
On Thu, Apr 30, 2020 at 9:13 AM Viechtbauer, Wolfgang (SP)
<wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:
Hello All, I am wondering if there has ever been any discussion/consideration given
to incorporating MathJax (or something similar) into R for rendering equations in .Rd files. I know that equations are rendered beautifully in the pdf manuals, but I suspect the majority of users primarily look at the html help files when using R. While I am comfortable reading something like "B_x(a,b) = integral_0^x t^(a-1) (1-t)^(b-1) dt", it would definitely be nicer if this was shown as a 'proper' equation.
Best, Wolfgang
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Thanks Gabor and Duncan! It works. For those interested, I added this to the beginning of the \details{} section:
\if{html}{\out{
<script id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax at 3/es5/tex-mml-chtml.js">
</script>
}}
And then I can use:
\if{html}{\out{\(B_{x(a,b)} = \int_0^x t^{a-1} (1-t)^{b-1} dt\)}}
or
\if{html}{\out{\[B_{x(a,b)} = \int_0^x t^{a-1} (1-t)^{b-1} dt\]}}
to render the equation (inline or as 'displaymath'). I'll try to add MathJax locally next.
Best,
Wolfgang
-----Original Message----- From: Duncan Murdoch [mailto:murdoch.duncan at gmail.com] Sent: Thursday, 30 April, 2020 12:22 To: Viechtbauer, Wolfgang (SP); r-devel Subject: Re: [Rd] Use of MathJax (or something similar) in .Rd files On 30/04/2020 6:15 a.m., Viechtbauer, Wolfgang (SP) wrote:
Interesting. I gave this a try, but couldn't make this work. One would
have to infuse something like
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax at 3/es5/tex-mml-chtml.js"> </script> or <script id="MathJax-script" async src="<url-to-your-site>/mathjax/tex-chtml.js"> </script> into the .html file, but just adding this to the .Rd file (directly or
wrapped with \if{html}{}) doesn't do that (it just gets printed). If
somebody has already successfully done this, I would be interested in
hearing how.
You'd need to wrap that code in \out (inside the conditional, i.e.
something like
\if{html}{\out{<script id="MathJax-script" async
src="<url-to-your-site>/mathjax/tex-chtml.js"></script>}}
Duncan Murdoch
Best, Wolfgang
-----Original Message-----
From: G?bor Cs?rdi [mailto:csardi.gabor at gmail.com]
Sent: Thursday, 30 April, 2020 11:51
To: Viechtbauer, Wolfgang (SP)
Cc: r-devel
Subject: Re: [Rd] Use of MathJax (or something similar) in .Rd files
You can probably already do this using the \if{html} conditional, and
either including the matchjax js files in the package, or getting them
from a CDN.
Gabor
On Thu, Apr 30, 2020 at 9:13 AM Viechtbauer, Wolfgang (SP)
<wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:
Hello All, I am wondering if there has ever been any discussion/consideration given
to incorporating MathJax (or something similar) into R for rendering equations in .Rd files. I know that equations are rendered beautifully in the pdf manuals, but I suspect the majority of users primarily look at
the
html help files when using R. While I am comfortable reading something
like
"B_x(a,b) = integral_0^x t^(a-1) (1-t)^(b-1) dt", it would definitely be nicer if this was shown as a 'proper' equation.
Best, Wolfgang
Thank you. This is a very useful idea! Best, Ravi
From: R-devel <r-devel-bounces at r-project.org> on behalf of Viechtbauer, Wolfgang (SP) <wolfgang.viechtbauer at maastrichtuniversity.nl>
Sent: Thursday, April 30, 2020 6:59:02 AM
To: r-devel
Subject: Re: [Rd] Use of MathJax (or something similar) in .Rd files
Sent: Thursday, April 30, 2020 6:59:02 AM
To: r-devel
Subject: Re: [Rd] Use of MathJax (or something similar) in .Rd files
Thanks Gabor and Duncan! It works. For those interested, I added this to the beginning of the \details{} section:
\if{html}{\out{
<script id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax at 3/es5/tex-mml-chtml.js">
</script>
}}
And then I can use:
\if{html}{\out{\(B_{x(a,b)} = \int_0^x t^{a-1} (1-t)^{b-1} dt\)}}
or
\if{html}{\out{\[B_{x(a,b)} = \int_0^x t^{a-1} (1-t)^{b-1} dt\]}}
to render the equation (inline or as 'displaymath'). I'll try to add MathJax locally next.
Best,
Wolfgang
>-----Original Message-----
>From: Duncan Murdoch [mailto:murdoch.duncan at gmail.com]
>Sent: Thursday, 30 April, 2020 12:22
>To: Viechtbauer, Wolfgang (SP); r-devel
>Subject: Re: [Rd] Use of MathJax (or something similar) in .Rd files
>
>On 30/04/2020 6:15 a.m., Viechtbauer, Wolfgang (SP) wrote:
>> Interesting. I gave this a try, but couldn't make this work. One would
>have to infuse something like
>>
>> <script id="MathJax-script" async
>> src="https://cdn.jsdelivr.net/npm/mathjax at 3/es5/tex-mml-chtml.js">
>> </script>
>>
>> or
>>
>> <script id="MathJax-script" async
>> src="<url-to-your-site>/mathjax/tex-chtml.js">
>> </script>
>>
>> into the .html file, but just adding this to the .Rd file (directly or
>wrapped with \if{html}{}) doesn't do that (it just gets printed). If
>somebody has already successfully done this, I would be interested in
>hearing how.
>
>You'd need to wrap that code in \out (inside the conditional, i.e.
>something like
>
>\if{html}{\out{<script id="MathJax-script" async
>src="<url-to-your-site>/mathjax/tex-chtml.js"></script>}}
>
>Duncan Murdoch
>
>>
>> Best,
>> Wolfgang
>>
>>> -----Original Message-----
>>> From: G?bor Cs?rdi [mailto:csardi.gabor at gmail.com]
>>> Sent: Thursday, 30 April, 2020 11:51
>>> To: Viechtbauer, Wolfgang (SP)
>>> Cc: r-devel
>>> Subject: Re: [Rd] Use of MathJax (or something similar) in .Rd files
>>>
>>> You can probably already do this using the \if{html} conditional, and
>>> either including the matchjax js files in the package, or getting them
>>>from a CDN.
>>>
>>> Gabor
>>>
>>> On Thu, Apr 30, 2020 at 9:13 AM Viechtbauer, Wolfgang (SP)
>>> <wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:
>>>>
>>>> Hello All,
>>>>
>>>> I am wondering if there has ever been any discussion/consideration given
>>> to incorporating MathJax (or something similar) into R for rendering
>>> equations in .Rd files. I know that equations are rendered beautifully in
>>> the pdf manuals, but I suspect the majority of users primarily look at
>the
>>> html help files when using R. While I am comfortable reading something
>like
>>> "B_x(a,b) = integral_0^x t^(a-1) (1-t)^(b-1) dt", it would definitely be
>>> nicer if this was shown as a 'proper' equation.
>>>>
>>>> Best,
>>>> Wolfgang
______________________________________________
R-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel