如何使用pandoc将markdown方程转换为pdf

时间:2015-02-20 20:48:30

标签: pdf latex markdown pandoc

我有一个包含大量方程式的markdown文档(我认为是mathjax),使用标记为2的应用程序可以很好地呈现。当我尝试使用pandoc将其转换为pdf以创建参考书目时,我收到错误。

例如,使用

\\[ \mu_{s,h,d,y} = \left\{
  \begin{array}{1 1}
    \omega_{s,h,d,y} + \delta_{s}(t_{s,h,d-1,y} - \omega_{s,h,d-1,y}) & \quad  \text{for $t_{s,h,d-1,y}$ is real} \\
    \omega_{s,h,d,y} & \quad  \text{for $t_{s,h,d-1,y}$ is not real}
  \end{array} \right.
 \\]

看起来像是

enter image description here

然而,当我跑

pandoc -H format.sty -V fontsize=12pt --bibliography northeast_temperature_refs.bib --csl=american-geophysical-union.csl northeast_temperature_ms2.md -o northeast_temperature_ms.pdf --mathjax

有或没有--mathjax我收到以下错误

! Missing $ inserted.
<inserted text> 
                $
l.268 \textbackslash{}{[} \mu

pandoc: Error producing PDF from TeX source

如果我尝试使用$$代替\\[,请执行以下操作:

$$
\mu_{s,h,d,y} = \left\{
  \begin{array}
    \omega_{s,h,d,y} + \delta_{s}(t_{s,h,d-1,y} - \omega_{s,h,d-1,y}) & \quad  \text{for $$t_{s,h,d-1,y}$$ is real} \\
    \omega_{s,h,d,y} & \quad  \text{for $$t_{s,h,d-1,y}$$ is not real}
  \end{array} \right.
 $$

我收到以下错误:

! LaTeX Error: Illegal character in array arg.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.278   \begin{array}{1 1}

pandoc: Error producing PDF from TeX source

这是我第一次尝试在预制程序之外编写方程式,所以任何帮助都会受到赞赏。当我用Marked进行快速检查时,我以为自己做得很好,但显然它与pandoc的工作方式不一样。

我在Yosemite的Mac上安装了MacTex。

2 个答案:

答案 0 :(得分:3)

Marked使用了不同的降价处理器(MultiMarkdown),而不是Pandoc,它具有不同的方程式语法(\\[ \\]而不是$$)。如果您希望以单一格式为标记预览/ HTML和pandoc PDF /任何其他输出编写,则可以将标记处理器更改为Pandoc(方向here)。这样,您就可以使用$$语法。

答案 1 :(得分:0)

我认为pandoc并不能覆盖数组命令,因为你的命令在IPython笔记本中对我不起作用。但是,用cases语句替换array命令对我有用:

\\[ \mu_{s,h,d,y} = \begin{cases}
    \omega_{s,h,d,y} + \delta_{s}(t_{s,h,d-1,y} - \omega_{s,h,d-1,y}) & \quad  \text{for $t_{s,h,d-1,y}$ is real} \\
    \omega_{s,h,d,y} & \quad  \text{for $t_{s,h,d-1,y}$ is not real}
  \end{cases}
 \\]
相关问题