| | --- |
| | 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} |
| | } |
| | ``` |