CoolFace
Datasetpublic

lukbl/LaTeX-OCR-dataset

LaTeX-OCR Dataset Summary This dataset was created to train 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… See the full description on the dataset page: https://huggingface.co/datasets/lukbl/LaTeX-OCR-dataset.

sourceHugging Facecc-by-4.0updated 1y agoView on Hugging Face
0likes67downloads
Dataset Card

LaTeX-OCR Dataset

Summary

This dataset was created to train 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. 1.Im2LaTeX-100k (Deng et al., 2017): The original dataset consists of LaTeX formulas extracted from scientific papers and paired with low-resolution images.
  2. 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. 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}
}