Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prune an empty \bibitem when auto-opened without need #2409

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

dginev
Copy link
Collaborator

@dginev dginev commented Aug 26, 2024

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.

Copy link
Owner

@brucemiller brucemiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems pretty tricky, but I can't think of a better way to deal with it, other than understanding all the cases where an empty bibitem is created and somehow avoiding it. So, let's go with it.. Thanks!

@brucemiller brucemiller merged commit 2bef09e into brucemiller:master Sep 26, 2024
13 checks passed
@brucemiller brucemiller deleted the avoid-empty-leading-bibitem branch September 26, 2024 21:43
teepeemm pushed a commit to teepeemm/LaTeXML that referenced this pull request Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spurious bibitem in {thebibliography} with custom macros
2 participants