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

Uploaded Python 3

File details

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

File metadata

  • Download URL: nb2latex-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 299ef6a8a9fc20264024dc1b52f5b4f1dd2f8db6403cb8d5a9912cc4252c1429
MD5 c705328c657e5583a26f03b02c5dbce4
BLAKE2b-256 0ea3fc71d724c821fbe2e731998615c9cd4bd0a3288566602edd58c670957ca6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nb2latex-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16c2fbe45db1300045a529ba38ef23254bacfabb8d9daa786ecb53e3f3d1b4db
MD5 539c71f159c1c22a4a3230a3e3e499d5
BLAKE2b-256 ec7766f2a9ac145240cf58a4a93fb10d9958f9c98a5d69a324a01ba43ec2caab

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