File size: 3,157 Bytes
8298dc4
 
 
 
 
 
 
 
 
 
 
b8fd1dd
 
 
 
 
8298dc4
 
 
 
 
b8fd1dd
 
090b515
 
 
 
 
8298dc4
090b515
 
 
8298dc4
090b515
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
dataset_info:
  features:
  - name: image
    dtype: image
  - name: text
    dtype: string
  splits:
  - name: train
    num_bytes: 275085333.421
    num_examples: 158479
  - name: validation
    num_bytes: 11585352.835
    num_examples: 6765
  download_size: 237789121
  dataset_size: 286670686.256
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
  - split: validation
    path: data/validation-*
license: cc-by-4.0
task_categories:
- image-to-text
size_categories:
- 100K<n<1M
---
# LaTeX-OCR Dataset
## Summary
This dataset was created to train [LaTeX-OCR](https://github.com/lukas-blecher/LaTeX-OCR), a model for recognizing LaTeX code from images of mathematical formulas. Each sample consists of a synthetically rendered formula image and its corresponding LaTeX formula. The images were generated from scratch using xelatex with multiple fonts, offering more typographic variety than many other datasets that use a single font (typically Computer Modern).

## Data Sources

Formulas were collected from these sources:

1. **Im2LaTeX-100k** ([Deng et al., 2017](https://arxiv.org/abs/1609.04938v2)): The original dataset consists of LaTeX formulas extracted from scientific papers and paired with low-resolution images. 
2. **arXiv Papers**: Additional LaTeX expressions were scraped from publicly available PDFs on arXiv.org using automated tools. Only standalone mathematical expressions were retained.
3. **wikipedia**: A small portion of formulas come from technical wikipedia pages

This dataset uses the LaTeX formulas from the sources above but **re-renders all images** from scratch using `xelatex` and a broader set of fonts.

### Fonts Used
Latin Modern Math, GFSNeohellenicMath.otf, Asana Math, XITS Math, Cambria Math

## Structure
Each dataset entry includes:

- A rendered PNG image of a LaTeX formula
- The original LaTeX string

## Usage

```python
from datasets import load_dataset

# Load the dataset
dataset = load_dataset("lukbl/LaTeX-OCR-dataset", split="train")

# Dataset({
#     features: ['image', 'text'],
#     num_rows: 158479
# })

# Inspect a sample
sample = dataset[0]
print(sample)
# Output example:
# {
#   'image': <PIL.PngImagePlugin.PngImageFile image mode=L size=192x64 at 0x7F3A38642D10>,
#   'text': '\\widetilde \\gamma _ { \\mathrm { h o p f } } \\simeq \\sum _ { n > 0 } \\widetilde { G } _ { n } { \\frac { ( - a ) ^ { n } } { 2 ^ { 2 n - 1 } } }'
# }

```

## Citation

If you use this dataset, please cite:

```
@misc{deng2017imagetomarkupgenerationcoarsetofineattention,
      title={Image-to-Markup Generation with Coarse-to-Fine Attention}, 
      author={Yuntian Deng and Anssi Kanervisto and Jeffrey Ling and Alexander M. Rush},
      year={2017},
      eprint={1609.04938},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/1609.04938}, 
}
@misc{blecher2025latexocr,
  author       = {Lukas Blecher},
  title        = {LaTeX-OCR: Optical Character Recognition for LaTeX Formulas},
  howpublished = {\url{https://github.com/lukas-blecher/LaTeX-OCR}},
  year         = {2025},
  note         = {GitHub repository}
}
```