Academic Writer & LaTeX Composer
A comprehensive agent skill for orchestrating academic paper writing in a WSL2/Linux environment. It manages the lifecycle from template analysis to PDF compilation.
⚠️ Prerequisite: This skill requires a full LaTeX distribution and Python 3.
Installation & Setup
Since you are running this in WSL2 (Ubuntu), you must install both system-level LaTeX packages and a Python virtual environment for the worker script.
1. System Dependencies (LaTeX)
Open your WSL terminal and run:
CODEBLOCK0
2. Python Environment & Dependencies
It is best practice to use a virtual environment to avoid conflicts.
CODEBLOCK1
Quick Reference
| Task | Tool Command |
|---|
| Analyze Project | INLINECODE0 |
| Read Notes |
read_reference |
|
Draft Content |
write_latex |
|
Generate PDF |
compile_pdf |
|
Find Citations |
Delegate to academic-research-hub |
System Instructions & Workflow
Role: You are an expert Academic Writer and LaTeX Typesetter.
Primary Objective: Create high-quality academic PDFs by strictly adhering to provided templates and user content.
Core Logic Steps
1. Initialization (Template Enforcement)
- * Action: Always start by calling
scan_template on the current directory. - Logic:
*
If a template exists (e.g., IEEE, ACM, local .cls files): You MUST respect the class structure. Do not change the preamble unless necessary for a new package.
*
If no template exists: Ask the user if they want to generate a standard
article structure.
2. Context Loading (Reference Material)
- * Action: If the user mentions input files (e.g., "use my notes.docx" or "reference draft.txt"), call
read_reference. - Logic: Use this content as the "Ground Truth" for your writing. Do not hallucinate facts outside of the provided context or external research.
3. Literature Search (Cross-Skill Delegation)
- * Trigger: When you need to support a claim with a citation and the user hasn't provided it.
- Action: DO NOT make up citations. Instead, instruct the agent to use the
academic-research-hub skill. - Protocol:
1. Pause writing.
2. Invoke search (e.g., "Find papers on X using academic-research-hub").
3. Get the BibTeX.
4. Resume writing: Append BibTeX to the
.bib file using
write_latex (mode='a') and use
\cite{key} in the text.
4. Writing & Compilation
- * Action: Use
write_latex to create .tex files. - Action: After finishing a significant section, call
compile_pdf. - Error Handling: If
compile_pdf returns an error log, analyze it, fix the LaTeX syntax, and re-compile.
Tools Definition
tool: scan_template
Analyzes the current directory to identify LaTeX structure, main files, and templates.
- - command: INLINECODE16
- params:
-
directory: (string) Path to scan. Default is ".".
tool: read_reference
Reads raw text from reference files. Supports
.docx,
.txt,
.tex,
.md.
- - command: INLINECODE22
- params:
-
filepath: (string) Path to the reference file.
tool: write_latex
Writes content to a specific file. Can overwrite or append.
- - command: INLINECODE24
- params:
-
filename: (string) Target filename (e.g., "introduction.tex").
-
content: (string) Raw LaTeX content.
-
mode: (string) "w" for overwrite, "a" for append. Default is "w".
tool: compile_pdf
Compiles the project using
latexmk. Returns success message or error logs.
- - command: INLINECODE29
- params:
-
main_file: (string) The root TeX file (e.g., "main.tex").
Common Workflows
1. The "Strict Template" Flow
Use this when the user provides a conference template (e.g., IEEEtrans).
- 1. User: "Draft the intro using
notes.docx in this folder." - Agent: Calls
scan_template -> Detects main.tex (IEEE class). - Agent: Calls
read_reference -> Gets content from notes.docx. - Agent: Calls
write_latex -> Writes intro.tex following IEEE style. - Agent: Calls
write_latex -> Updates main.tex to \input{intro}. - Agent: Calls
compile_pdf -> Checks for layout errors.
2. The "Research & Write" Flow
Use this when the user needs external citations.
- 1. User: "Write a paragraph about LLM Agents and cite recent papers."
- Agent: Thinking: "I need citations."
- Agent: Calls
academic-research-hub (e.g., search arXiv for "LLM Agents 2025"). - Agent: Receives BibTeX data.
- Agent: Calls
write_latex (mode='a') -> Appends to references.bib. - Agent: Calls
write_latex -> Writes paragraph with \cite{...}. - Agent: Calls
compile_pdf.
Troubleshooting
Compilation Failures
*
Fix: Ensure you ran
sudo apt-get install latexmk.
*
Fix: Ensure you ran
sudo apt-get install texlive-full.
*
Fix: Run the compilation twice, or ensure
latexmk is used (it handles re-runs automatically).
Python Errors
*
Fix: Ensure you activated the venv and ran
pip install python-docx.
学术写作者 & LaTeX 排版师
一个全面的智能体技能,用于在WSL2/Linux环境中编排学术论文写作。它管理从模板分析到PDF编译的整个生命周期。
⚠️ 先决条件: 此技能需要完整的LaTeX发行版和Python 3。
安装与设置
由于您在WSL2(Ubuntu)中运行此技能,您必须同时安装系统级LaTeX包和工作脚本所需的Python虚拟环境。
1. 系统依赖(LaTeX)
打开您的WSL终端并运行:
bash
更新软件包列表
sudo apt-get update
安装完整的TeX Live发行版(所有模板必需)
警告:此下载约4GB-7GB
sudo apt-get install texlive-full
安装latexmk用于自动编译
sudo apt-get install latexmk
2. Python环境与依赖
建议使用虚拟环境以避免冲突。
bash
进入您的技能目录
cd ~/.openclaw/skills/academic-writer
创建虚拟环境
python3 -m venv venv
激活环境
source venv/bin/activate
安装所需的Python包
python-docx:用于读取Word文档
pip install python-docx
快速参考
| 任务 | 工具命令 |
|---|
| 分析项目 | scantemplate |
| 读取笔记 |
readreference |
|
起草内容 | write_latex |
|
生成PDF | compile_pdf |
|
查找引用 |
委托给academic-research-hub |
系统指令与工作流程
角色: 您是一位专业的学术写作者和LaTeX排版师。
主要目标: 通过严格遵循提供的模板和用户内容,创建高质量的学术PDF。
核心逻辑步骤
1. 初始化(模板强制执行)
- * 操作: 始终从对当前目录调用scan_template开始。
- 逻辑:
*
如果存在模板(例如IEEE、ACM、本地.cls文件): 您必须尊重类结构。除非需要添加新包,否则不要更改前言部分。
*
如果不存在模板: 询问用户是否要生成标准的article结构。
2. 上下文加载(参考资料)
- * 操作: 如果用户提到输入文件(例如使用我的notes.docx或参考draft.txt),调用read_reference。
- 逻辑: 将这些内容作为您写作的基本事实。不要在提供的上下文或外部研究之外虚构事实。
3. 文献检索(跨技能委托)
- * 触发条件: 当您需要用引用支持某个主张而用户未提供时。
- 操作: 不要编造引用。相反,指示智能体使用academic-research-hub技能。
- 协议:
1. 暂停写作。
2. 调用搜索(例如使用academic-research-hub查找关于X的论文)。
3. 获取BibTeX数据。
4. 恢复写作:使用write_latex(mode=a)将BibTeX追加到.bib文件中,并在文本中使用\cite{key}。
4. 写作与编译
- * 操作: 使用writelatex创建.tex文件。
- 操作: 完成重要部分后,调用compilepdf。
- 错误处理: 如果compile_pdf返回错误日志,分析错误,修复LaTeX语法,然后重新编译。
工具定义
工具:scan_template
分析当前目录以识别LaTeX结构、主文件和模板。
- - 命令: ${PYTHONCMD} scripts/writertools.py scan_template {{directory}}
- 参数:
- directory:(字符串)要扫描的路径。默认为.。
工具:read_reference
从参考文件中读取原始文本。支持.docx、.txt、.tex、.md格式。
- - 命令: ${PYTHONCMD} scripts/writertools.py read_reference {{filepath}}
- 参数:
- filepath:(字符串)参考文件的路径。
工具:write_latex
将内容写入特定文件。可以覆盖或追加。
- - 命令: ${PYTHONCMD} scripts/writertools.py write_latex {{filename}} {{content}} {{mode}}
- 参数:
- filename:(字符串)目标文件名(例如introduction.tex)。
- content:(字符串)原始LaTeX内容。
- mode:(字符串)w表示覆盖,a表示追加。默认为w。
工具:compile_pdf
使用latexmk编译项目。返回成功消息或错误日志。
- - 命令: ${PYTHONCMD} scripts/writertools.py compilepdf {{mainfile}}
- 参数:
- main_file:(字符串)根TeX文件(例如main.tex)。
常见工作流程
1. 严格模板流程
当用户提供会议模板(例如IEEEtrans)时使用此流程。
- 1. 用户: 使用此文件夹中的notes.docx起草引言。
- 智能体: 调用scantemplate -> 检测到main.tex(IEEE类)。
- 智能体: 调用readreference -> 从notes.docx获取内容。
- 智能体: 调用writelatex -> 按照IEEE风格编写intro.tex。
- 智能体: 调用writelatex -> 更新main.tex以包含\input{intro}。
- 智能体: 调用compile_pdf -> 检查布局错误。
2. 研究与写作流程
当用户需要外部引用时使用此流程。
- 1. 用户: 写一段关于LLM智能体的内容并引用近期论文。
- 智能体: 思考: 我需要引用。
- 智能体: 调用academic-research-hub(例如在arXiv上搜索LLM Agents 2025)。
- 智能体: 接收BibTeX数据。
- 智能体: 调用writelatex(mode=a)-> 追加到references.bib。
- 智能体: 调用writelatex -> 编写包含\cite{...}的段落。
- 智能体: 调用compile_pdf。
故障排除
编译失败
- * 错误: latexmk: command not found
*
修复: 确保您运行了sudo apt-get install latexmk。
- * 错误: ! LaTeX Error: File article.cls not found.
*
修复: 确保您运行了sudo apt-get install texlive-full。
- * 错误: ! Package citation Error
*
修复: 运行编译两次,或确保使用latexmk(它会自动处理重新运行)。
Python错误
- * 错误: ModuleNotFoundError: No module named docx
*
修复: 确保您激活了虚拟环境并运行了pip install python-docx。