| name | reference-shortener |
| description | Shortens a LaTeX paper's cited references (authors to "et al.", journal abbreviations, DOI cleanup) by recompiling with latexmk until the paper fits a target page count. Use when a paper's bibliography overflows onto an extra page and needs to be compacted without dropping entries. |
| license | MIT |
reference-shortener
Compiles a LaTeX paper with latexmk and applies cleanups to the cited references — recompiling
after each step and stopping as soon as the paper fits the target page count. The referenced .bib
file(s) are rewritten with the smallest set of cleanups that reaches the target.
Order:
- Clear the
location field (and its BibTeX equivalent address) — few styles print it, so it is the cheapest information to lose
- Normalize DOIs (strip
https://doi.org/ prefixes and similar) — a cleanup any well-formed paper wants anyway
- Clean up URLs (unwrap redirect wrappers such as
google.de/url?...&url=..., decode escapes) — likewise
- Shorten author lists to the first author + "and others" (rendered as "et al.")
- Remove the
month field
- Abbreviate journal names (JabRef's bundled journal-abbreviation list)
- Shorten DOIs to the
10/xxx form via shortdoi.org — the very last resort, since not everyone likes short DOIs
Installation
Requires JBang and either a local TeX distribution (latexmk) or Docker
(falls back to the Island of TeX texlive/texlive image).
jbang app install reference-shortener@koppor/reference-shortener
One-off run without installation:
jbang reference-shortener@koppor/reference-shortener paper.tex
Usage
reference-shortener paper.tex
reference-shortener paper.tex --pages 6
reference-shortener paper.tex --pages 6 --output shortened.bib
Notes for agents
- The
.tex file must be a local path inside the paper's project directory; the whole directory is
staged to a temp copy for compilation, so the user's tree is only touched once a validated result
exists.
- Both BibTeX (
\bibliography) and biblatex (\addbibresource) papers work; latexmk drives the
needed bibtex/biber reruns automatically.
- If the target cannot be reached even after all cleanups, the tool applies its best effort,
rewrites the
.bib, reports the achieved page count on stderr, and still exits 0.
- A paper that already fits is left untouched ("nothing to shorten").
- Everything runs offline except the last-resort DOI-shortening step, which queries shortdoi.org; it
is reached only when author and journal shortening did not suffice, and is skipped gracefully (with
a warning) when the network is unavailable.
- Exit codes: 0 = OK (target reached, best effort, or nothing to do), 2 = usage error
(bad
--pages, missing bibliography, --output with multiple .bib files), 1 = compile or I/O
failure.