LaTeX & arXiv parsing, straight from the source

The PDF-based parsers we tested score 0% on equations and bibliography. AILANG Parse reads the .tex source directly: equations stay as LaTeX, 100% of bibliography entries and 93% of citations are kept, and all 19 papers in the arxivbench test set parse.

The Problem

Scientific papers are mostly written in LaTeX: arXiv alone holds 2M+ papers, ~89% with .tex source available. Document parsers such as Docling, LlamaParse, MarkItDown and Unstructured work from the PDF instead of the source. Equations come out as garbled Unicode. Citations lose their keys. Bibliography entries become plain text in the reference list.

On the arxivbench test set of 19 peer-reviewed papers, every PDF-based parser tested scores 0% on structured equations and 0% on structured bibliography entries. The text is usually still in the output. What is missing is the structure a RAG system needs: the LaTeX source of each equation, citation keys that link to their bibliography entries, and references as separate records instead of paragraphs of prose.

How It Works

AILANG Parse reads .tex files directly, as it does DOCX and XLSX. There is no OCR, no rendering and no AI model, so the same file always gives the same result.

Files pulled in with \input or \include are read first and merged into the paper, up to 10 levels deep. A file that cannot be found is skipped and the rest of the paper still parses. Equations, citations and bibliography entries come out in the same block format as every other AILANG Parse format.

# Parse an arXiv paper directly from .tex source
docparse ms.tex

# Multi-file papers: \input is resolved automatically
#   [\input] introduction -> introduction.tex (5300 chars)
#   [\input] background -> background.tex (8376 chars)
#   ...
#   After \input expansion: 79593 chars.
#   Extracted 125 blocks.

Coverage on arxivbench

Each parser is scored against counts taken from the raw .tex source (the "truth"). Score = min(observed, truth) / truth, averaged across papers where truth > 0.

What the scores measure: whether structure is kept, not whether the text is captured. A PDF-based parser that scores 0% on equations may still output the equation as flattened text. What it cannot give you is the equation's LaTeX source as a separate block you can render again. The same goes for the bibliography: PDF-based parsers output the reference list as paragraphs, not one record per entry with its citation key. A RAG system needs the structure, not only the prose.

Dimension AILANG (tex) Pandoc (tex) Docling (pdf) MarkItDown (pdf) Unstructured (pdf)
Papers parsed19/1915/1913/1913/1913/19
Sections94%77%64%1%75%
Equations (display)79%63%0%0%0%
Equations (inline)76%57%0%0%0%
Tables79%32%63%56%0%
Figures100%61%70%0%0%
Citations93%66%19%23%23%
Bibliography100%0%0%0%0%
Lists93%51%46%23%55%
Theorems100%47%0%0%0%

Pandoc also reads .tex source, but fails on 4 of the 19 papers because of custom \newcolumntype macros, \input harvmac and a few package-specific commands. AILANG Parse still parses those papers and keeps anything it does not recognize as raw text.

Multi-File Papers

Most papers over ~15 pages have a short main.tex or ms.tex that pulls in one file per section with \input{background}, \input{introduction} and so on. Parsing only that top file captures almost nothing, because the content is in the files it includes.

AILANG Parse follows these includes up to 10 levels deep. For each one it looks for <basedir>/<arg>.tex, then <basedir>/<arg>. A file that cannot be found, or that includes itself in a loop, is skipped without an error.

# Vaswani "Attention Is All You Need" — 10 \input files
docparse ms.tex
# Parsing 17611 chars of LaTeX source...
#     [\input] introduction -> introduction.tex (5300 chars)
#     [\input] background -> background.tex (8376 chars)
#     [\input] model_architecture -> model_architecture.tex (17109 chars)
#     [\input] why_self_attention -> why_self_attention.tex (7867 chars)
#     [\input] training -> training.tex (4444 chars)
#     [\input] results -> results.tex (11800 chars)
#     [\input] visualizations -> visualizations.tex (1543 chars)
#     [\input] parameter_attention -> parameter_attention.tex (3489 chars)
#     [\input] sqrt_d_trick -> sqrt_d_trick.tex (2226 chars)
# After \input expansion: 79593 chars.
# Extracted 125 blocks.

Example Output

Equations are kept as raw LaTeX in TextBlock entries with style: "equation". They are not converted to MathML or Unicode, because LLMs and RAG systems need the source.

{
  "blocks": [
    {"kind": "HeadingBlock", "level": 1, "text": "Attention Is All You Need"},
    {"kind": "HeadingBlock", "level": 2, "text": "3.2 Attention"},
    {
      "kind": "TextBlock",
      "style": "equation",
      "text": "\\text{Attention}(Q, K, V) = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{d_k}}\\right) V"
    },
    {
      "kind": "TextBlock",
      "text": "The dot-product attention is identical to our algorithm, except for the scaling factor of [cite:bahdanau2014neural]."
    },
    {"kind": "TableBlock", "rows": [...], "caption": "Table 1: Maximum path lengths..."},
    {
      "kind": "SectionBlock",
      "heading": "References",
      "blocks": [
        {"kind": "TextBlock", "style": "bibitem", "key": "vaswani2017attention",
         "text": "Vaswani, A., Shazeer, N., ..."}
      ]
    }
  ]
}

Use Cases

Scientific RAG & Research Copilots

Question answering over arXiv, bioRxiv or OpenReview needs correct equations and structured citations. Retrieval over OCR'd PDFs returns garbled math and loses bibliography entries. Parse the .tex source and your embeddings index what the paper actually says.

Literature Review Automation

Build citation graphs from 10,000 papers without manual work. Bibliography entries come out structured, with their keys, so you can match \cite{vaswani2017} across the papers and follow the graph in code.

Equation Search & Extraction

Equations are kept as raw LaTeX in TextBlock entries. Train math embeddings, build an "image-to-LaTeX" evaluator or power formula search. Your tools see the source the author wrote, not an OCR approximation.

Conference & Journal Pipelines

Handle submissions for ACL, NeurIPS, ICML or physics venues. Authors submit .tex; reviewers need structured content. Parse once, convert to Markdown or HTML for the review portal, and keep the original LaTeX as the reference.

Academic Plagiarism Detection

Compare papers section by section and equation by equation. Structured blocks let you compare what two papers claim in Section 3, not only whether their PDFs happen to share word sequences after OCR.

Preprint & Thesis Archives

University repositories, internal lab knowledge bases, grant-writing archives. Multi-file documents built with \input{chapter-1} parse in full from the source.

Try It

LaTeX is one of 17 supported input formats. Parsing uses no AI model and no OCR, and the same file always gives the same result.

# Upload a .tex file
curl -X POST https://docparse.ailang.sunholo.com/api/v1/parse \
  -F "filepath=@paper.tex" \
  -F "outputFormat=markdown" \
  -F "apiKey=YOUR_API_KEY"

# Or via the CLI with a local arXiv paper
docparse paper.tex --convert paper.md

Parse in Browser    See Benchmarks

Frequently Asked Questions

Why parse the .tex source instead of the PDF?

The .tex file is what the author wrote. The PDF is a rendering of it that loses equation structure, citation keys and bibliography metadata. The PDF-based parsers we tested score 0% on equations and bibliography because that information is not in the PDF. See the coverage table.

Does AILANG Parse handle multi-file LaTeX papers?

Yes. Files pulled in with \input and \include are followed up to 10 levels deep, and circular includes are skipped. Multi-file papers such as Vaswani's Attention paper and BERT parse in full. See Multi-File Papers.

What about custom macros and \newcommand?

Standard LaTeX sectioning, math environments, tables, figures, lists, theorems and citations are supported. Papers that rely heavily on custom macros (harvmac sectioning, custom \newcolumntype) still parse, but less of the structure defined by those macros is recognized. Pandoc fails on these papers; AILANG Parse does not.

Can I get the raw LaTeX equations back?

Yes. Equations are kept as raw LaTeX in TextBlock entries with style: "equation". They are not converted to MathML or Unicode.

Is arXiv source freely available?

Yes. arXiv provides bulk .tex source for ~89% of its 2M+ papers. The remaining ~11% are PDF-only submissions; use PDF parsing for those.

Does it handle .tar.gz arXiv source bundles?

No. Extract the tarball first and point the parser at the main .tex file. It follows \input to the other files.