[Bug] Body paragraphs silently dropped or rendered at 0.2-0.3x font size when parsed together with adjacent inline-formula blocks
Author: Hemir95Created Sep 25, 2026Updated Sep 25, 2026
Draft issue para funstory-ai/BabelDOC (NO PUBLICADO AÚN)
Título
[Bug] Body paragraphs silently dropped or rendered at 0.2-0.3x font size when parsed together with adjacent inline-formula blocks
Cuerpo
Bug Description
When translating scientific papers en->es, paragraphs that sit right below a figure or that contain inline math symbols adjacent to formula blocks are either:
- Silently dropped: the entire paragraph disappears from the translated PDF. No warning is emitted. Verified by comparing per-page extracted character counts: original page has 1570 chars, translated page has 495 chars; the missing text cannot be found anywhere in the 14-page output.
- Rendered at 2-3 pt: the paragraph text IS present but the typesetter crushes it to 0.2-0.3x of its original size (min_scale floor 0.1 is reached), producing a single illegible 5pt-tall line of text.
Both reproduce with BabelDOC 0.6.2 and 0.6.4.
Root cause analysis (from source)
- The frontend merges two adjacent source blocks (a multi-line prose paragraph
at 10 pt and a neighbouring block containing inline
εsymbols) into a single paragraph whose box is only ~9 pt tall (one line). _find_optimal_scale_and_layout(typesetting.py) then shrinks the translated text to fit that wrong box: 1.0 -> 0.95 -> ... -> 0.3 and below, hitting themin_scale = 0.1floor. The paragraph box is wrong, not the translation.
Reproduction
- Input: open-access MDPI paper (Materials 2022, 15, 5834 — "A Nonlinear Viscoelastic Constitutive Model for Solid Propellant with Rate-Dependent Cumulative Damage"), page 8, paragraph starting "Figure 7 shows that the stress–strain relation is nonlinear..." (contains σs, σm inline symbols).
- Command:
pdf2zh_next input.pdf --lang-in en --lang-out es --watermark-output-mode no_watermark --primary-font-family serif --output out/(default google/siliconflowfree translator; error is translator-independent, it is in parsing/typesetting). - Expected: the paragraph is translated at ~10 pt like the rest of the body.
- Actual (0.6.2): paragraph translated then shrunk to 3.0 pt single line AND a second paragraph of the same page is missing entirely. Actual (0.6.4): body font size is fixed (10 pt, good) but the paragraph loss persists (495 chars vs 1570).
Additional related defects (same papers)
- References section: entries are translated but merged together without line breaks ("...2008. [CrossRef]7. van Ramshorst...") — already documented as a known limitation, adding one more sample.
- Word duplication at figure/table boundaries: "máxima máxima", "HTPB HTPB es un polímero", "partículas Partículas" — the tail of a sentence split by a float is duplicated as the start of the continuation block. ~1 occurrence per 15-page paper. Persists in 0.6.4.
Environment
- BabelDOC 0.6.2 and 0.6.4, pdf2zh-next 2.9.0, Windows 11, Python 3.11 venv.
- Verification script available (pymupdf-based per-page char ratio + font-size histogram) if useful.
Source: funstory-ai/BabelDOC