Skip to main content

CLI to convert Jupyter notebooks to a single LaTeX document

Project description

nb2latex

Convert multiple Jupyter notebooks into a single LaTeX document and PDF.

Overview

nb2latex is a lightweight Python CLI tool that takes multiple .ipynb files and combines them into one clean LaTeX document. It extracts the main body of each .tex file produced from the corresponding .ipynb file using nbconvert and stitches them together into a single .tex file which is then compiled by pdflatex to output a PDF. A table of contents and title page are also included.

How it works

  • Converts selected .ipynb notebooks to LaTeX using nbconvert.
  • Strips unnecessary LaTeX preamble, begin{document}, and end{document} in each .tex file.
  • Combines main bodies into one .tex document and uses the preamble from nbconvert.
  • Adds title page and table of contents automatically.
  • Compiles the final .tex to PDF using pdflatex.
  • Cleans up excess files post-compile.

Requirements

  • Python >= 3.12
  • Pandoc (required for nbconvert)
  • A LaTeX distribution providing pdflatex on PATH (e.g MiKTeX or TeX Live)

Install dependencies:

pip install nb2latex

(Optional environment)

You can also recreate the environment using Micromamba/Conda and the provided environment.yml to install all dependencies except LaTeX distribution.

Micromamba:

micromamba create -f environment.yml
micromamba activate nb2latexEnv

Or Conda:

conda env create -f environment.yml
conda activate nb2latexEnv

Usage

nb2latex --title "LaTeX notebooks" notebook1.ipynb notebook2.ipynb notebook3.ipynb

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

nb2latex-0.1.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nb2latex-0.1.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file nb2latex-0.1.2.tar.gz.

File metadata

  • Download URL: nb2latex-0.1.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for nb2latex-0.1.2.tar.gz
Algorithm Hash digest
SHA256 818dbddb43f9633c121d9f6c6370f4bd54ade8bef32c64b3b5be18b7c39e08ac
MD5 501a6623c3ff5d77ad8c8812080120d1
BLAKE2b-256 b745ef82728a869c7b06a27ac958412d19b6b16e81d72db0cc4d3df9f9451b24

See more details on using hashes here.

File details

Details for the file nb2latex-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: nb2latex-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for nb2latex-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 00688105496deea519887e47752be073078108ec4d6de2615480eb91fb3a77ff
MD5 6c29067bf1e45536a666b1b5dcc0c7da
BLAKE2b-256 f17cc284b8bd178799ad52cd045839da7f9f0fcb0919275dbc52a92318bc1bd0

See more details on using hashes here.

Supported by

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