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.3.tar.gz (4.6 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.3-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nb2latex-0.1.3.tar.gz
  • Upload date:
  • Size: 4.6 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.3.tar.gz
Algorithm Hash digest
SHA256 1ee1a9d71323addc37256222df20b2f77e301713006ea3d191995c5dc3640e31
MD5 db5d07676fc88c73524a8ae280e050ae
BLAKE2b-256 4edde52fe5b923803cf7f4aaf9f113ea1ac5161a7c5055407e32714c42f17663

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nb2latex-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 66acbd5d51a23b67eb691565a6afaf72b03fb211ac76fae774858521eddee2d1
MD5 564da18c22067bd92f986c823312070b
BLAKE2b-256 4ddee8bf7ae0884176b9ae1331b869f48e07977054a83f3071e2641ab26bb465

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