-
-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use Latex expressions in blogdown? #36
Comments
I ran into this. You have to load mathjax javascript library to display mathematical notation on your pages. The easiest way to do this is to insert the following snippet:
into one of the partials files which you're sure will be loaded on each of your posts. You can find these in layout/partials. In my case I put the code above in the sidebar.html file because the sidebar is guaranteed to load on all my posts. For you it depends on which theme you have installed. Usually sidebar.html/header.html/footer.html are good bets. This is something which ought to be covered blogdown's documentation. |
We will document this in the near future. The approach @Lauler mentioned has a potential problem, but I don't have the time to explain it in detail. You can see what I did in the default template of blogdown: https://github.com/yihui/hugo-lithium/blob/master/layouts/partials/footer_mathjax.html |
@yihui Hi is there a list of tested themes known to render equations properly? The default them The |
Previous setup was not rendering MathJax correctly. Per blogdown issue 36, added JS code to theme footer. rstudio/blogdown#36 (comment)
I don't understand why people have been talking about the But my story went another way as follows.
For both the newest version 1.0.143 and the preview version 1.1.233 of RStudio. So it is a problem of RStudio Viewer? Curiously. My sessioninfo:
|
@pzhaonet You can use There are known issues with RStudio Viewer on Windows. In particular, https resources are unlikely to work, which means (1) you have to use protocol-relative URLs for https resources, i.e. If you don't understand what these mean, your best choice is to pop out the web page from RStudio Viewer into your real web browser. |
Thanks for explanation. Lucky and proud to use hugo-academic theme! |
Finally I have documented how to make MathJax work properly: https://bookdown.org/yihui/blogdown/templates.html This section is quite long but you will understand the nuts and bolts of Hugo much better. |
Does anyone know how to do this in blackburn theme? |
Hi I'm trying to enable latex notation in the skills widget in the academic configuration of blogdown. Any ideas on how to proceed? Thanks in advance. |
help! The preview of this markdown file works normally in rstudio. But this equation isn't shown in html.
|
Hi, @kongdd Your equation rendered fine on my machine My guess is that the mathjax library was not loaded correctly. In chrome you could hit F12 and check if there's any errors. |
Thanks for your reply. |
Ahh, I forgot to check the repo name. Blogdown is another story because it doesn't use pandoc as the markdown engine so the latex is not supported. Please check the blogdown manual In short, the issue is that not all Hugo themes have mathjax supported. The default Hugo-lithium theme has it, but the majority of Hugo themes do not have it. You have two options:
|
@tcgriffith Thanks for your detailed suggestion! Both of |
Hey, I have a much simpler solution to this. This should be enough for HTML noobs like me who want to use any Theme. Just add the following to the head of the Rmd file where you want to use Math and proceed. This adds Mathjax to your webpage from a nearby CDN. header-includes:
Finally, the RMD should look like this: title: "The tile of your page"
Your text here which can now handle math equations. |
If I use
in the document the resulting HTML page shows this result
Can anybody help out?
The text was updated successfully, but these errors were encountered: