Python Jupyter nbconvert乳胶出口主题

Python Jupyter nbconvert乳胶出口主题,python,css,latex,jupyter-notebook,nbconvert,Python,Css,Latex,Jupyter Notebook,Nbconvert,我正在使用Jupyter笔记本电脑nbconvert(另存为菜单)通过Latex导出为pdf。但是,pdf文件的状态不好。例如,一些宽表显示得很好。我希望有一个框,用于将表格调整到页面宽度。有什么风格,模板,我可以用来有好的报告,我可以要求nbconverter如何使用这种风格 以下是乳胶输出: 我想要这样的东西: 看起来熊猫在版本0.23中获得了一个\u repr\u latex\u()方法。您需要设置pd.options.display.latex.repr=True来激活它 无乳胶报告:

我正在使用Jupyter笔记本电脑nbconvert(另存为菜单)通过Latex导出为pdf。但是,pdf文件的状态不好。例如,一些宽表显示得很好。我希望有一个框,用于将表格调整到页面宽度。有什么风格,模板,我可以用来有好的报告,我可以要求nbconverter如何使用这种风格

以下是乳胶输出:

我想要这样的东西:


看起来熊猫在版本0.23中获得了一个
\u repr\u latex\u()
方法。您需要设置pd.options.display.latex.repr=True来激活它

无乳胶报告:

使用latex repr:

查看以使格式更接近您想要的格式。为了精确匹配所需的输出,需要使用自定义latex模板


编辑以提供有关模板的更多信息:

有关模板的一般信息,请参见。您可以在与笔记本相同的路径中创建
.tplx
文件,并在从命令行运行
nbconvert
时将其指定为模板:
!jupyter nbconvert——到python的“example.ipynb”——stdout——template=my_custom_template.tplx
。或者,您可以通过修改
~.jupyter
目录中的
jupyter\u notebook\u config.py
文件,指定在通过菜单导出为Latex时使用的默认模板。如果这个文件还不存在,您可以通过从命令行运行命令
jupyter notebook--generate config
来生成它。我的模板也位于
~/.jupyter
目录中,因此我将以下内容添加到我的
jupyter\u notebook\u config.py

# Insert this at the top of the file to allow you to reference
# a template in the ~.jupyter directory
import os.path
import sys
sys.path.insert(0, os.path.expanduser("~") + '/.jupyter')
# Insert this at the bottom of the file:
c.LatexExporter.template_file = 'my_template' # no .tplx extension here
c.LatexExporter.template_path = ['.', os.path.expanduser("~") + '/.jupyter'] # nbconvert will look in ~/.jupyter
要了解一些模板是如何工作的,请先看一下。行
(*-用于nb.cells中的单元格-*)
在笔记本中的所有单元格上循环。后面的
if
语句检查每个单元格的类型并调用相应的块

其他模板扩展了
null.tplx
。每个模板定义(或重定义)一些块。层次结构是
null->display\u priority->document\u contents->base->style.*->article


您的自定义模板可能应该扩展
article.tplx
,并在标题中添加一些Latex命令,以便按照您想要的方式设置表。查看设置自定义模板的示例。

是否有更改表格大小以适应页面宽度的设置? Latex代码是这样的:
\resizebox*{\textwidth}{!}{%


太好了!我应该把模板放在哪里?模板的格式是什么,tex文件?有样本吗?@butterwagonI也有同样的问题,我就这个问题提出了一个新问题