Files
KaTeX/contrib/mathtex-script-type
KaTeX bot 0854e68740 chore(release): 0.16.0 [ci skip]
# [0.16.0](https://github.com/KaTeX/KaTeX/compare/v0.15.6...v0.16.0) (2022-06-06)

### Bug Fixes

* **copy-tex:** Use JS (instead of CSS) to select full equation, solving display glitches ([#3586](https://github.com/KaTeX/KaTeX/issues/3586)) ([8c2d852](8c2d852c4a))

### BREAKING CHANGES

* **copy-tex:** copy-tex extension no longer has (or requires) a CSS file.

* Code cleanup, lint fixes, port to Flow

* Rewrite to extend both start and end of range

* Remove contrib/**/*.css linting

Co-authored-by: Erik Demaine <edemaine@mit.edu>
2022-06-06 16:13:28 +00:00
..
2022-06-06 16:13:28 +00:00

math/tex Custom Script Type Extension

This is an extension to automatically display code inside script tags with type=math/tex using KaTeX. This script type is commonly used by MathJax, so this can be used to support compatibility with MathJax.

Usage

This extension isn't part of KaTeX proper, so the script should be separately included in the page, in addition to KaTeX.

Load the extension by adding the following line to your HTML file.

<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/contrib/mathtex-script-type.min.js" integrity="sha384-jiBVvJ8NGGj5n7kJaiWwWp9AjC+Yh8rhZY3GtAX8yU28azcLgoRo4oukO87g7zDT" crossorigin="anonymous"></script>

You can download the script and use it locally, or from a local KaTeX installation instead.

For example, in the following simple page, we first load KaTeX as usual. Then, in the body, we use a math/tex script to typeset the equation x+\sqrt{1-x^2}.

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css" integrity="sha384-Xi8rHCmBmhbuyyhbI88391ZKP2dmfnOl4rT9ZfRI7mLTdk1wblIUnrIq35nqwEvC" crossorigin="anonymous">
        <script src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.js" integrity="sha384-X/XCfMm41VSsqRNQgDerQczD69XqmjOOOwYQvr/uuC+j4OPoNhVgjdGFwhvN02Ja" crossorigin="anonymous"></script>
        <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/contrib/mathtex-script-type.min.js" integrity="sha384-jiBVvJ8NGGj5n7kJaiWwWp9AjC+Yh8rhZY3GtAX8yU28azcLgoRo4oukO87g7zDT" crossorigin="anonymous"></script>
    </head>
    <body>
        <script type="math/tex">x+\sqrt{1-x^2}</script>
    </body>
</html>

ECMAScript module is also available:

<script type="module" src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/contrib/mathtex-script-type.mjs" integrity="sha384-4EJvC5tvqq9XJxXvdD4JutBokuFw/dCe2AB4gZ9sRpwFFXECpL3qT43tmE0PkpVg" crossorigin="anonymous"></script>