Jeffrey Girard
Jeffrey Girard

Reputation: 811

How to use MathJax in an Rmarkdown github_document?

I would like to include some math symbols in my GitHub README file generated by Rmarkdown. However, enclosing the symbols in $ does not render them as symbols: it just puts parentheses around them. Based on this document, I thought perhaps I could use MathJax, but my efforts to get this to work have been unsuccessful so far. Any help would be appreciated!

Attempt 1:

---
output:
  github_document
---
Here are some math symbols: $/alpha$ $A$ $1$ 

Attempt 2:

---
output:
  github_document:
    pandoc_args: "--mathjax"
---
Here are some math symbols: $/alpha$ $A$ $1$ 

Attempt 3:

---
output:
  github_document:
    pandoc_args: [
      "--mathjax", "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
    ]
---
Here are some math symbols: $/alpha$ $A$ $1$

Attempt 4:

---
output:
  github_document:
    md_extensions: -tex_math_single_backslash+tex_math_dollars
---
Here are some math symbols: $/alpha$ $A$ $1$

So far, all of these attempts produced this:

enter image description here

Upvotes: 4

Views: 1463

Answers (1)

J_F
J_F

Reputation: 10352

That´s a difficult question and lot of people asked them before, see e.g. https://github.com/github/markup/issues/897

I found a simple solution for some small formulas, e.g. for alpha:

Just use &alpha You can also sub- or superscript with ... or ... (see more here: https://www.w3schools.com/html/html_entities.asp)

Solution found here: How to show math equations in general github's markdown(not github's blog)

Upvotes: 1

Related Questions