Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/swhl/latextoimage

Use LaTeX compilation tools to convert formulas in LaTeX format into corresponding images.
https://github.com/swhl/latextoimage

convert latex latex-ocr

Last synced: 13 days ago
JSON representation

Use LaTeX compilation tools to convert formulas in LaTeX format into corresponding images.

Awesome Lists containing this project

README

        



LaTeX To Image





PyPI

SemVer2.0

GitHub

[简体中文](./docs/README_zh.md) | English

### Introduction
This tool is used to convert LaTeX formulas into corresponding images with the help of LaTeX tools.

### Install LaTeX compile environment
Ubuntu:
```bash
sudo apt-get install texlive-full

# verify whether the installation is successful.
$ xelatex --help
# Usage: pdftex [OPTION]... [TEXNAME[.tex]] [COMMANDS]
# or: pdftex [OPTION]... \FIRST-LINE
# or: pdftex [OPTION]... &FMT ARGS
# Run pdfTeX on TEXNAME, usually creating TEXNAME.pdf.
```

MacOS

Recommend to install [MacTex](https://tug.org/mactex/mactex-download.html)

```bash
# verify whether the installation is successful.
$ xelatex --help
# Usage: xetex [OPTION]... [TEXNAME[.tex]] [COMMANDS]
# or: xetex [OPTION]... \FIRST-LINE
# or: xetex [OPTION]... &FMT ARGS
# Run XeTeX on TEXNAME, usually creating TEXNAME.pdf.
```

### Installation
```bash
pip install latex_to_image
```

### CLI
```bash
$ latex_to_image "x^2+y^2=1" res.png
```

### Python
```python
import cv2
from latex_to_image import LaTeXToImg

render = LaTeXToImg()

formula = "x^2 + y ^2 = 1"
img = render(formula)
cv2.imwrite("res.png", img)
```

### Result



### Reference
- [LaTeX-OCR](https://github.com/lukas-blecher/LaTeX-OCR/blob/main/pix2tex/dataset/latex2png.py)