How can we insert formula into the markdown file?

Share steps with fenced code blocks and examples of usage.

Step 1. Edit _config.yml

Add

# Math equation
markdown: kramdown
highlighter: rouge
lsi: false
excerpt_separator: "\n\n"
incremental: false

Step 2. Create _includes/mathjax_support.html

Add

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    TeX: {
      equationNumbers: {
        autoNumber: "AMS"
      }
    },
    tex2jax: {
    inlineMath: [ ['$', '$'] ],
    displayMath: [ ['$$', '$$'] ],
    processEscapes: true,
  }
});
MathJax.Hub.Register.MessageHook("Math Processing Error",function (message) {
	  alert("Math Processing Error: "+message[1]);
	});
MathJax.Hub.Register.MessageHook("TeX Jax - parse error",function (message) {
	  alert("Math Processing Error: "+message[1]);
	});
</script>
<script type="text/javascript" async
  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

Step 3. Edit /_includes/head.html

Add

{% if page.use_math %}
  {% include mathjax_support.html %}
{% endif %}


Examples of usage

layout: single
title: "Vector"

Note, if using mathematical expression (LaTeX), you will need to have the following in your your.md file.

layout: single
title: "Vector"
use_math: true

Categories:

Updated: