如何在 Pandoc Markdown 中使用乳胶方程环境? [英] How to use latex equation environment in Pandoc Markdown?

查看:21
本文介绍了如何在 Pandoc Markdown 中使用乳胶方程环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Pandoc markdown 中,我可以使用 '$$' 来启动显示数学环境.但是,这些方程式在 Latex 中没有编号,所以我希望改用方程式环境,如下所示:

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:

egin{equation}
x+1 = 2 \
y+2 = 3 
end{equation}

如果我将降价转换为乳胶,那很好.但是当我使用 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 时可以正常工作,但在 Latex 中会产生编译错误.

Note that the following code works fine when converted to HTML but produces compilation error in latex.

$$    
egin{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 ef 宏;对于所有其他人,数字都是硬编码的.

For tex/pdf output, LaTeX's native equation environment and label and ef 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆