Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wviechtb/mathjaxr
R package to make use of Mathjax in Rd files
https://github.com/wviechtb/mathjaxr
latex mathjax r r-package
Last synced: 6 days ago
JSON representation
R package to make use of Mathjax in Rd files
- Host: GitHub
- URL: https://github.com/wviechtb/mathjaxr
- Owner: wviechtb
- Created: 2020-05-01T12:50:13.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-09T10:35:14.000Z (4 months ago)
- Last Synced: 2024-10-11T18:49:04.112Z (27 days ago)
- Topics: latex, mathjax, r, r-package
- Language: JavaScript
- Homepage:
- Size: 3.46 MB
- Stars: 47
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
Awesome Lists containing this project
- jimsghstars - wviechtb/mathjaxr - R package to make use of Mathjax in Rd files (JavaScript)
README
mathjaxr: Using Mathjax in Rd Files
===================================[![R build status](https://github.com/wviechtb/mathjaxr/workflows/R-CMD-check/badge.svg)](https://github.com/wviechtb/mathjaxr/actions)
[![CRAN Version](https://www.r-pkg.org/badges/version/mathjaxr)](https://cran.r-project.org/package=mathjaxr)
![devel Version](https://img.shields.io/badge/devel-1.7--1-brightgreen.svg)## Description
The `mathjaxr` package allows for easy inclusion of [MathJax](https://www.mathjax.org/) equations in Rd files. Package authors wanting to make use of the package and its functionality need to:
1. install the `mathjaxr` package,
2. add `mathjaxr` to `Imports` in the `DESCRIPTION` file of their package,
3. add `mathjaxr` to `RdMacros` in the `DESCRIPTION` file of their package (or add `RdMacros: mathjaxr` if the `DESCRIPTION` file does not yet contain a `RdMacros` entry),
4. add `BuildManual: TRUE` to the `DESCRIPTION` file,
5. add `import(mathjaxr)` in the `NAMESPACE` file of their package.One can then enable the use of MathJax by calling the `\loadmathjax` macro (that is provided by the `mathjaxr` package) within the `\description{}` section of an Rd file (or within the `@description` section when using `roxygen2`).
An inline equation can then be added with the `\mjeqn{latex}{ascii}` macro, with the LaTeX commands for the equation given between the first set of curly brackets (which will be rendered in the HTML and PDF help pages) and the plain-text version of the equation given between the second set of curly brackets (which will be shown in the plain text help). With the `\mjdeqn{latex}{ascii}` macro, one can add 'displayed equations' (as in LaTeX's `displaymath` environment).
Single argument versions of these macros, `\mjseqn{latexascii}` and `\mjsdeqn{latexascii}`, are also available. For the relatively rare case that one must specify different LaTeX commands for the PDF and HTML pages, there are also triple argument versions of these macros, namely `\mjteqn{pdflatex}{htmllatex}{ascii}` and `\mjtdeqn{pdflatex}{htmllatex}{ascii}`.
## Details
The Javascript code for MathJax is contained in this package. If a user viewing a help page has `mathjaxr` installed, it will be retrieved from there, otherwise it will be retrieved from the CDN site https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js. To force use of the CDN site, the user can set the environment variable `MATHJAXR_USECDN` to any non-blank value (e.g., `Sys.setenv(MATHJAXR_USECDN=TRUE)`). The URL for a diferent CDN can be specified via the environment variable `MATHJAXR_CDN`.
## Notes/Issues
- Care must be taken when using the less-than and greater-than symbols in equations as these might get interpreted by the browser as HTML tags. See [here](https://docs.mathjax.org/en/latest/input/tex/html.html) for further details. Adding space around these symbols should solve this problem (e.g., instead of writing `\mjseqn{i