Convert ipynb to pdf in Jupyter

后端 未结 9 1242
臣服心动
臣服心动 2021-01-31 08:23

I am new to ipython notebook, and I would like to convert my ipynb to pdf. But I get the following error when I try to Download as PDF via LaTex.

nbconvert faile         


        
相关标签:
9条回答
  • 2021-01-31 09:00

    A simple and surprisingly good solution is to print the notebook to pdf through the browser with ctrl+p. Just make sure your plots and figures are not on interactive mode otherwise they will not be displayed (set them to %matplotlib inline).

    Exporting jupyter notebooks through latex is quite troublesome and takes a lot of tinkering to get something remotely close to publish ready. When I absolutely need publication quality I do it on a latex editor, but this tutorial goes in great length about doing it on jupyter.

    A few useful tips to get better results:

    • Higher resolution plots
    • Hide your code-cells from the pdf
    • Take a look at these extensions to improve your jupyter documents
    0 讨论(0)
  • 2021-01-31 09:04

    For Linux, the reported error is due to the lack of XeLatex, part of the texlive-xetex package.

    Installation in ubuntu will be: sudo apt install texlive-xetex

    0 讨论(0)
  • 2021-01-31 09:07

    I agree that latex installation (at least on windows) is painful and the result in my case was not a great looking document. The ctrl-p method alone doesn't work great if you're running in JupyterLab, but if you export the notebook to HTML, then print from the browser, choosing PDF, the result is quite good.

    0 讨论(0)
  • 2021-01-31 09:13

    For Mac OS X, the solution for me was to install MacTex first and then export the path to find it:

    ### TeX
    export PATH="/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:$PATH"
    

    You can add this to your .bash_profile or similar config file to load it every time.

    See more here https://github.com/jupyter/nbconvert/issues/406

    0 讨论(0)
  • 2021-01-31 09:13

    For Error 500

    Debian Or Ubuntu Users:-

    First, install in terminal:-

    sudo apt-get install texlive-full
    

    then

    conda install -c conda-forge pandoc
    
    0 讨论(0)
  • 2021-01-31 09:14

    Here is the full solution that worked for me (for Mac).

    brew cask install mactex

    $ cd ~/

    $ touch .bash_profile

    This will open the bash profile on TextEditor

    $ open -e .bash_profile

    Paste the following to the top and save

    export PATH="/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:$PATH" 
    

    Close any notebook you have and reopen it

    Here is the notebook explaining it step by step: https://github.com/ybaktir/notes/blob/master/Convert%20Jupyter%20Notebook%20to%20Pdf.ipynb

    0 讨论(0)
提交回复
热议问题