cayman icon indicating copy to clipboard operation
cayman copied to clipboard

Latex Math Equation rendering problem

Open zarif98sjs opened this issue 3 years ago • 3 comments

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 ?

zarif98sjs avatar Mar 12 '21 08:03 zarif98sjs

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/[email protected]/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/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

max-torch avatar May 13 '21 12:05 max-torch

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.

stale[bot] avatar Jan 08 '22 23:01 stale[bot]

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

j7168908jx avatar Nov 04 '22 16:11 j7168908jx