LaTeXTrans Documentation
repository·main·Indexed 19 days ago
https://github.com/niutrans/latextransAn end-to-end LaTeX document translation system that uses multi-agent collaboration to translate LaTeX source code into multilingual PDFs. It preserves formulas, layout, and cross-references by translating pre-processed source code rather than PDFs. The system includes a CLI for processing arXiv IDs and local projects, a Streamlit-based GUI, and specialized classes for parsing (LatexParser), compiling (LaTexCompiler), and reconstructing (LatexConstructor) LaTeX documents.
What's inside LaTeXTrans
- LaTeXTrans is a specialized tool designed to translate documents written in LaTeX format into various target languages. A common use case is translating scientific papers from arXiv (e.g., English to Chinese) while preserving the LaTeX structure.
How LaTeXTrans works
mainLaTeXTrans is a structured LaTeX document translation system based on multi-agent collaboration. Unlike traditional PDF translation methods that often break formulas and formatting, LaTeXTrans translates the pre-processed LaTeX source code directly.
The system uses a workflow consisting of six specialized agents:
- Parser
- Translator
- Validator
- Summarizer
- Terminology Extractor
- Generator
This approach ensures that formulas, layout, and cross-references remain intact while maintaining terminology consistency and generating a high-quality translated PDF that matches the original layout.
Use the Streamlit GUI
mainFor a graphical interface with progress bars, logs, and configurable parameters, you can use the Streamlit-based GUI.
Option 1: Run the dedicated command
latextrans-guiOption 2: Run via Streamlit directly
streamlit run src/gui/streamlit_app.pylatextrans-guiInstall LaTeXTrans
mainTo install LaTeXTrans, clone the repository and install it in editable mode using pip. It is recommended to use a Conda virtual environment.
Prerequisites
To compile LaTeX files and generate PDF outputs, you must have a LaTeX distribution installed:
- MikTex (Recommended for being lightweight): When installing, ensure you select "install on the fly". You must also install Strawberry Perl to support compilation.
- TeXLive
Installation Steps
Using Conda (Recommended):
conda create -n latextrans python=3.10 -y conda activate latextrans git clone https://github.com/NiuTrans/LaTeXTrans.git cd LaTeXTrans pip install -e .Standard Installation:
git clone https://github.com/NiuTrans/LaTeXTrans.git cd LaTeXTrans pip install -e .pip install -e .Launch the LaTeXTrans GUI
mainFor a browser-based interface that shows live workflow progress, logs, and runtime configuration, you can launch the Streamlit-based GUI.
Run either the dedicated command or the Streamlit command directly.
# Using the dedicated CLI command latextrans-gui # Or running Streamlit directly streamlit run src/gui/streamlit_app.pyConfigure LaTeXTrans API settings
mainBefore running translations, you must configure your Large Language Model (LLM) credentials in the
config/default.tomlfile. You need to specify themodelname, yourapi_key, and thebase_urlfor the API.Model Recommended base_urldeepseek-chathttps://api.deepseek.com/v1/chat/completionsgpt-4ohttps://api.openai.com/v1/chat/completionsgemini-2.5-prohttps://generativelanguage.googleapis.com/v1beta/openai/chat/completionsmodel = "deepseek-chat" api_key = "your_api_key_here" base_url = "https://api.deepseek.com/v1/chat/completions"Configure LaTeXTrans LLM settings
mainBefore running translations, you must configure your Large Language Model (LLM) settings in the
config/default.tomlfile. You need to provide themodelname, yourapi_key, and thebase_urlfor the API.Recommended
base_urlexamples:- deepseek-chat:
https://api.deepseek.com/v1/chat/completions - gpt-4o:
https://api.openai.com/v1/chat/completions - gemini-2.5-pro:
https://generativelanguage.googleapis.com/v1beta/openai/chat/completions
model = "deepseek-chat" api_key = "your_api_key_here" base_url = "https://api.deepseek.com/v1/chat/completions"- deepseek-chat:
Use the latextrans CLI to translate LaTeX projects
mainThe
latextransCLI (viamain.py) allows you to automate the translation of LaTeX documents. You can provide input via arXiv IDs, local project directories, or compressed archives. The system uses aCoordinatorAgentto manage the translation workflow based on a TOML configuration file.Key Input Methods:
- arXiv IDs: Use
--arxivto provide one or more arXiv IDs. - Local Projects: Use
--projectto provide paths to local directories or archive files (.zip,.tar,.tar.gz,.tgz). - Batch Processing: Use
--all-existingto process all projects already present in the configuredtex_sources_dir.
# Translate a single arXiv paper latextrans --arxiv 2508.18791 # Batch translate multiple arXiv papers latextrans --arxiv 2508.18791v2, 2407.01648 # Translate a local project directory or archive latextrans --project /path/to/project_dir latextrans --project /path/to/archive.zip # Process all existing projects in the source directory latextrans --all-existing- arXiv IDs: Use
Launch the latextrans GUI via Streamlit
mainThe
latextransgraphical user interface can be launched using the Python entrypoint insrc/gui/launcher.py. This command starts a Streamlit application that provides a visual interface for the translation tools. It is equivalent to runningpython -m streamlit run src/gui/streamlit_app.pyfrom the project root.python src/gui/launcher.pyConfigure latextrans via TOML
mainThe translation behavior is controlled by a TOML configuration file. The CLI can override several keys in this configuration.
Configurable sections and keys via CLI:
llm_config.base_url: Set via--url.llm_config.model: Set via--model.llm_config.api_key: Set via--key.paper_list: Extended by providing--arxivIDs.tex_sources_dir: Set via--source.output_dir: Set via--output.
If
user_termis not set in the config, the system will automatically attempt to determine the arXiv category for downloaded papers.Translate local LaTeX projects
mainLaTeXTrans supports translating local files or directories using the
--projectflag.Compressed Archives
Provide a path to a
.zip,.tar,.tar.gz, or.tgzfile:latextrans --project D:\path\to\paper_source.tar.gzUncompressed Directories
Provide the path to the extracted project directory:
latextrans --project D:\path\to\paper_project_dirProcess All Existing Projects
To process all existing projects within the
tex sourcedirectory, use:latextrans --all-existingNote: When using
--arxivor--project, LaTeXTrans only processes the explicitly specified input and will not scan other projects intex source.latextrans --project D:\path\to\paper_project_dirTranslate arXiv papers via CLI
mainYou can translate papers directly using their arXiv ID. The system will download the LaTeX source, run the translation workflow (parsing, translating, reconstructing, and compiling), and save the results in the
outputsfolder.Single Paper
Use the
--arxivflag with the ID. You can also specify a version (e.g.,v2).latextrans --arxiv 2508.18791 # Or with version latextrans --arxiv 2508.18791v2Batch Translation
Provide multiple comma-separated arXiv IDs to translate them in bulk.
latextrans --arxiv 2508.18791v2, 2407.01648latextrans --arxiv 2508.18791