Skip to main content

LaTeX templates for jupyter notebook conversion to pdf

Project description

classic.tplx

A more accurate representation of jupyter notebooks when converting to pdfs. This template was designed to make converted jupyter notebooks look (almost) identical to the actual notebook. If something doesn't exist in the original notebook then it doesn't belong in the conversion.

Improvements

  1. \maketitle is removed (If you want a title then add a markdown cell to the top of your notebook).
  2. Sections are no longer numbered automatically (notebooks don't number sections so the pdf shouldn't).
  3. BOXES! are drawn around code cells.
  4. In/Out counts will move to the left as the execution count increases instead of pushing code to the right (only numbers are displayed by default to save page width).
  5. $\LaTeX$ and $\Tex$ in markdown cells will no longer cause conversion to fail. (This change was merged into nbconvert 5.4.0)
  6. "\LaTeX" and "\TeX" are no longer converted into a logo on conversion to pdf unless they are in math mode. (This and the above point replicate the functionality of these commands in notebook markdown).
  7. In/Out prompt colours updated to match Jupyter.
  8. Markdown paragraphs are no longer auto-indented in the pdf.
  9. Syntax highlighting improvements. (Bonus if using XeLaTeX)
  10. Output text wrapping improvements.
  11. Code cell text wrapping.

Quick Comparison: comparison for a closer look see the example directory.

Installation

Manually:

drop all of the "*.tplx" files into the folder containing the other LaTeX nbconvert templates. If using anaconda, it should be something like:

*/Anaconda3/Lib/site-packages/nbconvert/templates/latex

Automatically:

This has been thoroughly tested on windows, and it has been reported to work on MacOS as well.

pip install nb_pdf_template
python -m nb_pdf_template.install

Use

From the command line:

jupyter nbconvert --to pdf filename.ipynb --template classicm

Adding:

c.LatexExporter.template_file = 'classicm'

to the jupyter_nbconvert_config.py file will let you drop the "--template classicm", and to the jupyter_notebook_config.py file will let you use "download as pdf" from within the Jupyter notebook.

Replace classicm with your template of choice.

Templates

This package offers the following templates:

Template Use
classic.tplx (Recommended) For most accurate recreation of the default Jupyter Notebook Style.
classicm.tplx m for modified. Similar to classic.tplx, but in/out prompts are above cells instead of in the margin. Bonus left margins are smaller so code cells are wider.
style_jupyter.tplx DO NOT use this directly. Inherit from this template if you want to build your own.

Tips (Good for any template)

Moved to the wiki

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nb_pdf_template-3.0.0.tar.gz (7.5 kB view details)

Uploaded Source

File details

Details for the file nb_pdf_template-3.0.0.tar.gz.

File metadata

  • Download URL: nb_pdf_template-3.0.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for nb_pdf_template-3.0.0.tar.gz
Algorithm Hash digest
SHA256 454f75e6e5b398c5194eb818452fb34c6cd852dc06c970cbe31b47c7511e09d2
MD5 5af4c04ed7fe38a3818946303f0569da
BLAKE2b-256 cb40d961dfb3f00a4a413c16c35c3531ea0b6a32d96b3f5d3b30635df8920688

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page