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

Uploaded Python 3

File details

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

File metadata

  • Download URL: nb2latex-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 6d1aad530007380f231990a89238df8c91963487067acc7550715dd6a35d1cf6
MD5 58e0cd6dada16d26411fbcad68d1ae24
BLAKE2b-256 2340c067172222fb3d9853c2c0621a71b8370143ad5fef2d6b969702d0a52f26

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nb2latex-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cc359ea7e32c3ef4930dee1de8d0af2d871c6174be32659d8edc56b90a37c35f
MD5 8253abb44df9fda8ff620a5c2ebad0b6
BLAKE2b-256 c294524432c81048ae93653fb1bf9cc53e0b0aeee5a629750eaa7003d413b75b

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