6

Is there a way to get IPython sessions with syntax highlighting integrated into a latex document using, for example, the minted package (https://github.com/gpoore/minted)?

I have seen many ways of converting a notebook using nbconvert to a tex file. However I don't want to write the whole document within the notebook environment. I would however like to incorporate IPython examples into my thesis.

Something like:

\begin{minted}{ipython ....}
IN[1]: import pandas as pd
...
\end{minted}
sanguineturtle
  • 1,425
  • 2
  • 15
  • 29
  • There are Sphinx highlighters for IPython console examples, and Sphinx can produce Latex output. If you're writing Latex by hand, though, you might not like generated Latex. – Thomas K Dec 14 '13 at 02:51
  • Good Idea. I looked at writing RST and then parsing it through Sphinx, but I would like to do my writing in Latex if possible, as everything else is writen in latex. – sanguineturtle Dec 14 '13 at 04:29
  • This can be done by adding ipython-console-highlighting to Pygments. Then ipython will flow through minted and be recognized by Pygments – sanguineturtle Jan 29 '14 at 04:52

1 Answers1

2

This is what I have done to simply inject the IPython Console Writer into Pygments.

https://github.com/sanguineturtle/pygments-ipython-console

sanguineturtle
  • 1,425
  • 2
  • 15
  • 29