Skip to content

Instantly share code, notes, and snippets.

@Thell
Created August 7, 2015 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thell/6bc3b3b55d0ad0f5f09d to your computer and use it in GitHub Desktop.
Save Thell/6bc3b3b55d0ad0f5f09d to your computer and use it in GitHub Desktop.
RStudio MathJax Version
---
output: html_document
---
### RStudio MathJax and the preview window/pane
When $MathJax$ is rendered it should be using
```{r}
Sys.getenv(x = "RMARKDOWN_MATHJAX_PATH")
```
Which for me points to
```{r engine='bash'}
grep -m2 version $RMARKDOWN_MATHJAX_PATH/unpacked/MathJax.js
```
and is the same version the CDN uses, but we can see using
````
<script type="text/x-mathjax-config">
MathJax.Hub.Register.MessageHook("End Process",
function (message) { $('#MJVer').text( MathJax.fileversion ); });
</script>
````
that `RMARKDOWN_MATHJAX_PATH` is not honored and the MathJax version used is <span id="MJVer" style="font-weight:bold"></span>.
<script type="text/x-mathjax-config">
MathJax.Hub.Register.MessageHook("End Process",
function (message) { $('#MJVer').text( MathJax.fileversion ); });
</script>
This means there are three options to get the same mathjax that will be used if published to RPubs
1. Set `mathjax: local` _and_ `self_contained: no` _but_ then publishing doesn't work because the document isn't self contained.
2. Replace the contents of the RStudio mathjax path.
3. Open the document in an external browser for each iterative change.
Perhaps, `mathjax: local` should mean literally that... use a local copy of mathjax pointed to by `RMARKDOWN_MATHJAX_PATH`; either the default 2.3 or a self installed local copy. Then things would work as expected, `local` when you don't have or want internet access/CDN hits which also means no external publishing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment