1

I'm using blogdown on an Ubuntu 18.04 system, my 'LaTeX' is TinyTeX, and R is v3.5.2. All my packages are up to date, just ran a update.packages(ask = FALSE, checkBuilt = TRUE) and tinytex::tlmgr_update().


And now the issue: LaTeX equations, and everything else, renders fine when I issue the blogdown::serve_site() command from R Studio. When I'm offline (say on a plane) LaTeX equations won't render at all in blogdown. Instead of the rendered equation I get the code, eg:

$$\sigma = \sqrt{ \sum_{i=1}^N \frac{(x_i - \overline{x})^2}{N}}$$

Why is this? What should I do? It's not that big of a deal because I can actually see the rendered equations in R Studio. Just not on my served site.

Another interesting thing is that code snippets wrapped in triple tick marks ``` aren't properly rendered either.

What I get is this (notice zebra stripe background):

zebra stripes

When I expect to get this (solid grey background):

   2           123
   3           132
   4           131
   5           127
   6           117
   7           120
   8           124

When I'm back online with WiFi, and I re-render with blogdown::serve_site() it all looks fine again. Everything renders properly.


EDIT: Minimum reproducible would be a default blogdown site with the LaTeX equation shown above. Should I zip that up and post somewhere to help?

I added this to my YAML but it didn't seem to help:

output:
  html_document:
    mathjax: local
    self_contained: false

My browser console output is below.

cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css:1 Failed to load resource: net::ERR_INTERNET_DISCONNECTED
(index):1 [Intervention] Slow network is detected. See https://www.chromestatus.com/feature/5636954674692096 for more details. Fallback font will be used while loading: http://127.0.0.1:4321/fonts/lato-v11-latin-regular.woff2
(index):1 [Intervention] Slow network is detected. See https://www.chromestatus.com/feature/5636954674692096 for more details. Fallback font will be used while loading: http://127.0.0.1:4321/fonts/merriweather-v13-latin-regular.woff2
cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js:1 Failed to load resource: net::ERR_INTERNET_DISCONNECTED
cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/r.min.js:1 Failed to load resource: net::ERR_INTERNET_DISCONNECTED
cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/yaml.min.js:1 Failed to load resource: net::ERR_INTERNET_DISCONNECTED
(index):194 Uncaught ReferenceError: hljs is not defined
    at (index):194
cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML:1 Failed to load resource: net::ERR_INTERNET_DISCONNECTED
Display name
  • 4,153
  • 5
  • 27
  • 75
  • 1
    Did you check the developer console in your browser? Is there some resource that throws a 404 when you are off line? Perhaps there is some script/css that is being pulled from a CDN or other website? It would be easier to help if you provided a minimal [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) we could test with. – MrFlick Apr 01 '19 at 16:07
  • 1
    To use `MathJax` offline, I think you need to specify `local`. See [here](https://bookdown.org/yihui/rmarkdown/html-document.html#mathjax-equations). As @MrFlick noted, it's pulled from a CDN: `Specify "default" to use an HTTPS URL from a CDN host (currently provided by RStudio).` – Dan Apr 01 '19 at 16:11
  • @MrFlick added to my original post answers to your questions. Hope this helps. – Display name Apr 01 '19 at 17:12
  • 1
    You copied the mathjax.js file into the directory of your RMD file? For me everything works fine. – J_F Apr 01 '19 at 19:41
  • @J_F No I didn't. Where do I get the mathjax.js file? I don't know much about CDN. I'll put it in the directory of my .Rmd file. Thanks – Display name Apr 01 '19 at 20:27
  • 1
    @JasonHunter Save this file from the official repository: https://github.com/mathjax/MathJax/blob/master/MathJax.js – J_F Apr 01 '19 at 20:35
  • I did just download the MathJax.js file from the GitHub repo and placed it into my `/content/post` directory but am unfortunately still experiencing the same issue. – Display name Apr 01 '19 at 22:42
  • 1
    @JasonHunter I don't know if it's the same issue, but there's an [outstanding bug](https://github.com/rstudio/rmarkdown/issues/1283) with using MathJax locally with RMarkdown. – Dan Apr 02 '19 at 11:07

0 Answers0