我可以使用默认的 hugo-lithium 创建一个新的 blogdown 站点主题和下面的文本语句不会呈现为 LaTeX 方程,这是我期望的行为。An amount between $5 and $10.
Pandoc's manual解释了原因,我将在下面重点强调:
Anything between two
$
characters will be treated as TeX math. The opening$
must have a non-space character immediately to its right, while the closing$
must have a non-space character immediately to its left, and must not be followed immediately by a digit. Thus,$20,000 and $30,000
won’t parse as math. If for some reason you need to enclose text in literal$
characters, backslash-escape them and they won’t be treated as math delimiters.
但是,我可以更改为其他 Hugo 主题(例如 hugo-theme-codex ),并且每当我包含
math: true
时,这个完全相同的文本块都无法正确呈现在我的 YAML 中。An amount between $5 and $10.
最终显示为:当 Pandoc 应该遵循我上面引用的规则时,为什么会调用 LaTeX?我如何使用“其他”hugo 主题,仍然使用 LaTeX 数学方程,并让 Pandoc 遵循它自己的规则?逃离
$
不幸的是什么都不做,并显示与未转义版本相同的结果。# Doesn't work
An amount between \$5 and \$10.
进入双斜线转义 Action 似乎也不起作用:
# Doesn't work
An amount between \\$5 and \\$10.
对于那些想知道的人 - 最后两个问题已经得到解答,1 , 2 ,如果这个问题得到了回答,这应该是这三部分故事的结尾。
最佳答案
首先创建以下文件:
/your-blogdown-site/themes/hugo-theme-codex/layouts/partials/math.html
然后将此添加到 math.html
的正文中你刚刚创建的:<script src="//yihui.org/js/math-code.js"></script>
<script async
src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
只有 MathJax 发布 2.7.5
似乎工作正常。blogdown book templates section是此类事情的良好阅读 Material 来源。您必须包含
math: true
在您的 YAML 中使用此方法显示 LaTeX 数学方程。
关于r - 关于 LaTeX 的 Pandoc 规则未在 R blogdown 雨果主题上遵循,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62927411/