zoukankan      html  css  js  c++  java
  • jupyter导出pdf文件的方法

    使用jupyter lab导出pdf文件时,碰到一系列错误,经过查找资料,通过以下方法解决:

    1. 如果使用 file - Save and Export Notebook As...时,提示以下错误:

    解决办法如下:将 F:\Programe files\Python\share\jupyter\nbconvert 下的 templates 文件夹,拷贝到 C:\Users\...\AppData\Roaming\jupyter\nbconvert 下

    2. 如果如果使用 file - Save and Export Notebook As...时,提示以下错误:

    解决办法如下: 

    (1)下载并安装 Miktex 软件,并将其安装路径添加到系统环境变量中,例如,F:\Programe files\MiKTeX\miktex\bin\x64

    下载地址:https://miktex.org/download

    (2)重启jupyter lab后,选择导出pdf

     下面的提示框会弹出N多个,每次选择“安装”即可,直至该提示框不再弹出

      

    3. jupyter文件转pdf的方法:

    直接导出pdf文件时,格式是错误的,

    方法一、.ipynb先导出 xxx.md 文件,在将 xxx.md导出为 xxx.pdf

    方法二、.ipynb先导出 xxx.tex 文件,在将 xxx.tex 导出为 xxx.pdf

    (1)先导出 LaTex 文件,该文件后缀是 xxx.tex

    (2)为了支持中文,需要修改 xxx.tex 文件,在\documentclass{article}(没有这一句就在\documentclass[11pt]{ctexart} 的后面插入下面的语句)后面插入

    \usepackage{fontspec, xunicode, xltxtra}
    \setmainfont{Microsoft YaHei}

    (3)在命令行输入 xelatex xxx.tex

    (4)在对应目录下会出现一系列文件,如下:

     其中,

    • .ipynb 是我们的jupyter文件
    • .tex 是由jupyter notebook文件生成的
    • .pdf 是我们最后的目标文件由.tex文件生成
    • .log、.out、.aux是LaTex生成pdf的一些输出和日志
    总结一下,从jupyter notebook生成pdf文件需要的依赖项还是比较多的,Windows下安装MiKTeX才能用xelatex命令。

     
    参考资料:
    https://blog.csdn.net/grandesucesso/article/details/107831868
    https://www.jianshu.com/p/6b84a9631f8a
  • 相关阅读:
    一些易忘记的常识HTML,不定期添加
    base64 encoder/decoder for objectivec编码及解码(转)
    用XCode 开发基于网络库ACE的应用
    迅雷/旋风地址转换原理分析(转)
    主题:非常常用的Mac快捷键
    没事干测试ObjC数据类型
    These are the support and errata files for titles formerly published by Wrox Press Limited.
    iOS 开发者应该知道的 ARM 结构(转自apple4us)
    [创建型模式] Factory
    [创建型模式] Builder
  • 原文地址:https://www.cnblogs.com/shuaishuaidefeizhu/p/15567744.html
Copyright © 2011-2022 走看看