Splitting text on vertical gaps is why your parser mangles equations
TLDR: The universal rule in layout parsing is "start a new block when the vertical gap exceeds the paragraph gap." It is right for prose and wrong for everything that uses vertical space structurally. A summation is not three blocks; it is one block whose meaning is the stacking.
The position
Vertical gap is a proxy for "these lines belong together." It is a good proxy for prose, because prose only uses vertical space for one thing: separating paragraphs.
Technical documents use vertical space for a second thing entirely. In an equation, a glyph above another glyph is not a new block, it is a numerator. A sum's upper limit sits a full line above the operator and its lower limit a full line below, and both exceed the paragraph gap by design, because the typesetter wanted them visually separated from the body row.
So the gap rule cuts one equation into three pieces, every single time, and does it confidently.
What the industry does and why
Almost every open layout pipeline groups by whitespace. It is fast, it needs no model, it is language-independent, and it is genuinely excellent on the corpus everyone benchmarks against, which is prose with occasional tables.
There is also a good structural reason: the gap rule is local. It looks at two adjacent lines and decides. Local rules are cheap, parallelizable, and easy to reason about. That matters when you are processing a thousand pages.
Nobody is being lazy. The rule is defensible and it is the right default.
Why it fails for this problem class
The failure is not "slightly worse output." It is compounding, and it compounds through the layer that consumes the blocks.
Downstream of the grouper sits a LaTeX reconstructor that recovers structure from the geometry of the atoms it is given. The fraction bar is drawn as a vector, never present in the text layer, so structure has to be inferred from position: something above something else, separated by a gap, is a fraction.
Feed that reconstructor a fragment consisting of a sum's two limits and nothing else, and it does exactly what it was built to do. Two things, one above the other, therefore a fraction:
\frac{\ldots}{\frac{N}{k=1}}
That is a confident, well-formed, completely wrong answer for what should be \sum_{k=1}^{N}. The grouper's error did not stay an error. It became a plausible-looking output that no downstream validator can flag, because it is valid TeX.
And the fragments are individually useless as artifacts. A user opening an equations list to find nine rows, six of which read N and k=1, has a list they cannot act on.
The better approach
Stop treating the gap rule as the final answer and add a reconciliation pass that runs after typing, on regions rather than lines. Merge two vertically adjacent regions when the combined atom set reads as display math.
Combining before testing is what makes it safe. The math gate already caps a candidate at four baselines and rejects anything alphabetically dense, so a merge that would swallow the paragraph underneath fails its own gate. You are not adding a new judgement, you are giving the existing judgement a better-sized input.
Two details decide whether it works.
Iterate to a fixpoint. One pass is not enough, and this is the part that is easy to get wrong. A sum's upper limit and lower limit are two separate regions straddling the operator row. Neither reads as math alone. The pair does, and only once they have joined does the pair merge with the operator. A single left-to-right pass gives up at the first refusal and leaves the equation in three pieces, which is exactly what our first implementation did.
Do not group by column index. This one cost us an afternoon. The equation body spans the measure and gets filed as full-width; its narrow limit stack gets a real column index. Bucketing by column put the two halves of one equation in different buckets where they could never meet. What actually has to hold is that they are not across a gutter, and horizontal overlap tests that directly.
On a paper full of summations, this turned 23 regions on a page into 16, with each equation whole.
What you give up
Locality. The pass looks at pairs and repeats until stable, so it is no longer a single streaming decision. On a page of ordinary prose, nothing merges and the fixpoint terminates after one pass, so the cost is one extra scan. It is not free.
A new false-positive surface. Anything that merges can over-merge. Ours is bounded by the same gate that decides what math is, which means a bad merge and a bad math detection are the same bug with one place to fix. That was deliberate: two independent gates that can disagree is worse than one gate applied twice.
Determinism under edits. A user who splits a region by hand now has a pass that may rejoin it. Merge output has to be marked so a manual override outranks it.
When the common pattern is right
If your documents are prose, keep the gap rule and stop reading. It is correct, it is cheaper, and a reconciliation pass on prose is pure overhead for zero merges.
The rule breaks precisely where vertical position carries meaning: equations, chemical structures, stacked units in engineering tables, musical notation, anything typeset by a system that reasons about baselines. If that is your corpus, the gap rule is not a tuning problem you can solve with a threshold. It is measuring the wrong thing, and no value of the threshold makes a summation into one block.