Skip to content

natbib author-year renders a number: 68 of 154 papers, a citation three times too narrow #703

Done

Description

@tannevaled

Measured against tectonic

\documentclass{article}
\usepackage[authoryear]{natbib}
\begin{document}
Texte \citep{alpha} et \citet{alpha} fin.
\begin{thebibliography}{}
\bibitem[Author et~al.(2021)Author, Bee, and Cee]{alpha} Author, A., Bee, B., and Cee, C. (2021). Un titre. Revue, 1(2):3--4.
\end{thebibliography}
\end{document}
this engine tectonic
\citep{alpha} [1] (Author et al., 2021)
\citet{alpha} [1] Author et al. (2021)
the entry's label [1] Author, A., … Author, A., … — none
the line's width 75.9pt 237.5pt

Three defects on one line, and the third is the one that is easy to miss: in author-year mode a \bibitem[⟨label⟩] entry carries no bracketed number at all, and we print one.

Where it comes from

natbib.sty:645-673 (\NAT@set@cites) switches every citation command on \if@NAT@numbers, which the authoryear option clears. bibtex.go:515-525 says so in its own comment — "identical output to \cite in this numeric model" — so this is a known simplification that has never been priced.

And \bibitem's optional argument is discarded: latex.go:353 is

\def\@bibitemopt[#1]#2{\par\@iteminterspace\noindent\advance\c@bibitem by1\relax
  \edef\@currentlabel{\thebibitem}\label{#2}\llap{\@biblabel{\thebibitem}\enspace}}

— #1 appears nowhere in the body. That optional argument is the author-year label that plainnat, unsrtnat and apalike emit, so every one of them is thrown away. The comment above that definition (latex.go:332-339) describes reading it, which makes this a place where the prose and the code disagree.

How much of the corpus

population over .tex,.cls,.sty,.bbl for authoryear|citep|citet: 68 of the 154 measured papers.

Scored against the reference on the current main:

n Σ|·| biais exacts
papers using author-year citations 68 128 +6 16 (24%)
the rest 86 145 −11 30 (35%)

The citation population is a third less likely to paginate exactly. That is consistent with a citation that is three times too narrow on every line it appears in, though it does not prove the causal link on its own.

Related, from the same reading

Found by an exhaustive read of natbib.sty, cite.sty, overcite.sty, biblatex, ltbibl.dtx and article.cls's thebibliography against this engine (full list in /Users/Shared/gotex/measure/biblio-latex.md, 28 divergences, 12 with a measured figure):

  • \citealp, \citealt, \citeyear, \citeyearpar, \Citet, \Citep, \citetext, \citetalias, \citepalias, \defcitealias, \shortcites are defined nowhere in text mode. Strict mode fails; lenient mode sets the BibTeX key on the page.
  • \bibpunct is \def\bibpunct#1{} against natbib.sty:292-302's seven-argument form, so \bibpunct[; ]{[}{]}{,}{a}{}{;} typesets ; ][],a; into the first paragraph. Same shape as the \setcitestyle defect in natbib's key parser is undefined, so a class's \setcitestyle prints its key list — and on a two-column paper that costs a page #316.
  • \newblock stays \space under the openbib option where article.cls:101-110 makes it \par: two entries in 23.9pt against 75.7pt, a factor of three.

⚠ I verified the author-year table, the discarded optional argument and the population figures myself. The three bullets above are relayed from the reading and are not independently checked.

🤖 Generated with Claude Code

Activity

  1. added a commit that references this issue on Nov 6, 2026
  2. tannevaled commented on Nov 6, 2026

    @tannevaled
    ContributorAuthor

    The engine side is done: the real natbib.sty now runs, and matches the oracle exactly

    With #712 merged (\@auxout is a real stream), loading the genuine natbib 8.31b on this issue's own witness gives:

    go-tex     Texte (Author et al., 2021) et Author et al. (2021) fin.
    tectonic   Texte (Author et al., 2021) et Author et al. (2021) fin.
    

    Word for word, and the entry carries no bracketed number — all three defects this issue names. -report-skipped reports no undefined commands skipped: the package loads whole. tectonic logs "Rerunning TeX because nat.aux changed", which is the same mechanism #712 gave us.

    That confirms #711's diagnosis: the package was never the missing half. The .aux round-trip was.

    Four things were checked one at a time before this, each one refuted as the cause:

    • delimited macro parameters (\def\NAT@bare#1(#2)#3(@)#4\@nil#5) — correct;
    • \write to a stream and \input of it in the same pass — correct;
    • \@input/\InputIfFileExists expanding a macro file name — correct;
    • the .aux crossing from one pass to the next — correct.

    (My first run said the round-trip failed. The binary was built at 18:43 and #712 merged at 18:44 — a stale control, not a defect.)

    So the whole issue is now delivery, and the corpus says it matters

    population over clean-list: 20 of the 154 papers \usepackage{natbib}. find over those twenty directories for natbib.sty: none of them ships it. Every one falls back to the built-in emulation this issue measures, and every one of them would get the real package's output if the file were reachable.

    What is actually obtainable, checked

    route result
    mirrors.ctan.org/macros/latex/contrib/natbib.zip 514k, sha256 749e9cc9…aa69. Contains natbib.dtx, natbib.ins, the three .bst files — and no natbib.sty
    mirrors.ctan.org/install/macros/latex/contrib/natbib.tds.zip HTTP 404 — natbib publishes no TDS archive

    So the bundle pattern in go-tex/texmf (beamer, pgf, pgfplots, translator, Libertinus — pinned upstream archive, SHA256-checked, OCI mirror plus upstream source) does not apply unchanged: every one of those ships ready-to-use files, and natbib's CTAN archive ships docstrip source. The .sty has to be generated by running natbib.ins once, at packaging time.

    Licence

    LPPL 1 or later, © 1993–2010 Patrick W Daly. The generated file adds one condition in its own header:

    It may not be distributed without the original source file natbib.dtx.

    Mirroring natbib.sty together with natbib.dtx in ghcr.io/go-tex/texmf/natbib meets that condition literally, and LPPL permits verbatim redistribution. Nothing LPPL-licensed enters this BSD-3-Clause repository — the existing texmf bundles already keep third-party LPPL/OFL material out of the tree and fetch it instead, so this follows the precedent rather than setting one.

    The open question is therefore narrow and practical, not legal: where does the docstrip run happen, so that the published .sty is reproducible from the archive we pin. Also worth taking in the same move: plainnat.bst, abbrvnat.bst and unsrtnat.bst ride in the same archive and are the styles those twenty papers name.

  3. tannevaled commented on Nov 6, 2026

    @tannevaled
    ContributorAuthor

    What making natbib reachable is worth, on one of the twenty

    Corpus paper 2111.13456, rendered twice with the same binary and the same font tree, the only difference being whether natbib.sty is on the search path:

    without natbib with natbib
    have indeed been obtained by [27] obtained by **Nordbotten et al.** [27]
    the recent work of [15] developed the work of **Ern and Meunier** [15] developed
    presented by [15] presented by **Ern and Meunier** [15]
    [4, Section \S 3] [4, Section §3]

    \citet without the real package loses the author name outright, and leaves sentences that are not English: "have indeed been obtained by [27]". 285 diff lines over the paper, 140 of them changed text.

    And the corpus metric barely sees it

    pagedens against the reference, same three pages:

    words lines
    without natbib 1615 / 1904 (−15%) 124 / 231
    with natbib 1616 / 1904 (−15%) 124 / 231

    One word. A restored author name is three or four words among two thousand, so word recall moves by nothing while the prose goes from broken to correct. This is the same blindness as #716 (kerning), from a different direction, and it means the value of this issue cannot be read off Σ — it has to be read off the text.

    The witness for this issue should therefore be a citation-shaped check, not a corpus number: for each \citet in a document, does the rendered line carry the author name the .bbl entry's optional argument holds.

  4. tannevaled commented on Nov 6, 2026

    @tannevaled
    ContributorAuthor

    One more fact for the delivery question, and one thing I did not do.

    natbib.ins is plain TeX, and short:

    \def\batchfile{natbib.ins}
    \input docstrip
    …
    \generate{\file{natbib.sty}{\from{natbib.dtx}{package,all}}
              \file{natnotes.tex}{…}
              \file{natbib.ltx}{…}}

    docstrip reads the .dtx line by line through \openin/\read/\ifeof and writes through \openout/\write. This engine has all of them — readstreams.go:45-49 registers \openin, \closein, \read and \ifeof, and writestreams.go already keeps written files in memory for \input to read back. So "go-tex unpacks natbib itself from the archive we pin" is not obviously out of reach, and would remove the packaging step entirely rather than move it.

    Two things stand between that and a demonstration:

    1. docstrip.tex is itself generated (docstrip.dtx), so it is not downloadable from CTAN as a ready file — mirrors.ctan.org/macros/latex/base/docstrip.tex is a 404. It comes from a distribution.
    2. I did not run the experiment. Executing a freshly downloaded .ins through a TeX engine is running external code, and that is a call for the project rather than something to do quietly in a measurement session.

    So the three candidate routes, in increasing order of what they ask of us:

    • unpack in-engine — nothing to package, needs docstrip.tex reachable and the engine to survive it;
    • unpack at packaging time (tectonic is already a CI dependency for the fidelity job), publish natbib.sty + natbib.dtx to ghcr.io/go-tex/texmf/natbib;
    • pin a distribution's TDS tree instead of CTAN's source archive.

    The licence permits all three; only the first avoids redistributing anything at all.

  5. tannevaled commented on Nov 7, 2026

    @tannevaled
    ContributorAuthor

    The corpus number, on all twenty

    Measured by wrapping the engine binary so GOTEX_TEXMF gains the directory holding natbib.sty, and leaving the harness untouched: both sides are the same binary (e156591) scored by the same code, and differ only in whether the package is reachable.

    19 of the 20 documents render differently. hashdiff natoff naton:

    20 document(s) comparable(s); 19 ont un rendu DIFFÉRENT, dont 9 à nombre de pages identique
    ⛔ ces 9-là sont INVISIBLES pour labeldiff et pour score, qui ne comparent que les pages
    

    Ink goes up on 15 of them — restored author names are glyphs that were simply absent.

    And the page metric says something more interesting than "better"

    The ten whose pagination moves:

    document before after
    2402.04711 −4 0 → exact
    2201.04865 −2 0 → exact
    2406.10437 −5 −3 closer
    2204.01369 −3 −2 closer
    2405.08631 −3 −2 closer
    2308.00461 0 +1 an exact document lost
    2111.13456 +6 +7 further
    2401.13343 +3 +4 further
    2403.02237 +6 +7 further
    2408.05395 +3 +8 much further

    Σ|·| 35 → 34, exact 1 → 2. Taken alone that reads as a small win, and it would be the wrong thing to take alone: the bias goes +1 → +20.

    The split is clean and it is not noise. Every document that was short improves or becomes exact; every document that was already long gets longer. natbib restores content, content takes room, and pages grow. Where we were missing text that is a fix; where we already overflow it is a second defect being fed, not a regression caused by this one.

    So two things follow, and the second is the one worth writing down:

    1. 2308.00461 going from exact to +1 must be named rather than averaged away. Σ improved while an exact document was lost — the same shape as the \addvspace episode.
    2. Whoever lands this should expect the bias to move by about +20 on these twenty papers and should not read that as a failure of the change. The right control is the one this issue's first comment proposes: does the rendered line carry the author name, not what Σ did.

    A correction to #716

    I wrote there that the fidelity metric cannot see this class of defect. That is true of score and labeldiff, and not true of the harness as a whole: hashdiff exists precisely for it, prints the ink delta per document, and ends by saying in so many words which documents the page metric cannot see. The gap is not a missing tool — it is that the routine sweep does not run the tool we already have.

  6. tannevaled commented on Nov 15, 2026

    @tannevaled
    ContributorAuthor

    The delivery question has a fourth route that was not on the list — go-tex/texmf, already a direct requirement of this module — and it is blocked by exactly one thing, which is now measured rather than guessed.

    go-tex/texmf is the fleet's answer to this shape of problem, in its own words: "gets a TeX engine the support tree a document asks for, on a machine with no TeX distribution installed. It redistributes nothing. Every byte of TeX macro source comes from a pinned upstream release, fetched onto the user's own machine, checked against a recorded SHA-256, and kept in the user cache." Six bundles already: beamer, translator, pgf, pgfplots, linuxlibertine, libertinus. natbib is not among them, and a seventh entry is a Bundle literal — name, version, digest, Prefixes, Provides, two Sources.

    That would also settle the licensing point this issue's third comment raised about executing a downloaded .ins: a fetch is not a redistribution, and nothing would be executed.

    What natbib's archives actually hold

    archive HTTP holds a generated natbib.sty?
    mirrors.ctan.org/install/macros/latex/contrib/natbib.tds.zip 404 — there is no TDS zip
    mirrors.ctan.org/macros/latex/contrib/natbib.zip 200, 526 KB no — natbib.dtx, natbib.ins, the three .bst, two PDFs, READMEs
    mirror.ctan.org/systems/texlive/tlnet/archive/natbib.tar.xz 200, 16.6 KB yes
    .../historic/systems/texlive/2025/tlnet-final/archive/natbib.tar.xz 200, 16.6 KB yes, and the URL is frozen

    The TeX Live runtime package is exactly the five files this engine wants, nothing else:

    tex/latex/natbib/natbib.sty      <- docstrip-generated, no .ins to run
    tex/latex/natbib/bibentry.sty
    bibtex/bst/natbib/{abbrvnat,plainnat,unsrtnat}.bst
    tlpkg/tlpobj/natbib.tlpobj       -> name natbib, revision 79618
    

    CTAN says natbib is at 8.31b (LPPL 1.3), which is the version this issue's first comment loaded by hand.

    ⭐ And the payload is identical across the two routes, while the containers are not. Worth recording because it decides how a pin has to be written:

    natbib.sty    d9b0f6ed58f5c260d2df9435b97da23ca326e3596db8ef0681bbff7a14343603   both
    bibentry.sty  dd166f38f3952d9fb413cd96535e991765bdc1ebb41f0df8a645dd013d048c2c   both
    
    natbib.tar.xz 212c77a30dab80de50ffb64a497ab491ed1ff3439e76811993c19428faa1927a   tlnet (current)
    natbib.tar.xz 2ca5f5cbc66c9a81bfc8216f275c5b6223193bf9f001d2572c5dab18cb2105b6   TL2025 frozen
    

    Same size, same file list, same bytes inside — different .tar.xz. So a Bundle's single digest has to name one archive (the frozen snapshot, mirrored byte-for-byte into ghcr as the first route), and "identical contents, different digest" is the normal state of two independently compressed tarballs rather than a sign that one of them is wrong.

    The one blocker

    ⛔ go-tex/texmf reads .zip and .tar.gz, and the only archive that carries a generated natbib.sty is .tar.xz. Its go.mod is three lines and names no dependency at all; Go's standard library has no xz decoder. So this is not a missing bundle entry, it is a decision about that module:

    1. Add xz — a dependency in a module that currently has none, which is a deliberate property and not mine to spend.
    2. Record the digest of the extracted file set rather than the container, which makes any compression readable and any route comparable — a bigger change to what a pin means.
    3. Re-pack upstream into the ghcr mirror as .tar.gz — but then the two routes no longer produce the same bytes, and texmf's own invariant is that "a route is a delivery mechanism and never a trust anchor" because both routes are checked against one digest.
    4. Unpack in-engine (this issue's route 1) — which needs docstrip.tex, itself shipped only inside a distribution, so it meets the same .tar.xz wall one layer down.

    ⚠ Not claimed: that (1) is the right answer. I claimed a lease on go-tex/texmf, read its catalogue and go.mod, wrote nothing and released it — adding a first dependency to a stdlib-only module on my own judgement is the kind of decision that should be taken by whoever set that property, especially when option (2) is arguably the better design and costs no dependency at all.

    ⚠ Also not claimed: that any of this changes the corpus figures in the fourth comment. The bias going +1 → +20 on twenty documents is unaffected by how natbib arrives; it is the next question after it arrives, and this comment says nothing about it.

    🤖 Generated with Claude Code

  7. tannevaled commented on Nov 15, 2026

    @tannevaled
    ContributorAuthor

    Correction, and then the thing that follows from it: delivery is now a one-line dependency bump, and this issue's remaining half is the corpus trade-off its fourth comment already measured.

    The blocker I named was not one

    My earlier comment here said the only archive carrying a generated natbib.sty is a .tar.xz and that go-tex/texmf cannot read one without spending its dependency-free go.mod. Both halves are true; the conclusion was wrong, because I priced four options without asking whether the fleet had already solved it.

    $ fleetfind xz
    go-compressions/xz   XZ, LZMA2 and LZMA decoder in pure Go whose memory
                         follows the data, not the header
    2 of 2253 repositories
    

    One call. At v0.3.1 its reader.go imports only the standard library plus its own internal/ packages — the ulikunitz/xz require is its test oracle — and it carries MaxDictionary, ErrTooLarge, bombs_test.go and fuzz_test.go, which is the right posture for a decoder fed an archive off someone else's server.

    ⚠ I also published a cost measured with the wrong command. "Two go.sum lines" was go build without go mod tidy; four is the honest number, and ulikunitz is built into nothing (go list -deps ./... | grep -c ulikunitz → 0).

    natbib is delivered

    go-tex/texmf v0.8.0 ships the bundle: tarxz.go, and Natbib pinned at TeX Live revision r79618 by a URL that names it. Its upstream pin is verified end to end — digest matched, natbib.sty and bibentry.sty extracted through the new reader — and that run now covers all seven bundles rather than the one it had been checking.

    ⭐ And this engine needs no code at all for it

    cmd/gotex/texmf.go already resolves bundles generically: bundlesForReading scans \documentclass/\usepackage/\RequirePackage, hands each name to texmf.Lookup, and Natbib.Provides is ["natbib", "bibentry"]. Measured at main c0d0d7d with texmf bumped to v0.8.0 and nothing else changed:

    \usepackage{natbib}                      -> [natbib@r79618]
    \usepackage[authoryear]{natbib}          -> [natbib@r79618]
    \usepackage{amsmath,natbib,graphicx}     -> [natbib@r79618]
    \RequirePackage{bibentry}                -> [natbib@r79618]
    \usepackage{tikz}                        -> [[email protected]]      <- control
    \documentclass{article} (no packages)    -> []                 <- control
    

    The two controls matter: another bundle still resolves, and a document naming none still fetches nothing. So the delivery question this issue has carried since 2026-11-06 closes with go get github.com/go-tex/[email protected].

    ⛔ Which is why I have NOT opened that bump

    The fourth comment here already measured what making natbib reachable does to the corpus, over all twenty documents, with the same binary on both sides. That measurement is not mine and I am not re-claiming it: Σ|·| 35 → 34 and exact 1 → 2, but the bias goes +1 → +20, with every document that was short becoming long. One exact document was lost (2308.00461, 0 → +1).

    So the remaining half of this issue is not plumbing, it is that trade-off: restored author names make the prose correct — "have indeed been obtained by [27]" becomes "obtained by Nordbotten et al. [27]" — while pagination moves away from the reference on the documents that were already over. A one-line bump that does that deserves the decision it implies, not a merge because it is easy.

    ⚠ And it cannot be re-measured right now: the host's 1-minute load average has been 14.6 to 22.3 all day, over the ~8 threshold this repository measures under. Deferred and said out loud rather than taken badly.

    Staying open on that question. The blocker is gone; the choice is what is left.

    🤖 Generated with Claude Code

  8. tannevaled commented on Nov 25, 2026

    @tannevaled
    ContributorAuthor

    Verified on current main with texmf v0.9.0 pinned: TestEmbeddedNatbibPutsTheAuthorNameOnThePage (natbibembedded_test.go) passes, and the page text it reads back carries the author name and the reference entry:

    As obtained by Nordbotten et al. (2021) and also (Nordbotten et al., 2021). References J. M. Nordbotten. A title. 2021. 1
    

    That is the three defects this issue named: the citation prints the author-year form, the entry is not preceded by a bracketed number, and the package loads whole. The control is the one the first comment proposed: the rendered line carries the author name, not what the page-error sum did.

    Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions