问题
I can create a new blogdown site utilizing the default hugo-lithium theme and the text statement below will not render as a LaTeX equation, which is the behavior I expect.
An amount between $5 and $10.
Pandoc's manual explains the reason why, which I'll paste below with a bold emphasis:
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.
HOWEVER, I can change to other Hugo themes (e.g. hugo-theme-codex) and this exact same text block renders improperly whenever I include math: true
in my YAML.
An amount between $5 and $10.
ends up displaying as:
Why is LaTeX invoked, when Pandoc is supposed to follow the rule I quoted above? How can I use "other" hugo themes, still use LaTeX math equations, and have Pandoc follow it's own rules? Escaping the $
unfortunately doesn't do anything, and displays the same result as the un-escaped version.
# Doesn't work
An amount between \$5 and \$10.
Getting in on the double slash escape action doesn't seem to work either:
# Doesn't work
An amount between \\$5 and \\$10.
And for those wondering - the last two questions have been answered, 1, 2, and if this question is answered this should be the end of this three part story.
回答1:
First create the following file:
/your-blogdown-site/themes/hugo-theme-codex/layouts/partials/math.html
Then add this to the body of math.html
that you just created:
<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>
Only MathJax release 2.7.5
seems to work right.
The blogdown book templates section is a good source of reading material for this sort of thing. You must include math: true
in your YAML to display LaTeX math equations utilizing this method.
来源:https://stackoverflow.com/questions/62927411/pandoc-rules-regarding-latex-not-followed-on-r-blogdown-hugo-themes