3

我在 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$在预格式化部分中输入它不会这样做......

4

2 回答 2

0

您是否尝试过转义字符,例如:

\$d'(v) = \mathrm{min}_{e = (u,v) : u \in S} d(u) + l_e\$
于 2013-03-28T23:18:08.473 回答
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}

将在第三行以红色渲染单词 red。注意 \begin{Verbatim} 与大写 V 区别于常规逐字环境。

于 2013-10-30T22:21:06.700 回答