在Pandoc Markdown中如何使用乳胶方程式环境? [英] How to use latex equation environment in Pandoc Markdown?
问题描述
在Pandoc markdown中,我可以使用'$$'启动显示数学环境.但是,这些方程式在乳胶中没有编号,因此我希望改为使用方程式环境,如下所示:
In Pandoc markdown, I can use '$$' to start a display math environment. However, these equations are not numbered in latex so I hope to use the equation environment instead, like this:
\begin{equation}
x+1 = 2 \\
y+2 = 3
\end{equation}
如果我将Markdown转换为乳胶,那很好.但是,当我使用Mathjax将其转换为HTML时,该方法不起作用,因为Pandoc将这些行视为raw_latex在HTML中忽略了它们.
That's fine if I convert markdown to latex. But it does't work when I convert it to HTML with Mathjax because Pandoc treats these lines as raw_latex ignores them in HTML.
我试图禁止raw_latex扩展名
I tried to forbid the raw_latex extension
pandoc -f markdown-raw_latex ...
这一次将两个方程式显示在同一行中,因为Pandoc对反斜杠进行了转义,因此"\"不能正确产生换行符.
This time the two equations are displayed in the same line because the backslashes are escaped by Pandoc so the "\" doesn't produce a newline correctly.
请注意,以下代码在转换为HTML时可以正常工作,但在乳胶中会产生编译错误.
Note that the following code works fine when converted to HTML but produces compilation error in latex.
$$
\begin{equation}
x+1 = 2 \\
y+2 = 3
\end{equation}
$$
有什么办法可以解决这个问题?
Is there any way to handle this problem?
推荐答案
尝试 pandoc-eqnos 过滤器.标签可以使用以下属性附加到方程式:
Try the pandoc-eqnos filter. Labels may be attached to equations using attributes:
$$ y = mx +b $$ {#eq:description}
...,然后像这样引用:
... and then referenced like this:
@eq:description
对于tex/pdf输出,使用LaTeX的本机equation
环境以及\label
和\ref
宏.对于所有其他数字,这些数字都是硬编码的.
For tex/pdf output, LaTeX's native equation
environment and \label
and \ref
macros are used; for all others the numbers are hard-coded.
pandoc-eqnos页面上提供了有关如何安装和应用过滤器的说明.
Instructions are given on the pandoc-eqnos page for how to install and apply the filter.
这篇关于在Pandoc Markdown中如何使用乳胶方程式环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!