Skip to content

fix: drop footnote marks after captions and crop figures printed under their caption - #89

Merged
917Dhj merged 1 commit into
developfrom
fix/caption-above-figure
Nov 7, 2026
Merged

917Dhj merged 1 commit into
developfrom
fix/caption-above-figure

Conversation

@917Dhj

@917Dhj 917Dhj commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Summary

Two caption gaps in jmir-chatmind-rct.

Footnote mark after the caption (pdf_captions.py)

 caption line text
-  join every span
+  drop trailing spans flagged superscript (≤ 3 chars in total)
+    when the text before them ends a sentence

effects.a becomes effects.. Superscripts that don't follow a sentence end (cm2, GAD-7a) are kept.

Caption printed above its figure (extract_pdf_assets.py)

 figure crop
   beside caption
+  if no visual above the caption
+    below caption: a visual starting ≤ 24pt under it, chained down,
+                   rejected if it ends at a caption of its own
   above caption (text fallback took the page-header strip here)
   table fallback

Evidence

  • Before: jmir-chatmind-rct:caption:Table 3 XFAIL (…effects.a); review:Figure 1 XFAIL (crop [0, 0, 595, 65], reject low_visual_body_ratio)
    After: both XPASS(strict), so both gaps are removed. Figure 1 is cropped at [73, 83, 523, 776], usable, and reaches Visual Review.
  • New unit tests: test_footnote_mark_after_the_caption_sentence_is_not_caption_text (a, *,†, and a kept cm2), test_caption_above_its_figure_crops_the_figure_below, test_caption_with_no_visual_above_leaves_the_next_captioned_figure_alone
  • python3 -m pytest -q: 1706 passed, 1 skipped
  • python3 -m pytest -q -m corpus: 367 passed, 22 xfailed (baseline 365 / 24; no other gap flipped)
  • Every caption and crop diffed between develop and this branch across all 34 corpus papers (451 captions, 418 crops). Only jmir-chatmind-rct changes: Figure 1's crop, Table 3's caption, and Table 2's caption (study groups.e becomes study groups.). Table crop bboxes are unchanged.

Merge Danger

Door: two-way

No artifact schema change. A revert restores the old output.

Blast Radius: narrow

The below-caption path runs only for figure captions with no visual above them. The footnote rule only touches trailing superscript spans after a sentence end. Superscript marks in the middle of a caption (GAD-7a) are still kept as text, which is out of scope here.

🤖 Generated with Claude Code

…r their caption

jmir-chatmind-rct had two caption gaps.

- A superscript footnote mark after a caption's last sentence ("effects.a")
  was kept as caption text. Trailing spans that PyMuPDF flags as
  superscript, three characters at most, are now left out when the text
  before them ends a sentence. Table 2's "study groups.e" is fixed too.
- Figure 1's caption sits above the CONSORT diagram. With no visual above
  the caption, the crop fell back to the page-header strip, and the quality
  gate rejected it. A caption with no visual above it now takes a figure
  that starts within 24pt below it, unless that figure ends at a caption of
  its own.
- Removes both jmir-chatmind-rct known gaps.

On all 34 corpus papers, captions and crops change only for
jmir-chatmind-rct.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@917Dhj
917Dhj merged commit 68793ec into develop Nov 7, 2026
3 checks passed
@917Dhj
917Dhj deleted the fix/caption-above-figure branch November 9, 2026 07:58
moses-y pushed a commit to moses-y/DeepPaperNote that referenced this pull request Nov 12, 2026
A table caption can mark the abbreviations it uses, as in jmir-chatmind-rct
Table 2: "anxiety (GAD-7a), depression (ODSISb)", where each raised letter
points to a note below the table. 917Dhj#89 dropped only marks after a caption's
last sentence, so these stayed in the caption as "GAD-7a".

A superscript span of lowercase letters ("a" or "a,b") is now left out when
it follows a token with two or more capitals. Raised variables such as the
"l" of "h" + "l", a single capital such as "W" + "q", and raised digits stay.

On all 34 corpus papers (454 captions), only that caption changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant