LaTeX Document Translation Guide
SkillDocs & knowledgeTranslate LaTeX documents preserving math formulas and structure
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; ahel provides instructions and does not run this skill.
Add ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
Then ask your AI: use the LaTeX Document Translation Guide skill
What this skill tells your AI
The instructions your AI receives, as published by brycewang-stanford/auto-empirical-research-skills in skills/43-wentorai-research-plugins/skills/tools/ocr-translate/latex-translation-guide/SKILL.md and read by ahel’s review.
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
)
Manual Translation Tips
Protecting Math Environments
import re
def extract_and_protect(latex_text: str) -> tuple:
"""Extract math environments before translation."""
math_pattern = r'(\$\$[\s\S]*?\$\$|\$[^$]+\$|\\begin\{equation\}[\s\S]*?\\end\{equation\}|\\begin\{align\}[\s\S]*?\\end\{align\})'
placeholders = {}
counter = [0]
def replace_math(match):
key = f"__MATH_{counter[0]}__"
placeholders[key] = match.group(0)
counter[0] += 1
return key
protected = re.sub(math_pattern, replace_math, latex_text)
return protected, placeholders
def restore_math(translated: str, placeholders: dict) -> str:
"""Restore math environments after translation."""
for key, value in placeholders.items():
translated = translated.replace(key, value)
return translated
Commands to Protect
% Always protect these:
\ref{...} % Cross-references
\cite{...} % Citations
\label{...} % Labels
\eqref{...} % Equation references
\url{...} % URLs
\texttt{...} % Code/monospace
% Math environments to protect:
$...$ % Inline math
$$...$$ % Display math
\[...\] % Display math
\begin{equation}...\end{equation}
\begin{align}...\end{align}
\begin{theorem}...\end{theorem} % Custom environments
Bilingual Output
% Create side-by-side bilingual document
\usepackage{paracol}
\begin{paracol}{2}
\switchcolumn[0]
The transformer architecture has become...
\switchcolumn[1]
Transformer架构已经成为...
\switchcolumn[0]
Self-attention computes $\text{Attention}(Q,K,V) = \text{softmax}(\frac{QK^T}{\sqrt{d_k}})V$
\switchcolumn[1]
自注意力计算 $\text{Attention}(Q,K,V) = \text{softmax}(\frac{QK^T}{\sqrt{d_k}})V$
\end{paracol}
Translation Backends
| Backend | Quality | Cost | Speed |
|---|---|---|---|
| Google Translate | Good | Free | Fast |
| DeepL | Better | Freemium | Fast |
| OpenAI GPT-4 | Best | Paid | Slower |
| Claude | Best | Paid | Slower |
References
Signals
- GitHub stars
- 4k
- Forks
- 531
- Last commit
- Sep 2026
ahel review
K1binfo
installs-packages
Automated review, not a security audit. Ruleset v1+k2.
Advanced
- Item type
- skill
- Key
latex-translation-guide- Source
- github.com/brycewang-stanford/auto-empirical-research-skills
github.com/brycewang-stanford/auto-empirical-research-skills
Related picks
Skill · wshobson
The pick for Pythonpython-pro
Skill · jeffallan
The pick for Pythonlatex-posters
Skill · k-dense-ai
The pick for LaTeXlatex-drawing-guide
Skill · brycewang-stanford
The pick for LaTeXhandoff
Skill · mattpocock
More in Docs & knowledgecanvas-design
Skill · anthropics
More in Docs & knowledge