Skip to content

LearnIngest & extract

Math extraction

Formula recognition · Image to LaTeX

Recovering equations from a page as structured notation, usually LaTeX or MathML, instead of a jumble of symbols in the wrong order.

In DocSlurpGlossary entry

On this page

Math extraction recovers formulas from a page as structured notation, usually LaTeX (\frac{a}{b}) or MathML, rather than as loose symbols.

The difficulty is that math is two-dimensional. growth-plan-2027.pdf defines operating margin as a fraction: operating income on top, revenue underneath. In LaTeX that is

M = \frac{\text{Operating income}}{\text{Revenue}}

A text extractor reading left to right gets something like M = Operating income Revenue: the fraction bar is a drawn line, not a character, so it vanishes, and the numerator and denominator merge into one line. Exponents fare no better: x² becomes “x2”, and a sum with limits scatters its bounds onto the lines above and below.

Approaches, in rough order of capability:

  • Text layer plus rules: detect math by its symbol fonts and glyphs (∑, ∫, ≤, Greek letters) and at least flag the page as math-heavy, so it can be routed elsewhere.
  • Image-to-LaTeX models: trained on rendered formulas paired with their source, such as the im2latex work.
  • Page-level vision models: Nougat and general vision-language models transcribe whole pages and write formulas in LaTeX when asked.

The gotcha: a LaTeX string can be valid and wrong. A swapped subscript or a dropped minus sign still renders as a tidy equation. When math matters, render the output and compare it with the page image, or check that every symbol on the page appears in the transcription.

In DocSlurp

In DocSlurp

The page probe counts math glyphs, and the optional page router lowers trust in a math-heavy text layer and assigns a math role (core/worker/src/routing/planner.ts). Vision prompts require LaTeX: $...$ inline and $$...$$ for display equations (core/worker/src/tools/vision-model-profiles.ts).

Sources

Jump to