LaTeX/MathJax support for Help/Rd files?


#1

This may be more of a Base R issue, but I would not complain about better text rendering for R Help files, especially equations. I can copy and paste to an online LaTeX editor, but that can be cumbersome. It would also help developers including their formulas to better evaluate their equations as they are written, rather than having to wait for a pdf version of their manual.

Just a thought.

Thanks!


#2

That’s a good idea. What’s an example of an R Help issue that renders poorly?


#3

A common example of equations that don’t render ‘nice’ comes from the Distributions help pages, where you find equations such as

f(x) = 1/(√(2 π) σ) e^-((x - μ)^2/(2 σ^2))

and

f(x) = exp(-λ/2) SUM_{r=0}^∞ ((λ/2)^r / r!) dchisq(x, df + 2r)

Which can be a little hard on the eyes at times. However as far as I know the R help pages are html pages with ASCII only text and I don’t know the magnitude of how hard that would be able to be changed :thinking:


#4

Another example from a .Rd file: \deqn{h_{n} = 1 - \frac{(e_{ls} - e_{a})}{e_{ls}}}
This renders beautifully with MathJax, but in the help file looks like: h_{n} = 1 - \frac{(e_{ls} - e_{a})}{e_{ls}}

Similarly, if I add already formatted bibliographic information:
Horita J, K Rozanski, S Cohen. 2008. Isotope effects in the evaporation of
water: A status report of the Craig-Gordon model. Isotopes in environmental
and health studies 44 (1): 23–49. DOI: 10.1080/10256010801887174.

I get:
Horita J, K Rozanski, S Cohen. 2008. Isotope effects in the evaporation of water: A status report of the Craig-Gordon model. Isotopes in environmental and health studies 44 (1): 23–49. DOI: 10.1080/10256010801887174.

This is less of a big deal, but still odd that “-” is interpreted as “–”.

Thanks for your responses!


#5

Indeed, it looks like the HTML help pages have an HTML version of the equation. It’d be somewhat simple to just MathJax a LaTeX version if it existed, but in this case we don’t have the LaTeX markup, so we’d have to try to reverse engineer the HTML into LaTeX and then pass that to MathJax. I’m not sure this is even possible as the transformation to HTML appears to lose some information.

I think to do this properly RStudio would need to build its own set of HTML documents from the original sources, which probably won’t happen soon. :-/


#6

Bummer. Well, I greatly appreciate you looking into the matter.

Cheers!