Skip to main content

Handwritten LaTeX symbol classifier for the desktop

Project description

Hand TeX

License: GPL v3 GitHub release (latest by date) PyPI version Code style: black

Draw the symbol to find out what LaTeX command to use.

Example

Features

  • Over 3500 symbols and their variations, of which over 1700 are unique
  • Browse a list of all symbols
  • Fully offline
  • Supported packages: amsmath, amssymb, bbold, cmll, dsfont, esint, fdsymbol, gensymb, halloweenmath, latex2e, latexsym, logix, marvosym, mathabx, mathdots, mathrsfs, MnSymbol, stix, stix2, stmaryrd, textcomp, tipa, txfonts, upgreek, wasysym

This was inspired by the Detexify project and uses some of the same training data, now with new symbols and additional training data.


Installation

Platform Format Link
Linux Flatpak Coming soon
AUR Coming soon
Windows Executable HandTeX.exe
All Platforms Python package pip install handtex

The Python package requires Python 3.10 or later. Ensure Python is in your PATH.

If installed with Python, run handtex to start the program. If that doesn't work, try python -m handtex.main.

Does this work with CUDA?

Yes, but for using Hand TeX, this is not necessary. The model is small enough to run very quickly on a CPU, there is no noticeable difference.

Can I help make more training data?

Yes! In Hand TeX, go to the hamburger menu and select "Help symbol training". This will present you with a symbol to draw. Then just submit your drawing and it will be saved to a .json file. The location for this can be configured. Once you are satisfied with the drawings you have collected, send all of the .json files in one .zip archive to voxel.aur@gmail.com. Thanks!

Training example

Can I help in other ways?

Yes, help is always appreciated. If you know a thing or two about training models, I would like to know how to improve it further.

If you'd like to suggest new symbols, please open an issue and include drawings you made with the "Help symbol training" feature. To do this for new symbols, just manually enter the symbol name you want to suggest and press skip in the interface. Then draw the symbol and submit it. It would also be nice to include a .tex file that shows the symbol in use, so that it compiles with pdflatex or xelatex.

What is the difference between Hand TeX and Detexify?

Hand TeX supports the same symbols and many more, as it uses a larger dataset. The Detexify model uses time information to know what order you drew the strokes in, and what direction too. This can be useful for common symbols that are drawn in a specific way, but this approach struggles on more complex symbols that don't have a common way to draw them.

Hand TeX renders your strokes to a flat image and uses a convolutional neural network to classify the symbol. This approach ignores the order you draw the strokes in, focusing solely on the shape of the symbol.

The expanded, modified dataset is available under the same license as the original Detexify dataset here.

Running from source

These instructions assume you have Python 3.10 or later installed, as well as a collection of terminal utilities. This will work on any Linux system, or other OS with the appropriate tools installed.

To run from source, clone the repository

git clone https://github.com/VoxelCubes/Hand-TeX.git
cd Hand-TeX

Optionally, create a virtual environment

python -m venv venv
source venv/bin/activate

Install the dependencies

pip install -r requirements.txt

Optionally, if you wish to train and develop, also install the dev dependencies

pip install -r requirements_training.txt

You need a model to run the program. You have two options:

  1. Download the model from the releases page
mkdir -p handtex/data/model
curl -o handtex/data/model/handtex.safetensors https://github.com/VoxelCubes/Hand-TeX/releases/download/model/handtex.safetensors
curl -o handtex/data/model/encodings.txt https://github.com/VoxelCubes/Hand-TeX/releases/download/model/encoding.txt
  1. Train the model yourself. This requires the dev dependencies and a lot of time.
mkdir -p training/database
curl -o training/database/handtex.db.tar.xz https://github.com/VoxelCubes/Hand-TeX/releases/download/database/handtex.db.tar.xz
tar -xf training/database/handtex.db.tar.xz -C training/database
PYTHONPATH=. python training/train.py

Finally, run the program

PYTHONPATH=. python handtex/main.py

or

make run

If you have changed anything with the symbols or Qt ui files, you will need to regenerate the resources

make refresh-assets

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

handtex-1.0.1.tar.gz (3.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

handtex-1.0.1-py3-none-any.whl (3.3 MB view details)

Uploaded Python 3

File details

Details for the file handtex-1.0.1.tar.gz.

File metadata

  • Download URL: handtex-1.0.1.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for handtex-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0001f5fbbb4b0eeaeac79c36ff6676c9c9323b045d9c3950e4565dad1fd70fa3
MD5 9d662a721db44eb01c47144b15a74c96
BLAKE2b-256 11ac742a16ab097209884859eadb40dab85b0dd32bf3e4da6611c43f0efd4354

See more details on using hashes here.

File details

Details for the file handtex-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: handtex-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for handtex-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5a4f6446847e1fe9ec30ba8205cf6dd2468f7729897b3c9be779713811033335
MD5 9d8d930790052e077fad47f63b1ad028
BLAKE2b-256 2fd3b7497215e2d813ae1b3c5d603ffc90d56b591985585dfb919715c4766e3e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page