我们测试使用webtex
公式引擎,qmd文档输出为html,qmd文档的yaml设置为
format:
html:
html-math-method: webtex
以下是公式代码:
$$
\begin{aligned}
Pr(A) &= 0.5 \\
Pr(B) &= 0.5
\end{aligned}
$$ {#eq-webtex}
上述公式将渲染为图片形式:
渲染后的html代码为:
<p>
<span id="eq-webtex"><img style="vertical-align:middle" src="https://latex.codecogs.com/svg.latex?%5Cdisplaystyle%20%5Cbegin%7Baligned%7D%0APr%28A%29%20%26%3D%200.5%20%5C%5C%0APr%28B%29%20%26%3D%200.5%0A%5Cend%7Baligned%7D%0A%20%5Cqquad%281%29" alt="\begin{aligned}
Pr(A) &= 0.5 \\
Pr(B) &= 0.5
\end{aligned}
\qquad(1)" title="\begin{aligned}
Pr(A) &= 0.5 \\
Pr(B) &= 0.5
\end{aligned}
\qquad(1)" class="math display">
</span>
</p>
可以看到:
公式和标号同时被处理为一张图片。
公式图片格式为
.svg
而且这张公式图片是在线生成的(其对应的网址类似如
https://latex.codecogs.com/svg.latex?xxxx
)。可以查看在线生成网站https://latex.codecogs.com提供的相关支持选项。html源码中svg图片和latex代码是同时包含其中的。