pages-themes / cayman

Cayman is a Jekyll theme for GitHub Pages
https://pages-themes.github.io/cayman/
Creative Commons Zero v1.0 Universal
1.23k stars 3.19k forks source link

Latex Math Equation rendering problem #120

Open zarif98sjs opened 3 years ago

zarif98sjs commented 3 years ago

How to add support for rendering latex math equations ? I tried markdown: kramdown / mathjax:true / katex:true but nothing seems to work . What is the correct way to achieve this ?

max-torch commented 3 years ago

Put a HTML head tag at the top of the markdown file that looks like this:

<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
<style>
.katex-display > .katex {
  display: inline-block;
  white-space: nowrap;
  max-width: 100%;
  overflow-x: scroll;
  text-align: initial;
}
.katex {
  font: normal 1.21em KaTeX_Main, Times New Roman, serif;
  line-height: 1.2;
  white-space: normal;
  text-indent: 0;
}
</style>
</head>

Insert katex equations enclosed with double dollar signs. $$Priorityscore = \prod_{j=1}^{n}{a_{j}}^{w_j}$$

In _config.yml add

markdown:           kramdown
kramdown:
    math_engine:    katex
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

j7168908jx commented 2 years ago

Put the MathJax tags inside the <head> of the layout HTML works as well.

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      extensions: ["tex2jax.js"],
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"] ],
          processEscapes: true,
          processRefs: true,
          processEnvironments: true
      },
      TeX: { equationNumbers: { autoNumber: "AMS" } }
  });
</script>
<script type="text/javascript" async
  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

In _config.yml add

markdown: kramdown
kramdown:
  math_engine: mathjax