← 返回 Skills 市场
Formula—PDF
作者
Nahida-Robin
· GitHub ↗
· v1.0.0
· MIT-0
100
总下载
1
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install formula-pdf
功能描述
将包含数学公式的内容渲染为PDF文档。使用HTML+MathJax渲染公式,通过Edge无头模式转为PDF。当用户要求整理文档、生成报告、制作笔记且内容含有公式时触发。不要用Word导出(公式会变成代码),必须用此方法。
使用说明 (SKILL.md)
Formula-PDF: 公式PDF文档生成
触发条件
当用户说 "整理成文档"、"发给我"、"弄成PDF" 且内容含有数学公式时触发。 必须优先使用此方法,不要使用Word导出。
工作流程
Step 1: 编写HTML
内容优先写中文(文件名用英文),公式用MathJax语法。
写文件的正确方式(重要!):
- 不要用
write工具直接写HTML(含大量引号和反斜杠时参数会解析失败) - 用PowerShell here-string写:
@'
\x3Chtml>
\x3Chead>
\x3Cmeta charset="UTF-8">
\x3Cscript>MathJax={tex:{inlineMath:[['$','$']],displayMath:[['$$','$$']]}};\x3C/script>
\x3Cscript src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">\x3C/script>
\x3C/head>
\x3Cbody>
\x3C!-- 内容 -->
\x3C/body>
\x3C/html>
'@ | Out-File -FilePath filename.html -Encoding UTF8
公式写法:
- 行内公式
$E = mc^2$ - 块级公式
$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$ - 表格中可以放公式
- 支持所有标准LaTeX数学命令
- 注意写斜杠:
\frac不是frac
Step 2: 转换为PDF
使用Edge无头模式打印为PDF。不要杀Edge进程,可直接共存运行。
& 'edge' `
--headless=new `
--virtual-time-budget=30000 `
--print-to-pdf="output.pdf" `
--no-margins `
"file:///C:/path/to/input.html"
关键参数解释:
--headless=new:无界面模式--virtual-time-budget=30000:等待MathJax加载和渲染的时间(毫秒)--print-to-pdf:输出PDF路径--no-margins:无边距"file:///":必须用文件协议,路径用双引号包起来
Step 3: 验证公式已渲染
用pymupdf检查PDF文本中是否含有原始LaTeX代码:
import fitz
doc = fitz.open(pdf_path)
text = ""
for page in doc:
text += page.get_text()
# 如果含有这些关键词,说明公式没渲染
latex_patterns = [r'\frac', r'\sqrt', r'\lim', r'\sum', r'\int', r'\dfrac', r'$$']
for p in latex_patterns:
if p in text:
print("警告: 公式未渲染,含LaTeX原始代码")
print("验证完成")
Step 4: 发送文件
用message工具将PDF发送给用户:
message(action="send", filePath="PDF路径", message="公式已渲染")
参考脚本
scripts/html_to_pdf.py:一键转换脚本,支持参数assets/template.html:HTML模板,可直接用作起点
常见问题
公式显示为LaTeX代码
- 增加
--virtual-time-budget的值(如50000) - 检查MathJax CDN地址是否可达
- 验证HTML中MathJax script标签是否正确
PDF没生成
- Edge可能在进程冲突,先重试一次
- 确保文件路径用正斜杠
中文乱码
- CSS中设置
font-family: 'Microsoft YaHei', 'Segoe UI', sans-serif;
目录结构
formula-pdf/
├── SKILL.md
├── scripts/
│ └── html_to_pdf.py # 一键转换工具
├── references/ # (可选)更多使用参考
└── assets/
└── template.html # HTML模板
安全使用建议
Install only if you are comfortable with local PDF generation through Microsoft Edge and a MathJax CDN. Prefer the basic script/manual workflow, and avoid the enhanced script or any kill-edge option unless you have saved work and explicitly want Edge closed. For confidential documents, consider using a local MathJax copy instead of loading it from the CDN.
能力评估
Purpose & Capability
The core purpose is coherent: SKILL.md and README.md describe writing HTML with MathJax and using headless Edge to print a PDF. Users should still expect local file writes, local browser execution, and a remote MathJax CDN dependency.
Instruction Scope
The main SKILL.md says not to kill Edge processes, but included helper/reference material contains force-kill behavior. That creates a conflicting high-impact path for an agent choosing how to perform the conversion.
Install Mechanism
The registry requirements declare no required binaries and no OS restriction, while README.md lists Windows, Microsoft Edge, Python 3, and optional PyMuPDF. This looks like under-declared setup rather than hidden installation.
Credentials
The enhanced script can terminate all msedge.exe processes, including unrelated user browser windows, and may do so automatically after a failed conversion attempt.
Persistence & Privilege
No evidence of persistence, credential collection, account access, privilege escalation, or background operation after the PDF conversion task.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install formula-pdf - 安装完成后,直接呼叫该 Skill 的名称或使用
/formula-pdf触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of formula-pdf skill.
- Automatically renders content with mathematical formulas as PDF using HTML + MathJax and Edge in headless mode.
- Source content is written primarily in Chinese, formulas use standard LaTeX via MathJax.
- Provides detailed workflow including HTML generation, PDF conversion, and formula rendering verification.
- Addresses common issues such as formula rendering errors, PDF generation failures, and font problems.
元数据
常见问题
Formula—PDF 是什么?
将包含数学公式的内容渲染为PDF文档。使用HTML+MathJax渲染公式,通过Edge无头模式转为PDF。当用户要求整理文档、生成报告、制作笔记且内容含有公式时触发。不要用Word导出(公式会变成代码),必须用此方法。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 100 次。
如何安装 Formula—PDF?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install formula-pdf」即可一键安装,无需额外配置。
Formula—PDF 是免费的吗?
是的,Formula—PDF 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Formula—PDF 支持哪些平台?
Formula—PDF 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Formula—PDF?
由 Nahida-Robin(@nahida-robin)开发并维护,当前版本 v1.0.0。
推荐 Skills