SKILL.md
LaTeX Document Translation Guide
Overview
Translating LaTeX academic documents requires preserving mathematical formulas, cross-references, citations, and formatting while converting the text between languages. This guide covers tools and techniques for translating LaTeX papers — from command-line utilities to full document pipelines. Particularly useful for making research accessible across language barriers.
LaTeXTrans Approach
# Install LaTeXTrans
pip install latextrans
# Translate a LaTeX file
latextrans translate paper.tex --from en --to zh --output paper_zh.tex
How It Works
- Parse: Extract text segments while preserving LaTeX commands
- Protect: Shield math environments (
$...$,\[...\], equations) - Translate: Send text segments to translation API
- Reconstruct: Reassemble with original LaTeX structure
Python Usage
from latextrans import LatexTranslator
translator = LatexTranslator(
source_lang="en",
target_lang="zh",
engine="google", # or "deepl", "openai"
)
# Translate a file
translator.translate_file("paper.tex", "paper_zh.tex")
# Translate a string
result = translator.translate(
r"The loss function $\mathcal{L}(\theta)$ is minimized "
r"using gradient descent with learning rate $\eta$."
)
# Output preserves $\mathcal{L}(\theta)$ and $\eta$ untouched
MathTranslate Tool
# Install MathTranslate (specialized for math-heavy papers)
pip install mathtranslate
# Translate arXiv paper directly
translate_arxiv 2301.00001 -o translated.tex
# Translate local file
translate_tex paper.tex -o paper_translated.tex
MathTranslate Features
# Configuration
import mathtranslate
# Set translation backend
mathtranslate.config.set_translator("google") # free
mathtranslate.config.set_translator("openai") # higher quality
# Translate with customization
mathtranslate.translate(
input_file="paper.tex",
output_file="paper_zh.tex",
source_lang="en",
target_lang="zh-CN",
threads=4, # parallel translation
)
