[IPython-dev] Including IPython notebooks as subsections in a LaTeX document?

Maximilian Albert maximilian.albert at gmail.com
Tue May 27 11:23:47 EDT 2014


Hi all,

apologies if this has been asked before - it sounds like such a natural
question that I can't imagine it hasn't, but I can't seem to find any
information on it (maybe I'm using the wrong keywords for my search).

I'm interested in including (converted) IPython notebooks as subsections in
a bigger LaTeX document. What is the best way to achieve this?

Ideally, I would like to have a .tex document that looks like this:

==>
\documentclass{article}

% Load the IPython style definitions somehow

\begin{document}

\section{Introduction}
blah blah blah

\section{Contents of first notebook}
\include{awesome_notebook}

\section{Foobar}
blah blah blah

\section{Contents of second notebook}
\include{awesome_notebook_02}

% ... some other sections ...

\end{document}
<==

The .tex files for the notebooks would be provided by nbconvert:

   $ ipython nbconvert --to latex --template inline awesome_notebook.ipynb

Obviously the "inline" template doesn't exist (yet), but what I'd like it
to do is produce a .tex file of the "bare-bones" contents of the notebook
which can just be included in a document like the above. Naturally, I would
also need a .tex or .sty file somewhere which provides the commands that
usually go into the preamble of the converted notebook.

My first thought was to copy the template 'base.tplx' that comes with
IPython and adapt it so that it only contains the bits between
"\begin{document}" and "\end{document}". The preamble commands could be
copied into a separate file that I can then load once in the preamble of my
bigger document.

However, I was wondering if there is a simpler/more elegant approach, or if
anyone has any better ideas how to include notebooks in LaTeX documents?

Many thanks and best wishes,
Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140527/6e6f7179/attachment.html>


More information about the IPython-dev mailing list