How to Add Latex Math to Jekyll-based Theme- Minimal Mistakes
Recently, I was trying to add a few mathematical equations in the bolg posts. However, the equations were not working well. I looked for some tutorials, and found the following solutions:
-
Add the following to the
_includes/scripts.html
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ extensions: ["tex2jax.js"], jax: ["input/TeX", "output/HTML-CSS"], tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ], processEscapes: true }, "HTML-CSS": { availableFonts: ["TeX"] } }); </script>
it says that if the
mathjax
is enabled in the pages, it will render the equations using the package. And based on this blog post, it became easier to use usual formats and notations we use in latex. -
Add
mathjax: true
in the default post configuration section of the_config.yml
file as follows:# Defaults defaults: # _posts - scope: path: "" type: posts values: layout: single author_profile: true read_time: true comments: true share: true related: true mathjax: true
check the last line, I have enabled
mathjax
as true.
And, now you are good to go. If you need to check the configuration files, you can visit my repository to see how I configured.
A few suggestions:
- Use
\vert
as the pipe symbol rather than using|
within the math expressions. Sometimes it does not work. - I prefer
$ $
for inline expression (math within paragraph) - Other than that, you can use
$$ $$
for equations that are not within the paragraphs.
That’s it! Have a good day.
References
Leave a comment