簡體   English   中英

如何使用Pandoc將Markdown方程轉換為pdf

[英]How do I convert markdown equations to pdf using pandoc

我有一個Markdown文檔,其中包含許多方程式(我認為是mathjax),使用Marked 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.
 \\]

看起來像

在此處輸入圖片說明

但是,當我跑步時

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的工作方式不一樣。

我在裝有優勝美地的Mac上並安裝了MacTex。

Marked在引擎蓋下使用了與Pandoc不同的Markdown處理器(MultiMarkdown),后者對等式具有不同的語法( \\\\[ \\\\]而不是$$ )。 如果您要為Marked預覽/ HTML和pandoc PDF /其他任何輸出都以單一格式編寫,則可以將Marked的處理器更改為Pandoc( 此處的指示)。 這樣,您可以對所有內容使用$$語法。

我認為pandoc不會涵蓋array命令,因為您的命令在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}
 \\]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM