← 返回 Skills 市场
ldxs001

latex-modular

作者 Lighthexuish · GitHub ↗ · v1.2.4 · MIT-0
cross-platform ⚠ suspicious
52
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install latex-modular
功能描述
LaTeX 模块化组合技能。提取 LaTeX 文档头/组件(表格、图片、列表、章节样式)作为可组合模块,通过 Python 脚本稳定组合生成不报错的 lualatex 文档,支持从原始 LaTeX 代码重构进模块化体系。
使用说明 (SKILL.md)

\r

latex-modular\r

\r

触发场景\r

\r

文件更新约束\r

\r

本技能的 .md 文件禁止使用 Write/Edit 工具更新。\r 必须用 scripts/ 下的 Python 脚本原子写入(tmp + os.replace())。\r \r | 文件 | 更新方式 | 脚本 |\r |------|----------|--------|\r | SKILL.md frontmatter | Python 原子写入 | scripts/update_frontmatter.py |\r | SKILL.md 正文 | Python 直接重建 | scripts/safe_write.pysafe_write() |\r | scripts/components/*.txt | Python 写入 | scripts/component_manager.py |\r | references/*.md | scripts/safe_write.py | 随技能自带 |\r \r

  • [把这段 LaTeX 做成模块化模板]\r
  • [生成一个 LaTeX 文档,用模块化方式]\r
  • [重构这个 LaTeX 代码进模块化体系]\r
  • [提取 LaTeX 的组件,做成可复用模块]\r
  • [用 latex-modular 生成一个...文档]\r
  • [验证这段 LaTeX 能不能编译通过]\r \r 不触发:\r
  • 用户只是问 [LaTeX 怎么写]——这是闲聊\r
  • 用户要求直接编辑 .tex 文件而不使用模块化方式\r \r

核心能力\r

\r

📚 渐进式加载:本技能采用渐进式 MD 体系,SKILL.md 为入口(≤230行),详细内容拆分到 references/*.md 按需加载。\r \r

  • extract 模式 — 从已有 LaTeX 代码中提取文档头、宏包、自定义命令、环境、样式,保存为可复用组件\r
  • compose 模式 — 通过 Python 脚本按模块组合生成完整 LaTeX 文档,确保编译无错误\r
  • refactor 模式 — 将原始 LaTeX 代码重构进模块化体系,保留原文语义,按模块拆分存储\r
  • validate 模式 — 使用 lualatex 编译验证生成的 .tex 文件,报告错误并返回修复建议\r
  • template 模式 — 模板库+自定义保存+内容注入。支持 --template 按名加载、--save-as 保存自定义模板、--content 注入正文、--list-templates 等,内置 article/report 两种预设模板(scripts/template.py + scripts/templates/)\r \r

渐进式文件索引\r

\r | 文件 | 位置 | 说明 |\r |------|------|------|\r | references/guide.md | 使用指南 | 完整使用指南(触发词、工作流程、输出格式) |\r | references/architecture.md | 架构说明 | 内部架构(组件分类、组合引擎、验证器) |\r | references/antipatterns.md | 反模式 | 常见 LaTeX 错误 + 正确做法 |\r | references/faq.md | FAQ | 常见问题解答(宏包冲突、字体问题、编译错误) |\r | references/changelog.md | 更新日志 | 版本更新记录 |\r | references/component-spec.md | 组件规范 | 命名、参数、依赖声明 |\r \r

脚本工具\r

\r | 脚本 | 功能 |\r |------|------|\r | scripts/compose.py | 模块组合引擎,按依赖顺序组合组件 |\r | scripts/extract.py | 从 LaTeX 源文件提取组件 |\r | scripts/validate.py | 编译验证,调用 lualatex 并检查输出 |\r | scripts/refactor.py | 重构引擎,将原始 LaTeX 转为模块化结构 |\r | scripts/template.py | 模板库管理:--template 加载、--save-as 保存、--content 注入、--list-templates 等 |\r | scripts/component_manager.py | 组件库管理(增删改查) |\r | scripts/safe_write.py | 原子写入工具(tmp + os.replace)|\r | scripts/update_frontmatter.py | 更新 SKILL.md frontmatter |\r \r

依赖\r

\r

  • Python 3.11+(推荐 3.13.12 managed)\r
  • lualatex(默认,推荐):/c/Program Files/MiKTeX/miktex/bin/x64/lualatex\r
  • 也可通过 --engine xelatex 切换为 xelatex\r
  • 不推荐 pdflatex\r
  • 首次编译时 MiKTeX 会自动安装缺失宏包,可能需要等待\r
  • 中文字体依赖:SimSun、SimHei、KaiTi、FangSong(Windows 系统自带)\r \r

工作流程\r

\r

extract 模式(提取组件)\r

\r

  1. 读取用户提供的 LaTeX 源文件\r
  2. 解析文档结构:导言区(\documentclass 到 \begin{document})、正文区\r
  3. 提取组件并分类保存到 scripts/components/:\r
    • preamble/*.tex — 宏包引入、颜色定义、字体配置\r
    • environments/*.tex — 自定义环境(mylist、mycolumns 等)\r
    • commands/*.tex — 自定义命令(\ imu、\seeref 等)\r
    • styles/*.tex — 章节样式、目录样式、页眉页脚\r
    • tables/*.tex — 表格样式模板\r
    • graphics/*.tex — 图片插入模板\r
  4. 生成组件索引 scripts/components/manifest.json\r \r

compose 模式(组合生成)\r

\r

  1. 读取 scripts/components/manifest.json 获取可用组件列表\r
  2. 根据用户需求选择所需组件\r
  3. 调用 scripts/compose.py 按正确顺序组合:\r
    • 第1层:文档类声明\r
    • 第2层:宏包引入(自动去重)\r
    • 第3层:自定义命令和环境\r
    • 第4层:样式配置\r
    • 第5层:文档正文(用户提供)\r
  4. 输出完整 .tex 文件\r \r

组件库结构\r

\r

scripts/components/\r
├── manifest.json          # 组件索引\r
├── preamble/              # 导言区组件\r
│   ├── class-settings.txt\r
│   └── packages.txt\r
├── environments/          # 自定义环境\r
│   ├── mylist.txt\r
│   ├── mycolumns.txt\r
│   └── abstract-env.txt\r
├── commands/              # 自定义命令\r
│   ├── title-commands.txt\r
│   └── background.txt\r
├── styles/                # 样式配置\r
│   ├── section-style.txt\r
│   ├── toc-style.txt\r
│   └── header-footer.txt\r
├── tables/                # 表格模板\r
│   └── table-style.txt\r
└── graphics/              # 图片模板\r
    └── figure-insert.txt\r
```\r
\r
### refactor 模式(重构)\r
\r
1. 读取原始 LaTeX 文件\r
2. 解析并提取各组件到 `scripts/components/` 对应目录\r
3. 生成模块化版本的主文档(使用 \\input{} 或 \\include{} 引入组件)\r
4. 验证重构后文档编译通过\r
\r
### validate 模式(编译验证)\r
\r
1. 调用 `scripts/validate.py`\r
2. 使用系统 lualatex 编译 .tex 文件\r
3. 捕获编译输出,解析错误和警告\r
4. 返回结构化报告:成功/失败、错误位置、修复建议\r
安全使用建议
Review before installing if you handle untrusted .tex files. Prefer running validation in a sandbox or low-privilege workspace, avoid arbitrary --engine values, disable MiKTeX auto-installation if possible, and confirm which files will be written before using extract, refactor, template, or --fix modes.
能力评估
Purpose & Capability
The documented purpose is coherent: extracting, composing, refactoring, templating, and validating LaTeX documents. File writes and LaTeX compilation are expected for that purpose, but they carry real local execution risk.
Instruction Scope
The scripts expose an --engine parameter and run the selected executable without a strict allowlist in multiple paths. Some workflows validate by default, so compilation can happen as part of normal template/refactor use rather than only a clearly isolated validation step.
Install Mechanism
The package consists of markdown, JSON, text components, and Python helper scripts. It declares no external Python dependency installation and VirusTotal telemetry is clean.
Credentials
Running lualatex/xelatex on user-provided or assembled TeX is proportionate to the skill, but the artifacts do not require sandboxing, filesystem isolation, or network/package-install controls; the docs also note MiKTeX may auto-install missing packages.
Persistence & Privilege
No background persistence, credential use, or service installation was found. The skill can persistently alter its local component/template library, create backups, generate outputs, and remove generated PDFs/auxiliary files as part of normal operation.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install latex-modular
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /latex-modular 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.2.4
- Removed the file skill-card.md. - Updated documentation to reflect changes in file extensions for components (now *.txt instead of *.tex). - Adjusted tables, listings, and instructions in SKILL.md to match the new *.txt file naming convention for the components directory.
v1.2.2
- Improved documentation in SKILL.md with detailed usage scenarios, workflow explanations, and modular file indexing. - Expanded descriptions of extract, compose, refactor, validate, and template modes for clarity and completeness. - Added clear constraints on file update methods, emphasizing the use of specific Python scripts for atomic writes. - Refined dependency specifications, LaTeX engine recommendations, and initial setup guidance. - Now includes comprehensive tables outlining file structure, script utilities, and typical directory organization.
元数据
Slug latex-modular
版本 1.2.4
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

latex-modular 是什么?

LaTeX 模块化组合技能。提取 LaTeX 文档头/组件(表格、图片、列表、章节样式)作为可组合模块,通过 Python 脚本稳定组合生成不报错的 lualatex 文档,支持从原始 LaTeX 代码重构进模块化体系。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 52 次。

如何安装 latex-modular?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install latex-modular」即可一键安装,无需额外配置。

latex-modular 是免费的吗?

是的,latex-modular 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

latex-modular 支持哪些平台?

latex-modular 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 latex-modular?

由 Lighthexuish(@ldxs001)开发并维护,当前版本 v1.2.4。

💬 留言讨论