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:
- Tree-sitter AST Extractor (
src/extraction/languages/latex.ts)
- Standalone Fallback Extractor (
src/extraction/latex-extractor.ts)
- Unit test suite covering sections, environments, labels, references, citations, macros, imports, and acronyms.
- 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.
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,
.texfiles 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
\section{...},\subsection{...}-> Symbol Kind:module, Edge:contains\begin{figure},\begin{equation},\begin{algorithm}-> Symbol Kind:struct, Edge:contains\label{sec:intro},\label{fig:arch}-> Symbol Kind:constant, Edge:contains\ref{sec:...},\eqref{...},\cref{...}-> Edge:references(UnresolvedRef)\cite{...},\citep{...}-> Edge:references(UnresolvedRef)\newcommand{...},\def...-> Symbol Kind:function, Edge:contains\input{...},\include{...},\bibliography{...}-> Symbol Kind:import, Edge:importsImplementation Details
We have implemented and tested a complete extractor package with:
src/extraction/languages/latex.ts)src/extraction/latex-extractor.ts)Would the maintainers welcome a PR for this feature? We have the branch and patches ready to open.