我正在构建一个下载项目,并将其呈现为一个包含大量数学页面的gitbook,并且它正在缓慢地呈现。我想使用KaTeX而不是mathJax来呈现我的数学,但我不知道如何让它工作。有一个gitbook插件,所以它应该是可能的,但我不太知道如何将它与预订集成。
在我的index.Rmd文件中,我尝试了以下方法:
---
site: bookdown::bookdown_site
output:
bookdown::gitbook:
pandoc_args: [--katex]
mathjax: NULL
includes:
in_header: katex.html
documentclass: book
---其中katex.html由样式表和KaTeX主题组成。
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" integrity="sha384-wITovz90syo1dJWVh32uuETPVEtGigN07tkttEqPv+uR2SE/mbQcG7ATL28aI9H0" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.js" integrity="sha384-/y1Nn9+QQAipbNQWU65krzJralCnuOasHncUFXGkdwntGeSvQicrYkiUBwsgUqc1" crossorigin="anonymous"></script>然而,数学并没有呈现出来(除了一些仍然由MathJax呈现的部分)。

有什么办法可以让我和KaTeX一起订票吗?
发布于 2017-04-19 20:49:35
您似乎没有阅读KaTeX文档。KaTeX不会自动呈现数学表达式。参见其自述的关于Github的页面上数学的自动绘制一节。简而言之,您必须加载auto-render.min.js并添加一个事件来呈现数学,例如在您的katex.html中,您需要:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" integrity="sha384-wITovz90syo1dJWVh32uuETPVEtGigN07tkttEqPv+uR2SE/mbQcG7ATL28aI9H0" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.js" integrity="sha384-/y1Nn9+QQAipbNQWU65krzJralCnuOasHncUFXGkdwntGeSvQicrYkiUBwsgUqc1" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/contrib/auto-render.min.js" integrity="sha384-dq1/gEHSxPZQ7DdrM82ID4YVol9BYyU7GbWlIwnwyPzotpoc57wDw/guX8EaYGPx" crossorigin="anonymous"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.body);
});
</script>要在下载gitbook输出中禁用MathJax,需要在YAML中设置math: false。
---
site: bookdown::bookdown_site
output:
bookdown::gitbook:
pandoc_args: [--katex]
mathjax: NULL
includes:
in_header: katex.html
documentclass: book
math: false
---https://stackoverflow.com/questions/43096301
复制相似问题