Currently with the following command of my .ipynb file:
$ ipython nbconvert --to latex --post PDF Untitled1.ipynb --SphinxTransformer.author=\"John Doe\"
[NbConv
Like the OP, I'm not very happy with IPython 2
output from nbconvert
. Since the converter no longer uses the Sphinx documentclass or the Sphinx preprocessing system, you can't use the SphinxTransformer
calls on the nbconverter line.
Drop --post PDF
so nbconvert
creates just the .tex
file. Then, edit the .tex
file to make it prettier. Then, run pdflatex
on it a few times.
To make yourself the author, add a line like the following right after the \title
line in the he .tex
file:
\author{Never Saint}
You can find nice templates to help you make output look like what you want at latextemplates.com
.
Another approach is to roll a new template, starting with the ones in .../IPython/nbconvert/templates/latex
. As the root user, add an article1.tplx
file next to article.tplx
and report.tplx
. The following version creates a different output style that I personally find useful. The "margins" block produces front matter for LaTex, and the "predoc" block produces commands and text that are inserted at the start of the document. I blank out the "maketitle" block so there's no title page. Delete my empty "maketitle" block if you want to have a title page with an author and a date.
Usage: nbconvert --to latex yourNotebook.ipynb --template article1 --to PDF
% Default to the notebook output style
((* if not cell_style is defined *))
((* set cell_style = 'style_ipython.tplx' *))
((* endif *))
% Inherit from the specified cell style.
((* extends cell_style *))
%===============================================================================
% Latex article1, based on Article
%===============================================================================
((* block docclass *))
\documentclass{article}
((* endblock docclass *))
((* block margins *))
\usepackage{blindtext}
\usepackage{mathptmx}% Times Roman font
\usepackage[scaled=.90]{helvet}
\usepackage{xcolor}
\usepackage{titlesec}
\titleformat{\title}[display]
{\normalfont\sffamily\huge\bfseries\color{blue}}
{\titlename}{20pt}{\Huge}
\titleformat{\section}
{\normalfont\sffamily\Large\bfseries\color{darkgray}}
{\subsection}{1em}{}
\titleformat{\subsection}
{\normalfont\sffamily\Large\bfseries\color{darkgray}}
{\thesubsection}{1em}{}
\parindent=0pt
\parskip=6pt
((* endblock margins *))
((* block predoc *))
\begin{document}
\pagestyle{plain}
\thispagestyle{plain}
\pagenumbering{arabic}
\setcounter{page}{5}
\lfoot{\copyright 2014}
This document is composed as an
\href{http://ipython.org/notebook.html}{IPython} notebook. The printed
version of this document was generated from the \texttt{IPython}
notebook, using the \texttt{ipython nbconvert} utility to generate a
\texttt{Latex} document.
((* block maketitle *))((* endblock maketitle *))
((* block author *))\author{Put Your Name Here}((* endblock author *))
((* endblock predoc *))