docling-project / docling-project/docling

Bug Report: LaTeX Formula Spacing Issue with do_formula_enrichment=True

Open
#2,374 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

### Bug
When using do_formula_enrichment=True in the PDF pipeline, LaTeX formulas are preserved but rendered with incorrect spacing, making them difficult to read. Each character in the formula appears to be separated by spaces, breaking the mathematical notation.

### Steps to reproduce
```
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.pipeline_options import PdfPipelineOptions
from docling.datamodel.base_models import InputFormat

# Configure pipeline with formula enrichment
pipeline_options = PdfPipelineOptions()
pipeline_options.do_formula_enrichment = True

converter = DocumentConverter(format_options={
InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)
})

# Convert PDF containing mathematical formulas
result = converter.convert("https://arxiv.org/pdf/1706.03762v7")
doc = result.document
```
Expected Behavior
LaTeX formulas should be preserved with proper formatting:
```
$$Attention(Q,K,V) = \text{softmax}(\frac{QK^{T}}{\sqrt{d_{k}}})V$$
```
Actual Behavior
LaTeX formulas are rendered with spaces between every character:
```
$$A t t e n t ( Q , K , V ) = \text {softmax} ( \frac { Q K ^ { T } } { \sqrt { d _ { k } } } ) V$$
```

Image

### Docling version
Docling version: 2.55.0
Docling Core version: 2.48.4
Docling IBM Models version: 3.9.1
Docling Parse version: 4.5.0
Python: cpython-312 (3.12.11)
Platform: Linux-6.6.97+-x86_64-with-glibc2.35

### Python version
Python Version: Python 3.12.11

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.