nev*_*int 7 python pdf latex type-conversion ipython
目前使用我的.ipynb文件的以下命令:
$ ipython nbconvert --to latex --post PDF Untitled1.ipynb --SphinxTransformer.author="John Doe"
[NbConvertApp] Using existing profile dir: u'/Users/me-macmini/.ipython/profile_default'
[NbConvertApp] Converting notebook Untitled1.ipynb to latex
[NbConvertApp] Support files will be in Untitled1_files/
[NbConvertApp] Loaded template article.tplx
[NbConvertApp] Writing 12876 bytes to Untitled1.tex
[NbConvertApp] Building PDF
[NbConvertApp] Running pdflatex 3 times: [u'pdflatex', u'Untitled1.tex']
[NbConvertApp] Running bibtex 1 time: [u'bibtex', u'Untitled1']
[NbConvertApp] WARNING | bibtex had problems, most likely because there were no citations
[NbConvertApp] Removing temporary LaTeX files
[NbConvertApp] PDF successfully created
Run Code Online (Sandbox Code Playgroud)
使用IPython 2.1,我得到了使用标准经典样式格式化的乳胶文件:

我的问题是:
我该怎么做才能从ipython命令获得以下样式?

为什么以上命令不能使作者出现?
和OP一样,我对IPython 2输出不太满意nbconvert.由于转换器不再使用Sphinx文档类或Sphinx预处理系统,因此无法使用SphinxTransformernbconverter行上的调用.
删除--post PDF所以nbconvert只创建.tex文件.然后,编辑.tex文件使其更漂亮.然后,运行pdflatex几次.
要使自己成为作者,请\title在he .tex文件中的行后面添加如下所示的行:
\author{Never Saint}
Run Code Online (Sandbox Code Playgroud)
你可以找到漂亮的模板来帮助你使输出看起来像你想要的latextemplates.com.
另一种方法是滚动一个新模板,从中开始.../IPython/nbconvert/templates/latex.作为root用户,article1.tplx在article.tplx和旁边添加一个文件report.tplx.以下版本创建了一种我认为有用的不同输出样式."边距"块为LaTex生成前端内容,"predoc"块生成在文档开头插入的命令和文本.我删掉了"maketitle"块,所以没有标题页.如果您想要一个包含作者和日期的标题页,请删除我的空"maketitle"块.
用法: 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 *))
Run Code Online (Sandbox Code Playgroud)