Skip to main content

parses valid LaTeX and provides variety of Beautiful-Soup-esque methods and Pythonic idioms for iterating over and searching the parse tree

Project description


PyPi Downloads per Day Build Status Coverage Status

TexSoup is a fault-tolerant, Python3 package for searching, navigating, and modifying LaTeX documents.

Created by Alvin Wan + contributors.

Getting Started

To parse a $LaTeX$ document, pass an open filehandle or a string into the TexSoup constructor.

from TexSoup import TexSoup
soup = TexSoup("""

\section{Hello \textit{world}.}


(n.) A sacred fruit. Also known as:

\item red lemon
\item life

Here is the prevalence of each synonym.

\begin{tabular}{c c}
red lemon & uncommon \\
life & common


With the soupified $\LaTeX$, you can now search and traverse the document tree. The code below demonstrates the basic functions that TexSoup provides.

>>> soup.section  # grabs the first `section`
\section{Hello \textit{world}.}
>>> soup.section.string
'Hello \\textit{world}.'
>>> soup.tabular
\begin{tabular}{c c}
red lemon & uncommon \\
life & common
>>> soup.tabular.args[0]
'c c'
>>> soup.item
\item red lemon
>>> list(soup.find_all('item'))
[\item red lemon, \item life]

For more use cases, see the Quickstart Guide. Or, try TexSoup online, via →




TexSoup is published via PyPi, so you can install it via pip. The package name is TexSoup:

$ pip install texsoup

From source

Alternatively, you can install the package from source:

$ git clone
$ cd TexSoup
$ pip install .

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for TexSoup, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size TexSoup-0.3.1.tar.gz (26.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page