11

在 iPython 中,可以使用由 MathJax 解释的 Latex 语法编写方程。

但现在我还想在 iPython 中做其他花哨的乳胶东西,比如用一些乳胶包编写伪代码。有没有可能在 iPython 中编写这样的东西?

例子:

%%latex
\usepackage[]{algorithmicx}
\begin{algorithmic}
   \If {$i\geq maxval$}
      \State $i\gets 0$
   \Else
      \If {$i+k\leq maxval$}
         \State $i\gets i+k$
      \EndIf
   \EndIf
\end{algorithmic}
4

1 回答 1

2

可悲的是,似乎不支持像 algorithmicx 这样的外部乳胶包(https://github.com/ipython/ipython/issues/6524)。

一种可以扩展在该环境中破解 Latex 的能力的方法是 IPython.display.Latex。有了它,您可以动态创建一个字符串并将其显示为 Latex。不像您正在寻找的那样方便,但对于某些用例可能就足够了。

于 2016-05-15T18:06:13.313 回答