Skip to main content

Translate math-heavy papers

Project description

MathTranslate

en zh

This is a project to provide translation of scientific papers with heavy math symbols from any language to any language while keeping the math symbols unchanged. In most translation softwares you wouldn't be able to keep equations and it would annoy you. This project is based on the following two tools:

  1. mathpix: it provides an interface to convert text+equation images to latex code. Unfortunately it is not totally free. The price can be seen at https://mathpix.com/pricing. In further developments we will try our best to reduce the number of requests to save your money. (This project itself is 100% free and open-source!)
  2. google translate

The main work of this project is to translate LaTex files based on Google Translate of plain text, with mathpix combined we can finally translate pdf (or other formats) to pdf.

Here's an example of what you get finally.

Although it is currently a small project, we are aware that this project has received much more attention that we expected. We are planning more developments for better user experience.

Releases

Mar 16, 2023

We are now supporting all operating systems! You only need to have python and pip to do everything.

Requirements

  1. A mathpix account. Unfortunatedly it is not totally free. The current price is free for 100 screenshots (requires an educational email in registeration) and $5 per month for 5000 screenshots.
  2. Python3 and library mtranslate: pip install mtranslate
  3. texlive (or any other tool to generate pdf from tex). For Chinese you would need CJK package.

Usage

  1. Download mathpix. In the Settings-Formatting, change "Inline math delimiters" and "Block mode delimiters" to "\( ... \)" and "\[ ... \]", respectively.
  1. Add directory MathTranslate/scripts to PATH
  2. Use mathpix to screenshot what you want to translate, copy the output latex code and save in a txt file. Mathpix currently recognizes continuous text (which can be one or more paragraphs). You can also screenshot and copy multiple separated texts and put them in the same txt file, we will automatically identify and merge the paragraphs separated by pictures or pages in the next step.
  3. Assume the filename you saved in the previous step is main.txt. Run translate_tex.py main.txt. You will get a translated tex file main.tex and a corresponding pdf file main.pdf in case xelatex is installed on your machine.
  4. Since this project is small, sometimes you need to slightly change the final tex file for compilation.
  5. The default code is translating English into Chinese. If you want to translate from/to other languages, you just need to change language_from and language_to in MathTranslate/scripts/translate_tex.py

Examples

In the example directory, you can see main.txt which is the mathpix output of a part of paper.pdf. Run translate_tex.py main.txt and you will get the main.tex and main.pdf. translated.png is what you should expect to see in the main.pdf.

Further developments

  1. Automatically extract images from pdf, process images in a batch and output a single translated pdf by one click!
  2. Reduce the number of mathpix requests by open-source techniques.
  3. A more user-friendly interface.

If you are interested in making contributions, please contact me by susyustc@gmail.com or Wechat account sunjiace2262.

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

mathtranslate-1.1.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

mathtranslate-1.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file mathtranslate-1.1.0.tar.gz.

File metadata

  • Download URL: mathtranslate-1.1.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for mathtranslate-1.1.0.tar.gz
Algorithm Hash digest
SHA256 367713eddcfecf29cb4a070eac758128c0bd40fddf436c07963ca3b27e0e71b4
MD5 26b39aa575f6964ef4cad90951f4b5c3
BLAKE2b-256 fbeaa8ca998a5ad894f01647da8ec7120b445a4e7e7bfbe739274dd072a174df

See more details on using hashes here.

File details

Details for the file mathtranslate-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mathtranslate-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cd9eec1664e2928e645ba8f4367b94a99549e1eb94ce9dd9836fc1e48a21cd2
MD5 3a3a65b6dcee28ade7b58fcffa23e0a3
BLAKE2b-256 ccc6329cd1068e5bf4604d2721bfda9024bed8850e208df3a61fe1d72fe33230

See more details on using hashes here.

Supported by

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