<p>和OP一样,我对<code>nbconvert</code>的输出不太满意。由于转换器不再使用Sphinx documentclass或Sphinx预处理系统,因此不能在nbconverter行上使用<code>SphinxTransformer</code>调用。</p>
<h2>粗鲁的方式</h2>
<p>删除<code>--post PDF</code>,这样<code>nbconvert</code>只创建<code>.tex</code>文件。然后,编辑<code>.tex</code>文件,使其更漂亮。然后,对它运行<code>pdflatex</code>几次。</p>
<p>要使自己成为作者,请在he<code>.tex</code>文件中的<code>\title</code>行之后添加一行如下:</p>
<pre><code>\author{Never Saint}
</code></pre>
<p>您可以在<code>latextemplates.com</code>找到很好的模板来帮助您使输出看起来像您想要的那样。</p>
<h2>根用户的方式</h2>
<p>另一种方法是滚动一个新模板,从<code>.../IPython/nbconvert/templates/latex</code>中的模板开始。作为根用户,在<code>article.tplx</code>和<code>report.tplx</code>旁边添加一个<code>article1.tplx</code>文件。下面的版本创建了一个我个人认为有用的不同输出样式。“margins”块生成乳胶的前页,“predoc”块生成插入文档开头的命令和文本。我把“maketitle”块清空,这样就没有标题页了。如果你想有一个有作者和日期的标题页,请删除我的空“maketitle”块。</p>
<p>用法:<code>nbconvert --to latex yourNotebook.ipynb --template article1 --to PDF</code></p>
<pre><code>% 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 *))
</code></pre>