PaperMirror: VS Code LaTeX Chinese Preview Extension, Cursor Compatible
Write English LaTeX, read a Chinese mirror beside it.
PaperMirror is a lightweight LaTeX translation preview extension for non-native English researchers writing technical papers. It works in VS Code and can also be installed in Cursor through a local .vsix package.
Language / 语言: 中文 | English
Keywords: LaTeX Chinese preview, LaTeX translation preview, TeX Chinese mirror, VS Code LaTeX translator, Cursor LaTeX translator, AI paper writing assistant, academic writing, technical paper writing, OpenAI-compatible LaTeX translation, DeepSeek LaTeX translation, SiliconFlow LaTeX translation, MathJax LaTeX preview.
中文
English
PaperMirror 是一个面向非英语母语科研作者的 轻量级 LaTeX 翻译预览工具。你继续在左侧写英文 .tex 源码,PaperMirror 在右侧生成简体中文镜像预览,帮助你快速检查论文逻辑、术语和段落表达。
它不会修改你的论文源码,不替代 Overleaf、LaTeX Workshop 或最终 PDF 编译。英文 .tex 仍然是唯一真实稿件,中文 preview 只是写作时的阅读辅助。
功能
- 当前活动
.tex 文件的中文侧边预览。
- 保存后自动更新,也可以手动点击
Refresh。
- 只翻译新增或修改过的 block,并复用本地缓存。
- 长文档渐进式渲染:先显示结构和已有缓存,后续一批批更新右侧预览。
- 保护并恢复 inline math、display math、
cite、ref、label、url 等内容。
- MathJax 本地渲染公式。
- 常见
algorithm + algorithmic 伪代码渲染为可翻译列表。
itemize、enumerate、highlights 渲染为列表。
figure、table、algorithm2e、tikzpicture 等复杂环境显示为轻量占位。
- 默认不翻译
% 注释掉的 LaTeX 内容;需要时可打开 paperMirror.translateComments。
- 支持中文预览字体和字号设置。
- 支持
paperMirror.glossary 术语表配置。
- 默认从模型输入和中文译文里移除 cite/ref/url;如需定位提示,可打开
paperMirror.showReferenceMarkersInTranslations 显示轻量 [cite]、[ref]、[url]。
- API key 优先存储在 VS Code SecretStorage,也支持在 settings 中临时填写。
- 右侧 preview 内置进度、cache、warning 和安全 fallback 提示。
API 兼容性说明
PaperMirror 通过 OpenAI-compatible Chat Completions 接口调用模型。作者目前日常使用并重点测试的是 SiliconFlow,因为作者手头主要可用的是硅基流动 API。
DeepSeek、OpenAI、Ollama 和自定义 OpenAI-compatible endpoint 已在配置层支持,但不同平台的响应格式、JSON 稳定性、限流策略和模型名称可能存在差异。如果你在其他平台上遇到 bug,或希望增加新的 provider / model 预设,欢迎提交 issue 或留言反馈。
快速使用
- 打开一篇英文
.tex 文件。
- 运行
PaperMirror: Set API Key。
- 运行
PaperMirror: Validate API Connection。
- 运行
PaperMirror: Open Preview。
- 修改并保存
.tex 文件,右侧 preview 会更新。
VS Code 和 Cursor 都可以通过本地 .vsix 安装使用。Cursor 用户可运行 Extensions: Install from VSIX... 并选择打包出的 .vsix 文件。
SiliconFlow 示例设置:
{
"paperMirror.provider": "siliconflow",
"paperMirror.baseUrl": "https://api.siliconflow.cn/v1",
"paperMirror.model": "Pro/zai-org/GLM-4.7",
"paperMirror.updateMode": "onSave",
"paperMirror.translateComments": false,
"paperMirror.showReferenceMarkersInTranslations": false,
"paperMirror.previewFontFamily": "Microsoft YaHei",
"paperMirror.previewFontSize": 15
}
paperMirror.baseUrl 只填 base URL,不要填完整的 /chat/completions,PaperMirror 会自动拼接。
常用配置
paperMirror.provider: deepseek、siliconflow、openai、ollama 或 custom。
paperMirror.apiKey: 可选 settings key;更推荐使用 PaperMirror: Set API Key 存到 SecretStorage。
paperMirror.baseUrl: OpenAI-compatible base URL。
paperMirror.model: 模型名。
paperMirror.updateMode: onSave 或 manual。
paperMirror.translateComments: 是否翻译 LaTeX 注释,默认 false。
paperMirror.showReferenceMarkersInTranslations: 是否在中文译文中显示轻量 [cite]、[ref]、[url] 标记,默认 false,优先保证译文流畅度。关闭时真实 key 仍不会进入模型输入。
paperMirror.previewFontFamily / paperMirror.previewFontSize: 中文预览字体和字号。
paperMirror.glossary: 术语表,例如 { "graph-level prediction": "图级预测" }。
paperMirror.maxBlocksPerRefresh: 每次 refresh 最多翻译多少个 block,0 表示不限制。
paperMirror.maxBlocksPerRequest / paperMirror.maxRequestChars: 控制每次 provider 请求大小。
paperMirror.requestTimeoutMs: 单次 provider 请求超时时间。
paperMirror.enableJsonMode: 是否请求 JSON 输出;如果某些兼容接口不支持 response_format,可以关闭。
如果想用其他已安装中文字体:
{
"paperMirror.previewFontFamily": "custom",
"paperMirror.previewCustomFontFamily": "\"LXGW WenKai\", \"Microsoft YaHei\", sans-serif",
"paperMirror.previewFontSize": 15.5
}
常用命令
PaperMirror: Open Preview
PaperMirror: Refresh Preview
PaperMirror: Set API Key
PaperMirror: Validate API Connection
PaperMirror: Open Settings
PaperMirror: Show Logs
PaperMirror: Clear Cache
右侧 preview 顶部只保留 Refresh / Stop 和 ... 菜单;设置、验证、日志、定位源码和清理缓存都在更多菜单里。
长文档建议
第一次测试 20-30 页论文时,可以先设置:
{
"paperMirror.updateMode": "manual",
"paperMirror.maxBlocksPerRefresh": 60
}
确认可用后,再改回:
{
"paperMirror.updateMode": "onSave",
"paperMirror.maxBlocksPerRefresh": 0
}
第一次完整翻译可能需要几分钟;后续保存小改动时,PaperMirror 会优先更新新增或修改过的 block,并复用已有缓存。
当前边界
- v0.1 只支持当前活动
.tex 单文件,不递归解析完整 \input / \include 项目。
- PaperMirror 不是 TeX 编译器,不保证最终 PDF 排版一致。
algorithm2e、复杂表格、TikZ 和自定义宏目前主要按占位处理。
- 公式预览依赖 MathJax,支持常见 inline/display math,但不承诺覆盖所有 TeX 宏包语法。
English
中文
PaperMirror is a lightweight LaTeX translation preview tool for non-native English researchers writing technical papers. You keep editing the English .tex source on the left, while PaperMirror shows a Simplified Chinese mirror preview on the right.
It never modifies your source file and does not replace Overleaf, LaTeX Workshop, or final PDF compilation. The English .tex file remains the single source of truth; the Chinese preview is a reading aid for drafting.
Features
- Chinese side preview for the active
.tex file.
- Save-to-refresh by default, with manual Refresh available.
- Changed-block translation with local cache reuse.
- Progressive rendering for long documents: structure and cached blocks appear first, pending blocks update chunk by chunk.
- Placeholder protection for inline math, display math,
cite, ref, label, url, and related commands.
- Local MathJax rendering.
- Common
algorithm + algorithmic pseudocode rendered as translatable lists.
- List rendering for
itemize, enumerate, and highlights.
- Lightweight placeholders for
figure, table, algorithm2e, and tikzpicture.
- LaTeX comments are not translated by default; enable
paperMirror.translateComments only if needed.
- Configurable Chinese preview font and font size.
- Optional
paperMirror.glossary terms are passed to the translator.
- cite/ref/url commands are removed from model input and translated Chinese text by default. Enable
paperMirror.showReferenceMarkersInTranslations to show lightweight [cite], [ref], and [url] cues in translated preview blocks.
- API keys stored in VS Code SecretStorage by default, with an optional settings-based key for testing.
- In-preview progress, cache, warning, and safe-fallback messages.
API Compatibility
PaperMirror talks to models through an OpenAI-compatible Chat Completions interface. The author currently uses and tests PaperMirror mainly with SiliconFlow, because SiliconFlow is the provider available in the author's daily workflow.
DeepSeek, OpenAI, Ollama, and custom OpenAI-compatible endpoints are configurable, but different platforms may vary in response format, JSON stability, rate limits, and model names. If you encounter provider-specific bugs or want support for another provider/model preset, please open an issue or leave feedback.
Quick Start
- Open an English
.tex file.
- Run
PaperMirror: Set API Key.
- Run
PaperMirror: Validate API Connection.
- Run
PaperMirror: Open Preview.
- Edit and save the
.tex file to refresh the preview.
PaperMirror can be installed locally in VS Code and Cursor through a .vsix package. In Cursor, run Extensions: Install from VSIX... and choose the generated .vsix file.
SiliconFlow example:
{
"paperMirror.provider": "siliconflow",
"paperMirror.baseUrl": "https://api.siliconflow.cn/v1",
"paperMirror.model": "Pro/zai-org/GLM-4.7",
"paperMirror.updateMode": "onSave",
"paperMirror.translateComments": false,
"paperMirror.showReferenceMarkersInTranslations": false,
"paperMirror.previewFontFamily": "Microsoft YaHei",
"paperMirror.previewFontSize": 15
}
Use the base URL only. Do not include /chat/completions; PaperMirror appends it automatically.
Common Settings
paperMirror.provider: deepseek, siliconflow, openai, ollama, or custom.
paperMirror.apiKey: optional settings key. SecretStorage through PaperMirror: Set API Key is recommended.
paperMirror.baseUrl: OpenAI-compatible base URL.
paperMirror.model: model name.
paperMirror.updateMode: onSave or manual.
paperMirror.translateComments: whether to translate LaTeX comments. Default: false.
paperMirror.showReferenceMarkersInTranslations: whether translated Chinese text shows lightweight [cite], [ref], and [url] markers. Default: false for smoother translation quality. Real keys are still removed from model input.
paperMirror.previewFontFamily / paperMirror.previewFontSize: Chinese preview font and size.
paperMirror.glossary: optional terminology map, for example { "graph-level prediction": "图级预测" }.
paperMirror.maxBlocksPerRefresh: maximum translated blocks per refresh. 0 means unlimited.
paperMirror.maxBlocksPerRequest / paperMirror.maxRequestChars: provider request size controls.
paperMirror.requestTimeoutMs: per-request provider timeout.
paperMirror.enableJsonMode: request JSON output when supported. Disable it if a compatible provider does not support response_format.
To use another installed Chinese font:
{
"paperMirror.previewFontFamily": "custom",
"paperMirror.previewCustomFontFamily": "\"LXGW WenKai\", \"Microsoft YaHei\", sans-serif",
"paperMirror.previewFontSize": 15.5
}
Commands
PaperMirror: Open Preview
PaperMirror: Refresh Preview
PaperMirror: Set API Key
PaperMirror: Validate API Connection
PaperMirror: Open Settings
PaperMirror: Show Logs
PaperMirror: Clear Cache
The preview header keeps only Refresh / Stop and a ... menu visible. Settings, validation, logs, source reveal, preview reveal, and cache clearing live under the menu.
Long Documents
For the first smoke test on a 20-30 page paper:
{
"paperMirror.updateMode": "manual",
"paperMirror.maxBlocksPerRefresh": 60
}
After the smoke test works, switch back to:
{
"paperMirror.updateMode": "onSave",
"paperMirror.maxBlocksPerRefresh": 0
}
The first full translation can take several minutes. Later save-triggered refreshes prioritize new or changed blocks and reuse cached translations.
Current Boundaries
- v0.1 supports the active
.tex file only and does not recursively resolve a full \input / \include project.
- PaperMirror is not a TeX compiler and does not guarantee final PDF layout fidelity.
algorithm2e, complex tables, TikZ, and custom macros are mostly shown as placeholders.
- Formula preview uses MathJax and supports common inline/display math, but not every TeX package macro is guaranteed.