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.0.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.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nb2latex-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 1bc9814de845adf7b931b80eafb435d1e847feb34c2937ec3e4c10e5b102fd3d
MD5 5a76249d8292e3d2137a228893b0c033
BLAKE2b-256 c2ee0115db5babe412a7ac605a8cade9ccb9b038cf1c42b1a9c4b0a5feee8b81

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nb2latex-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1446a5d6ab418b31a5b0d059e709fc041032fbb131e503a299fbca3b123ab0f8
MD5 682790617291a3be81bbdedd7e948387
BLAKE2b-256 48bd5e6a6f116486e61cda089d573e00b58c2782fcf73e83639ae63598358323

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