在 github 页上以 latex 格式在 jekyll 博客中显示等式
display equation in jekyll blog in latex format on github pages
我正在尝试在 github 页面上托管的由 jekyll 支持的博客上编写方程式。我正在尝试按照说明 here 使用 MathJax
javascript 库。本质上,我在 _layouts\page.html
和 _layouts\post.html
前面的内容下方添加了以下代码
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
(从 here 复制)。问题是方程式仍然没有在 post 上正确显示,例如,我在我的 post 中写了以下内容(上下各有一个空行):
[\ a^2 + b^2 = c^2 \]
而不是在页面上以 latex
格式向我展示方程式,它只转义 \
并向我展示以下
[\ a^{2} + b^{2} = c^{2} \]
其他详细信息(在我的_config.yml
中关于突出显示)如下
# Build settings
markdown: kramdown
highlighter: rouge
paginate: 5
kramdown:
input: GFM
hard_wrap: false
# syntax_highlighter: rouge
此外,下面粘贴的是_layouts\page.html
中的代码
---
layout: default
---
<article class="post">
<header class="post-header">
<h1 class="post-title">{{ page.title }}</h1>
</header>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
<div class="post-content">
{{ content }}
</div>
</article>
和_layouts\post.html
中的代码
---
layout: default
---
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">{{ page.title }}</h1>
<p class="post-meta"><time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">{{ page.date | date: "%b %-d, %Y" }}</time>{% if page.author %} • <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">{{ page.author }}</span></span>{% endif %}</p>
</header>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
<div class="post-content" itemprop="articleBody">
{{ content }}
</div>
</article>
对于解决正确显示方程的问题的任何帮助,我们将不胜感激!
谢谢!
SN248
一方面,数学定界符应该是 \[...\]
(如果需要转义双反斜杠)。
另一方面,kramdown(Jekyll 的默认 markdown 解析器)有其独特的数学块语法,它使用 $$...$$
作为内联和显示样式,参见。 http://kramdown.gettalong.org/syntax.html#math-blocks
我正在尝试在 github 页面上托管的由 jekyll 支持的博客上编写方程式。我正在尝试按照说明 here 使用 MathJax
javascript 库。本质上,我在 _layouts\page.html
和 _layouts\post.html
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
(从 here 复制)。问题是方程式仍然没有在 post 上正确显示,例如,我在我的 post 中写了以下内容(上下各有一个空行):
[\ a^2 + b^2 = c^2 \]
而不是在页面上以 latex
格式向我展示方程式,它只转义 \
并向我展示以下
[\ a^{2} + b^{2} = c^{2} \]
其他详细信息(在我的_config.yml
中关于突出显示)如下
# Build settings
markdown: kramdown
highlighter: rouge
paginate: 5
kramdown:
input: GFM
hard_wrap: false
# syntax_highlighter: rouge
此外,下面粘贴的是_layouts\page.html
---
layout: default
---
<article class="post">
<header class="post-header">
<h1 class="post-title">{{ page.title }}</h1>
</header>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
<div class="post-content">
{{ content }}
</div>
</article>
和_layouts\post.html
---
layout: default
---
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">{{ page.title }}</h1>
<p class="post-meta"><time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">{{ page.date | date: "%b %-d, %Y" }}</time>{% if page.author %} • <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">{{ page.author }}</span></span>{% endif %}</p>
</header>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
<div class="post-content" itemprop="articleBody">
{{ content }}
</div>
</article>
对于解决正确显示方程的问题的任何帮助,我们将不胜感激!
谢谢!
SN248
一方面,数学定界符应该是 \[...\]
(如果需要转义双反斜杠)。
另一方面,kramdown(Jekyll 的默认 markdown 解析器)有其独特的数学块语法,它使用 $$...$$
作为内联和显示样式,参见。 http://kramdown.gettalong.org/syntax.html#math-blocks