Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/swhl/latextoimage
- Owner: SWHL
- License: mit
- Created: 2023-12-20T01:29:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-22T07:32:09.000Z (about 1 year ago)
- Last Synced: 2024-11-25T07:45:05.448Z (2 months ago)
- Topics: convert, latex, latex-ocr
- Language: Python
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### 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 LaTeXToImgrender = 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)