From Smartana Wiki
Jump to: navigation, search

KaTeX Introduction

Is a TeX derivative for the Web. It is similar to MathJax but faster.

It is integrated into a Webpage. First the style-sheet and javascript has to be loaded.

<link rel="stylesheet" type="text/css" href="/path/to/katex/katex.min.css">
<script type="text/javascript" src="/path/to/katex/katex.min.js"></script>

That means you need to download those to a path on your server/computer from Github.

Now you can easily integrate them via:

<p><span id="mykatex1"> </span></p>
<script> katex.render(" c^2 = a^2 + b^2 ", mykatex1); </script>

If you have several equations the script metnioned by Bourne (2014) will be useful:

<div class="math">  c^2 = a^2 + b^2  </div>
some test in between
<div class="math">  c = \sqrt{a^2 + b^2}  </div>
  $(".math").each(function() {
    var texTxt = $(this).text();
    el = $(this).get(0);
    if(el.tagName == "DIV"){
        addDisp = "\\displaystyle";
    } else {
        addDisp = "";
    try {
        katex.render(addDisp+texTxt, el);
    catch(err) {
        $(this).html("<span class='err'>"+err);