LaTeXML icon indicating copy to clipboard operation
LaTeXML copied to clipboard

prune an empty \bibitem when auto-opened without need

Open dginev opened this issue 1 year ago • 0 comments
trafficstars

Fixes #2403

With Bruce's help, I zeroed in on the cause of the issue, namely \par@in@bibliography. That code, which defensively auto-opens a \bibitem, recognizes too few of the legitimate cases with macro use (as described in the issue).

Since it is rather high difficulty to both handle "sloppy" uses of {thebibliography} as well as the advanced macro uses before a real \bibitem, this PR resigns to undoing the error after it is caused.

Namely, this first stab suggests to check in the afterDigest hook of \lx@bibitem whether the previous recorded box was an empty use of \bibitem. In the case it was, the assembled previous box is pruned from the digested list, and its RefStepID is reused.

Seems to work well on the few cases I tried, open to adjustments.

dginev avatar Aug 26 '24 04:08 dginev