Convert arXiv papers to plain text using LTeXML
Project description
arxivparse
Convert arXiv papers to clean plain text using LaTeXML. Download any arXiv paper and get structured text with title, abstract, sections, and math notation preserved.
Install
pip install arxivparse
Quick verification that LaTeXML is installed:
latexml --version
Usage
Get text as a string
from arxivparse import arxiv_to_text
text = arxiv_to_text("1706.03762") # Attention is All You Need paper
print(text[:200])
Save text to a file
from arxivparse.pipeline import convert_arxiv_to_text
from pathlib import Path
output_path = convert_arxiv_to_text("1706.03762", output_path="paper.txt")
text = Path("paper.txt").read_text()
Handle errors gracefully
from arxivparse.errors import (
Arxiv2TextError,
DownloadError,
NoLatexSourceError,
ConversionError,
)
try:
text = arxiv_to_text("1706.03762")
except NoLatexSourceError:
print("Paper is PDF-only")
except DownloadError:
print("Download failed")
except ConversionError:
print("LaTeXML conversion failed")
Library Usage
Simple: get text as a string
from arxivparse import arxiv_to_text
text = arxiv_to_text("1706.03762")
Full pipeline control
from arxivparse.pipeline import convert_arxiv_to_text
from arxivparse.errors import Arxiv2TextError
try:
output_path = convert_arxiv_to_text("1706.03762")
text = output_path.read_text(encoding="utf-8")
except Arxiv2TextError as e:
print(f"Failed: {e}")
Configuration
Both functions accept optional timeouts:
# arxiv_to_text() - returns string
text = arxiv_to_text(
arxiv_id="1706.03762",
download_timeout=60, # seconds to wait for download
convert_timeout=120, # seconds to wait for LaTeXML
)
# convert_arxiv_to_text() - returns file path
path = convert_arxiv_to_text(
arxiv_id="1706.03762",
output_path="paper.txt", # custom output file
download_timeout=60,
convert_timeout=120,
keep_temp=False, # keep intermediate files
)
Error Handling
from arxivparse.errors import (
DownloadError, # network/HTTP failure
NoLatexSourceError, # paper is PDF-only
ConversionError, # LaTeXML failed
MainTexNotFoundError, # no .tex file found
Arxiv2TextError, # any pipeline failure
)
CLI Reference (Optional)
If you prefer the command line:
# Install the CLI (comes with the package)
arxivparse 1706.03762
# Multiple papers
arxivparse 1706.03762 2301.07041
# Custom output
arxivparse -o paper.txt 1706.03762
# Verbose output
arxivparse -v 1706.03762
# Keep temp files for debugging
arxivparse --keep-temp 1706.03762
Output Format
QASPER-style plain text: title, abstract, section headings, body paragraphs, inline math (LaTeX notation like h_{t}), and figure/table captions. No bibliography entries, footnotes, author affiliations, or citation numbers.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arxivparse-0.2.0.tar.gz.
File metadata
- Download URL: arxivparse-0.2.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28fc06532ac8b839e07a49006018650acc36df91fe54b60db0033d3a18645ec9
|
|
| MD5 |
a579fb04793f526bad7bf4dfc897ed69
|
|
| BLAKE2b-256 |
5f394df04cea5c1fe3d227dee15a74823dac0c35297e9ed023ebb79913c17b66
|
Provenance
The following attestation bundles were made for arxivparse-0.2.0.tar.gz:
Publisher:
python-publish.yml on flrjrf/arxivparse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arxivparse-0.2.0.tar.gz -
Subject digest:
28fc06532ac8b839e07a49006018650acc36df91fe54b60db0033d3a18645ec9 - Sigstore transparency entry: 1340545828
- Sigstore integration time:
-
Permalink:
flrjrf/arxivparse@e3cbc82fb7a964369d02b4f7fe968b48e9f6c129 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/flrjrf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e3cbc82fb7a964369d02b4f7fe968b48e9f6c129 -
Trigger Event:
release
-
Statement type:
File details
Details for the file arxivparse-0.2.0-py3-none-any.whl.
File metadata
- Download URL: arxivparse-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df3a13437dd28ac6ed484e47728fea90dde1f97b8e6054f436e77361ce0f0a0e
|
|
| MD5 |
d00c901d06fa0c18dfdb218e6ec18ee5
|
|
| BLAKE2b-256 |
46cf2c93b6f317e03d2f82dcf53f918366f58e098ff0d1c69c9329b15dfb8ebd
|
Provenance
The following attestation bundles were made for arxivparse-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on flrjrf/arxivparse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arxivparse-0.2.0-py3-none-any.whl -
Subject digest:
df3a13437dd28ac6ed484e47728fea90dde1f97b8e6054f436e77361ce0f0a0e - Sigstore transparency entry: 1340545894
- Sigstore integration time:
-
Permalink:
flrjrf/arxivparse@e3cbc82fb7a964369d02b4f7fe968b48e9f6c129 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/flrjrf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e3cbc82fb7a964369d02b4f7fe968b48e9f6c129 -
Trigger Event:
release
-
Statement type: