Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Translate LaTeX documents preserving math formulas and structure
.claude/skills/brycewang-stanford-latex-translation-guide/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | -13% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 13% | 0% |
| case-07 | ✗→✓ | ▲ Improved | -31% | 0% |
| case-08 | ✗→✓ | ▲ Improved | -23% | 0% |
| case-09 | ✗→✓ | ▲ Improved | -44% | 0% |
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.
bash# Install LaTeXTrans pip install latextrans # Translate a LaTeX file latextrans translate paper.tex --from en --to zh --output paper_zh.tex
$...$, \[...\], equations)pythonfrom 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
bash# 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
python# 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 )
pythonimport 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
latex% 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
latex% 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}
| Backend | Quality | Cost | Speed | |---------|---------|------|-------| | Google Translate | Good | Free | Fast | | DeepL | Better | Freemium | Fast | | OpenAI GPT-4 | Best | Paid | Slower | | Claude | Best | Paid | Slower |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 31,033 | 56,240 | +81% | 1 | 1 | 0% | 4,625 | 5,300 | +15% | 0 | 0 | — |
case-02 | fail→pass | 28,996 | 13,008 | -55% | 1 | 1 | 0% | 4,326 | 3,782 | -13% | 0 | 0 | — |
case-03 | pass→pass | 40,816 | 10,835 | -73% | 1 | 1 | 0% | 1,992 | 3,170 | +59% | 0 | 0 | — |
case-04 | pass→pass | 51,394 | 20,284 | -61% | 1 | 1 | 0% | 3,188 | 5,019 | +57% | 0 | 0 | — |
case-05 | pass→pass | 17,049 | 24,614 | +44% | 1 | 1 | 0% | 3,438 | 5,053 | +47% | 0 | 0 | — |
case-06 | fail→pass | 15,794 | 8,641 | -45% | 1 | 1 | 0% | 2,195 | 2,481 | +13% | 0 | 0 | — |
case-07 | fail→pass | 14,936 | 33,912 | +127% | 1 | 1 | 0% | 2,877 | 1,976 | -31% | 0 | 0 | — |
case-08 | fail→pass | 17,225 | 7,690 | -55% | 1 | 1 | 0% | 2,959 | 2,292 | -23% | 0 | 0 | — |
case-09 | fail→pass | 17,339 | 3,983 | -77% | 1 | 1 | 0% | 3,244 | 1,822 | -44% | 0 | 0 | — |
case-10 | pass→pass | 18,970 | 17,409 | -8% | 1 | 1 | 0% | 3,472 | 4,522 | +30% | 0 | 0 | — |
case-11 | fail→fail | 38,067 | 17,110 | -55% | 1 | 1 | 0% | 3,198 | 3,955 | +24% | 0 | 0 | — |
case-12 | fail→pass | 18,908 | 12,136 | -36% | 1 | 1 | 0% | 2,900 | 3,436 | +18% | 0 | 0 | — |
case-13 | pass→pass | 16,900 | 15,290 | -10% | 1 | 1 | 0% | 3,089 | 4,071 | +32% | 0 | 0 | — |
case-14 | pass→pass | 18,422 | 19,378 | +5% | 1 | 1 | 0% | 2,999 | 4,102 | +37% | 0 | 0 | — |
case-15 | pass→pass | 12,954 | 9,903 | -24% | 1 | 1 | 0% | 2,181 | 3,013 | +38% | 0 | 0 | — |
case-16 | pass→pass | 10,074 | 8,487 | -16% | 1 | 1 | 0% | 1,883 | 2,728 | +45% | 0 | 0 | — |
case-17 | fail→pass | 18,798 | 19,297 | +3% | 1 | 1 | 0% | 3,041 | 4,423 | +45% | 0 | 0 | — |
case-18 | pass→pass | 15,216 | 19,245 | +26% | 1 | 1 | 0% | 2,510 | 3,977 | +58% | 0 | 0 | — |
case-19 | pass→pass | 17,829 | 3,162 | -82% | 1 | 1 | 0% | 2,366 | 1,717 | -27% | 0 | 0 | — |
case-20 | fail→pass | 17,745 | 22,911 | +29% | 1 | 1 | 0% | 2,608 | 5,623 | +116% | 0 | 0 | — |
case-21 | pass→pass | 12,043 | 2,494 | -79% | 1 | 1 | 0% | 2,080 | 1,604 | -23% | 0 | 0 | — |
case-22 | fail→pass | 18,555 | 14,097 | -24% | 1 | 1 | 0% | 2,815 | 3,695 | +31% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +41 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.