Using MathJax on a Github Page?
Asked Answered
M

2

12

basic question here. I'm trying to figure out a simple and effective way of writing LaTeX-style formulas on a Github web page.

The top answer here suggests that MathJax is a possible solution.

This thread seems to imply MathJax isn't supported.

Personally, I've followed the directions Herem but the math equations aren't appearing.

Thoughts?

Miraflores answered 18/12, 2015 at 2:49 Comment(1)
It works with Jekyll so it can work with raw html on Github pages. See #34228495Watchcase
H
7

2022 Answer

MathJax is now natively supported when viewing .md files on GitHub. However, it is not automatically supported in GitHub Pages. To enable MathJax in GitHub Pages, the easiest option is to include the script from a CDN.

TAKE NOTE: the CDN has changed! The updated script tag to include is below. Add this script tag inside the <head/> of your _layouts/default.html file.

<script type="text/javascript" id="MathJax-script" async
  src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
</script>

For more information, read the MathJax Docs page about using a CDN.

Additional Help

If you want to use dollar signs (i.e. $1 + 2$) to escape math sequences, add the following as well:

<script>
  MathJax = {
    tex: {
      inlineMath: [['$', '$']]
    }
  };
</script>

see the docs for more information.

Heisler answered 10/7, 2022 at 18:48 Comment(2)
Following these instructions did not produce a _layouts/default.html file. Assuming a new project from those instructions, what am I supposed to code?Synopsize
You can look here for information on how the layouts work with Jekyll. Here is a small example, and the corresponding deployment.Heisler
C
3

you can use Mathjax on Github Page by adding next code in tag in your html code.

<script type="text/javascript" charset="utf-8" 
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML,
https://vincenttam.github.io/javascripts/MathJaxLocal.js"></script>

I refered this page. https://vincenttam.github.io/blog/2014/11/09/mathjax-local-configuration-file/

Chicoine answered 19/8, 2016 at 10:37 Comment(2)
sorry, adding code is "vincenttam.github.io/javascripts/MathJaxLocal.js" after cdn.mathjax.org/mathjax/latest/…Chicoine
The CDN has changed. Please see my answer for a more recent update.Heisler

© 2022 - 2024 — McMap. All rights reserved.