11

In iPython one can write equations using latex syntax which is interpreted by MathJax.

But now I want to do also other fancy latex stuff in iPython like writing pseudocode with some latex packages. Is there a possibility to write something like this in iPython?

Example:

%%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}
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Tik0
  • 2,499
  • 4
  • 35
  • 50

1 Answers1

2

Sadly, it seems external latex packages like algorithmicx aren't supported (https://github.com/ipython/ipython/issues/6524).

One way you can extend your ability to hack latex together in that environment is IPython.display.Latex. With it you can dynamically create a string and display it as Latex. Not as convenient as what you're looking for, but might suffice for some use cases.

Tristan Reid
  • 5,844
  • 2
  • 26
  • 31