如何在 Bookdown 中加载 MathJax 扩展?

pgl*_*lpm 6 r mathjax bookdown

更新:我认为问题与这两个 bookdown-bug 报告有关:Cannot load mathtools MathJax extension in bookdownCustom MathJax URL not working。问题是 upgreek 扩展需要 MathJax V3,但 bookdown/Rstudio 使用过时的 V2.7。根据这些错误,目前无法在 bookdown 中使用 V3。

用 Bookdown 写一篇文章 我想在数学中使用直立的希腊字母。MathJax 为此提供了upgreek扩展,但我无法加载它或使其在 Bookdown 中工作。这是我尝试过的:

按照 Bookdown 手册,我创建了一个名为“mathjax.html”的 html 文件,其中包含以下脚本:

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  loader: {load: ['[tex]/upgreek']},
  TeX: { TagSide: "right" }
});
</script>
Run Code Online (Sandbox Code Playgroud)

然后我include:在“_output.yml”配置文件中进行了修改:

bookdown::gitbook:
  includes:
    in_header: mathjax.html
[...]
Run Code Online (Sandbox Code Playgroud)

但是希腊字母仍然没有渲染(例如, an$\uppi$输出一个 red \uppi,表示未知的宏)。

我不明白问题出在哪里。上面的 MathJax 配置脚本尝试遵循Bookdown 手册中的说明(使用)和MathJax 手册MathJax.Hub.Config({});中的说明(使用 )。我也尝试使用后者,但希腊字母仍然没有呈现。我对这类脚本的语法非常无知。window.MathJax = {};

我的一般问题是:如何让 Bookdown 加载特定的 MathJax 包?

pgl*_*lpm 2

我在这里报告我使用 \xe2\x80\x93 的解决方法,这是一种完全不同但显然更优越的方法 \xe2\x80\x93 ,以防它对其他人有用。

\n

根据github 上的这个绝妙建议,我现在使用Quarto来创建这本书,而不是 Bookdown。直立小写希腊字母是开箱即用的,就像许多其他乳胶数学的细节一样。我认为原因是Quarto使用了MathJax\xc2\xa03。

\n

请注意,如果将 HTML 数学实现更改为 KaTeX(例如通过指定

\n
format: \n  html: \n    code-fold: true\n    html-math-method: katex\n
Run Code Online (Sandbox Code Playgroud)\n

在“_quarto.yml”文件中)则直立小写希腊语不起作用,因为它(尚未)在 KaTeX 中实现。

\n