{% macro math() %}
  {% if page.extra.math or section.extra.math or config.extra.math %}
    {% if config.extra.library and config.extra.library == "mathjax" %}
      <script>
      // https://mathjax.github.io/MathJax-demos-web/convert-configuration/convert-configuration.html
      window.MathJax = {
      	tex: {
      	inlineMath: [['$', '$'], ['\\(', '\\)']],
      	displayMath: [['$$', '$$'], ['\[\[', '\]\]']],
      	processEscapes: true,
      	processEnvironments: true,
      	},
      	options: {
      	skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
      	}
      };
      </script>
      <script  async defer src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" id="MathJax-script"></script>
    {% else %}
      <!-- KaTeX -->
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
      <script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
      <script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
    {% endif %}
  {% endif %}
{% endmacro %}
