Skip to content

feat(extraction): add LaTeX (.tex) extraction support #1552

Description

@MasihMoafi

Summary

Add first-class LaTeX (.tex, .sty, .cls, .dtx, .ltx) extraction support to CodeGraph.

Academic papers, preprints, technical specifications, and research repositories often contain rich document architectures split across multiple files. Currently, .tex files are unindexed, leaving AI coding agents without structural visibility into paper sections, mathematical equations, figures, tables, algorithms, cross-references (\ref), citations (\cite), macro definitions, and multi-file \input{...} / \include{...} hierarchies.

Proposed Extraction Mapping

  • Sections: \section{...}, \subsection{...} -> Symbol Kind: module, Edge: contains
  • Environments: \begin{figure}, \begin{equation}, \begin{algorithm} -> Symbol Kind: struct, Edge: contains
  • Labels: \label{sec:intro}, \label{fig:arch} -> Symbol Kind: constant, Edge: contains
  • References: \ref{sec:...}, \eqref{...}, \cref{...} -> Edge: references (UnresolvedRef)
  • Citations: \cite{...}, \citep{...} -> Edge: references (UnresolvedRef)
  • Macros: \newcommand{...}, \def... -> Symbol Kind: function, Edge: contains
  • File Includes: \input{...}, \include{...}, \bibliography{...} -> Symbol Kind: import, Edge: imports

Implementation Details

We have implemented and tested a complete extractor package with:

  1. Tree-sitter AST Extractor (src/extraction/languages/latex.ts)
  2. Standalone Fallback Extractor (src/extraction/latex-extractor.ts)
  3. Unit test suite covering sections, environments, labels, references, citations, macros, imports, and acronyms.
  4. Verified across real-world research papers (extracted 592 nodes, 588 edges, 0 errors).

Would the maintainers welcome a PR for this feature? We have the branch and patches ready to open.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions