latexq
latexq is an experimental CLI for context management in LaTeX manuscripts.
latexq can query and reshape paper-like LaTeX manuscripts into smaller parts to improve AI-assisted review and editing workflows.
In practice, a common workflow when writing is to review and revise a smaller part of a manuscript at a time.
latexq is designed to help manage scope when this workflow is adapted with AI:
-
For review,
lq selecthelps extract only the parts that provide sufficient context for the review. This makes it easier to send only a portion of a manuscript to an AI for review, and withlq selectone can automate (and script) context extraction into a repeatable process. -
For editing,
lq splithelps keep the manuscript organized so that each section (or subsection) is its own file. Limiting the content in each file makes it easier to keep AI-generated edits limited to the intended part; a common challenge with AI tools is that they are overeager to make edits.
The purpose of latexq is intentionally narrow.
It does not interact with GenAI endpoints and has no dependency on AI APIs.
AI-assisted editing is usually done interactively within an editor like VS Code or an agentic tool like Claude Code.
To extract structure in LaTeX manuscripts, latexq uses existing LaTeX commands like \section, \subsection, \appendix, \ref and \label commands.
For the full supported subset and parser constraints, see docs/latex-subset.md.
🚀 Getting started
Requirements
- Python 3.12+
📦 Installation
$ python -m pip install git+https://github.com/genai-latex-proofreader/latexq.git
From a local checkout:
$ python -m pip install .
Example command to extract one section
Input manuscript main.tex:
\documentclass{article}
\begin{document}
\section{Introduction}
\label{sec:intro}
This is the intro.
\section{Methods}
\label{sec:methods}
This is the methods section.
\end{document}
lq select \
--input-file main.tex \
--query '@sec:methods'
This emits the selected LaTeX fragment to stdout:
\section{Methods}
\label{sec:methods}
This is the methods section.
📚 Learn More
The core latexq commands are:
| Command | See | |
|---|---|---|
| 🔎 | lq select extracts parts of a manuscript for focused review or editing. |
docs/latexq-select.md |
| ✂️ | lq split splits a manuscript into smaller files so that each section or subsection is in its own file. |
docs/latexq-split.md |
| 📄 | lq flatten combines a manuscript into one .tex file. |
docs/latexq-flatten.md |
| 🔗 | lq graph builds a reference dependency graph showing which sections and subsections reference each other. |
docs/latexq-graph.md |
Specifications:
- docs/latex-subset.md: the supported LaTeX subset, parser assumptions, and structural constraints.
- docs/query-language.md: Defines the query language used by
lq selectandlq flattento extract part of a LaTeX manuscript.
Instructions for developing latexq can be found in docs/development.md.
Feedback and ideas is welcome.
⚖️ License
Copyright 2024-2026 Matias Dahl and contributors.
latexq is released under the MIT License, see LICENSE.md.
Large parts of latexq (both code and documentation) have been created with the assistance of AI-powered tools.
An earlier version of this work is https://github.com/genai-latex-proofreader/genai-latex-proofreader
Metadata
Release files for latexq 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| latexq-0.1.0.tar.gz | 125.5 kB | With provenance | Details for latexq-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| latexq-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for latexq-0.1.0-py3-none-any.whl |
Total release size: 176.0 kB
Release files / latexq-0.1.0.tar.gz
| Download URL | latexq-0.1.0.tar.gz |
|---|---|
| Size | 125.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34f56345ed46703d9224b8c43089e0b679c275f2166adaa73a76ac8c9bb51526
|
|
BLAKE2b-256 checksum How to use checksums |
f93319ad1420aa5d70b059540ba2fdda7d2ed95513db965779402ea2f41aa249
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 14, 2026.
Transparency logRelease files / latexq-0.1.0-py3-none-any.whl
| Download URL | latexq-0.1.0-py3-none-any.whl |
|---|---|
| Size | 50.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
da93e520fff446a277e448625f61f4d05e87441f9c5e1b80a42f20fa5fa6f209
|
|
BLAKE2b-256 checksum How to use checksums |
f3c148666b6fd2b3b3b543b8c2bd293196ef68cb7a657be0eb0c7805b17f0e1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 14, 2026.
Transparency logSecurity for latexq 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for latexq-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.