menu

Make Your Jekyll Support Latex

  • date_range 25/05/2018 20:27 info
    sort
    tools
    label
    tools

Cool Example:

If you want to solve the problem immediately, just go to this link.

Or, reading on

I want to make my jekyll surpport latex math. I tried many ways, such as the following link:

I just cannot figure out, where to put these codes, even from the jekyll official way Math support. Besides I am also little worried about the outdated way.

two things are sure:

  • In ‘_config.xml’ file, I should use kramdown engine
markdown: kramdown
  • The following code should be used
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ TeX: { equationNumbers: { autoNumber: "all" } } }); </script>
  <script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"] ],
        processEscapes: true
      }
    });
  </script>
  <script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>

Finally, I found this this link, went to his/her repostory and got the idear of position to put these codes.

I should put these codes in the all-shared layout file which is ‘_include/head.html’, see this file code as following

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>
    </title>
    <link rel="shortcut icon" type="image/x-icon" href="/assets/res/logo-half.png">
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/materialize/0.99.0/css/materialize.min.css">
    <link rel="stylesheet" href="//fonts.googleapis.com/icon?family=Material+Icons">
    <link rel="stylesheet" href="/assets/css/main.css">
  	<!-- mathjax code should add here -->
    </script> -->
    <script type="text/x-mathjax-config"> MathJax.Hub.Config({ TeX: { equationNumbers: { autoNumber: "all" } } }); </script>
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"] ],
          processEscapes: true
        }
      });
    </script>
    <script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
  </head>
</html>