将LaTeX包含在pandoc预格式化部分中

时间:2013-02-23 20:18:35

标签: latex pandoc

我在pandoc文档中有一段预先格式化的代码。严格来说,这是伪代码,我想在预格式化的部分中包含一些渲染的LaTeX。例如:

# Dijkstra's algorithm

Dijkstra's Algorithm (G,l)
Let S be the set of explored nodes
    For each u in S, we store a distance d(u)
Initially S = {s} and d(s) = 0
While S is not equal to V
    Select a node v not in S with at least one edge from S for which
        d'(v) = min_{e = (u,v) : u in S} d(u) + l_e is as small as possible
    Add v to S and define d(v) = d'(v)
EndWhile

我希望,例如,d'(v) = min_{e = (u,v) : u in S} d(u) + l_e可以在文档的正文中进行渲染:$d'(v) = \mathrm{min}_{e = (u,v) : u \in S} d(u) + l_e$

不,在预先格式化的部分输入$d'(v) = \mathrm{min}_{e = (u,v) : u \in S} d(u) + l_e$不会这样做......

2 个答案:

答案 0 :(得分:0)

您是否尝试过以下字符:

\$d'(v) = \mathrm{min}_{e = (u,v) : u \in S} d(u) + l_e\$

答案 1 :(得分:0)

这真是一个乳胶问题......包fancyvrb应该做你想要的。它允许您在Verbatim块中指定转义序列。例如,在标题中包含\ usepackage {fancyvrb}之后:

\begin{Verbatim}[commandchars=\\\{\}] \textit{% This is a comment}
First verbatim line.
\fbox{Second} verbatim line. \textcolor{red}{Third} verbatim line.
\end{Verbatim}

将在红色的第三行渲染红色字。注意\ begin {Verbatim} with capital V将其与常规逐字环境区分开来。