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

Matthew McCormick matthew.m.mccormick at gmail.com
Tue May 27 16:20:52 EDT 2014

Hi Max,

You might find Dexy [1] convenient for this.

Hope this helps,
Matt

[1] http://dexy.it/

On Tue, May 27, 2014 at 11:23 AM, Maximilian Albert
<maximilian.albert at gmail.com> wrote:
> 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
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>