gregm711

Compile LaTex & Typst into PDF with TypeTex

开发编程v1.5.0
作者:gregm711更新于 2026-05-11共 2 个版本 · 最新版本发布于 2026-02-01typetex@clawhub_gregm711/typetex
脚本工具#Source Code#PDF

据 AlphaMoat 统计,截至 2026-09,Compile LaTex & Typst into PDF with TypeTex 累计下载 3,471 次、获 4 个星标,在全部 5,078 个 AI 技能中排名第 3,186 位,在「开发编程」分类(577 个)中排名第 410 位。

累计安装
199
累计下载
3,471
星标
4
全站排名
#3,186
全站前 63% · 「开发编程」前 72%
平台累计安装累计下载星标评论
ClawHub ↗1103,3924-
SkillHub ↗1993,4714—

各平台的计数口径不同,统计时间不一致。

这个技能是做什么的

主文介绍提交源代码并接收 PDF 的编译服务,也列出 Typst 与 LaTeX 的请求端点和响应格式。

资料发布于 2026-10-27

可以用来做什么

  • 把 Typst 或 LaTeX 文档编译成 PDF

什么时候用

  • 需要将源文档提交给编译 API 并获取结果时

示例提示词

以下是根据技能文档生成的示例,不代表实际运行结果。

编译这个 LaTeX 项目,并返回生成的 PDF

月度数据趋势

累计下载3,471
2,3252,9413,5562026-03 · 累计下载 2,4102026-05 · 累计下载 2,8182026-06 · 累计下载 2,9552026-07 · 累计下载 3,1802026-08 · 累计下载 3,2922026-09 · 累计下载 3,47126-0326-09
星标4
3442026-03 · 星标 32026-05 · 星标 42026-06 · 星标 42026-07 · 星标 42026-08 · 星标 42026-09 · 星标 426-0326-09

2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。

月份累计下载环比星标
2026-093,471—4
2026-083,292+3.5%4
2026-073,180+7.6%4
2026-062,955+4.9%4
2026-052,818—4
2026-032,410—3

SKILL.md 原文

以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。

6.8 KB · ClawHub v1.5.0
---
name: Typst & LaTeX Compiler
description: Compile Typst and LaTeX documents to PDF via API. Send source code, get back a PDF.
metadata:
  clawdbot:
    config:
      requiredEnv: []
      stateDirs: []
---
展开全部(共 327 行)
# Typst & LaTeX Compiler

Compile Typst (.typ) and LaTeX (.tex) documents to PDF using the TypeTex compilation API.

## API Endpoint

**Base URL:** `https://studio-intrinsic--typetex-compile-app.modal.run`

## Endpoints

### Compile Typst

```
POST /public/compile/typst
Content-Type: application/json
```

**Request Body:**
```json
{
  "content": "#set page(paper: \"a4\")\n\n= Hello World\n\nThis is a Typst document.",
  "main_filename": "main.typ",
  "auxiliary_files": {}
}
```

**Response (Success):**
```json
{
  "success": true,
  "pdf_base64": "JVBERi0xLjQK..."
}
```

**Response (Failure):**
```json
{
  "success": false,
  "error": "error: file not found: missing.typ"
}
```

### Compile LaTeX

```
POST /public/compile/latex
Content-Type: application/json
```

**Request Body:**
```json
{
  "content": "\\documentclass{article}\n\\begin{document}\nHello World\n\\end{document}",
  "main_filename": "main.tex",
  "auxiliary_files": {}
}
```

**Response (Success):**
```json
{
  "success": true,
  "pdf_base64": "JVBERi0xLjQK..."
}
```

**Response (Failure):**
```json
{
  "success": false,
  "error": "! LaTeX Error: Missing \\begin{document}.",
  "log_output": "This is pdfTeX..."
}
```

### Health Check

```
GET /public/compile/health
```

Returns `{"status": "ok", "service": "public-compile"}` if the service is running.

## Usage Examples

### Simple Typst Document

```python
import requests
import base64

response = requests.post(
    "https://studio-intrinsic--typetex-compile-app.modal.run/public/compile/typst",
    json={
        "content": """
#set page(paper: "a4", margin: 2cm)
#set text(font: "New Computer Modern", size: 11pt)

= My Document

This is a paragraph with *bold* and _italic_ text.

== Section 1

- Item 1
- Item 2
- Item 3
""",
        "main_filename": "main.typ"
    }
)

result = response.json()
if result["success"]:
    pdf_bytes = base64.b64decode(result["pdf_base64"])
    with open("output.pdf", "wb") as f:
        f.write(pdf_bytes)
    print("PDF saved to output.pdf")
else:
    print(f"Compilation failed: {result['error']}")
```

### Simple LaTeX Document

```python
import requests
import base64

response = requests.post(
    "https://studio-intrinsic--typetex-compile-app.modal.run/public/compile/latex",
    json={
        "content": r"""
\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}

\title{My Document}
\author{Author Name}

\begin{document}
\maketitle

\section{Introduction}

This is a LaTeX document with math: $E = mc^2$

\end{document}
""",
        "main_filename": "main.tex"
    }
)

result = response.json()
if result["success"]:
    pdf_bytes = base64.b64decode(result["pdf_base64"])
    with open("output.pdf", "wb") as f:
        f.write(pdf_bytes)
else:
    print(f"Compilation failed: {result['error']}")
    if result.get("log_output"):
        print(f"Log: {result['log_output']}")
```

### Multi-File Project (Typst)

```python
import requests
import base64

response = requests.post(
    "https://studio-intrinsic--typetex-compile-app.modal.run/public/compile/typst",
    json={
        "content": """
#import "template.typ": *

#show: project.with(title: "My Report")

= Introduction

#include "chapter1.typ"
""",
        "main_filename": "main.typ",
        "auxiliary_files": {
            "template.typ": """
#let project(title: none, body) = {
  set page(paper: "a4")
  set text(font: "New Computer Modern")

  align(center)[
    #text(size: 24pt, weight: "bold")[#title]
  ]

  body
}
""",
            "chapter1.typ": """
== Chapter 1

This is the first chapter.
"""
        }
    }
)

result = response.json()
if result["success"]:
    pdf_bytes = base64.b64decode(result["pdf_base64"])
    with open("report.pdf", "wb") as f:
        f.write(pdf_bytes)
```

### Including Images

For binary files like images, base64-encode them:

```python
import requests
import base64

# Read and encode an image
with open("figure.png", "rb") as f:
    image_base64 = base64.b64encode(f.read()).decode("utf-8")

response = requests.post(
    "https://studio-intrinsic--typetex-compile-app.modal.run/public/compile/typst",
    json={
        "content": """
#set page(paper: "a4")

= Document with Image

#figure(
  image("figure.png", width: 80%),
  caption: [A sample figure]
)
""",
        "main_filename": "main.typ",
        "auxiliary_files": {
            "figure.png": image_base64
        }
    }
)
```

### Using curl

```bash
# Typst compilation
curl -X POST https://studio-intrinsic--typetex-compile-app.modal.run/public/compile/typst \
  -H "Content-Type: application/json" \
  -d '{
    "content": "#set page(paper: \"a4\")\n\n= Hello World\n\nThis is Typst.",
    "main_filename": "main.typ"
  }' | jq -r '.pdf_base64' | base64 -d > output.pdf

# LaTeX compilation
curl -X POST https://studio-intrinsic--typetex-compile-app.modal.run/public/compile/latex \
  -H "Content-Type: application/json" \
  -d '{
    "content": "\\documentclass{article}\n\\begin{document}\nHello World\n\\end{document}",
    "main_filename": "main.tex"
  }' | jq -r '.pdf_base64' | base64 -d > output.pdf
```

## Supported Features

### Typst
- Full Typst language support
- Multi-file projects with imports
- Images (PNG, JPG, SVG)
- Custom fonts (New Computer Modern, etc.)
- Math equations
- Tables and figures
- Bibliography (using Hayagriva format)

### LaTeX
- Full TeX Live distribution via Tectonic
- Multi-file projects (\input, \include)
- BibTeX/BibLaTeX bibliography
- Custom style files (.sty, .cls)
- All standard packages (amsmath, graphicx, etc.)
- TikZ/PGFPlots graphics
- Images (PNG, JPG, PDF, EPS)

## Error Handling

When compilation fails, the response includes:
- `success: false`
- `error`: Human-readable error message
- `log_output` (LaTeX only): Full compilation log for debugging

Common errors:
- **Syntax errors**: Check your source code for typos
- **Missing files**: Ensure all imported/included files are in `auxiliary_files`
- **Package not found**: Most common packages are available; contact support for additions
- **Timeout**: Complex documents may timeout after 60 seconds

## Rate Limits

- No authentication required
- Please be respectful of shared resources
- For high-volume usage, contact support

## Tips for Agents

1. **Always check `success`** before accessing `pdf_base64`
2. **Parse errors** to provide helpful feedback to users
3. **Use minimal documents** when testing - complex documents take longer
4. **Cache results** if compiling the same content multiple times
5. **Include all dependencies** in `auxiliary_files` for multi-file projects

## Related Resources

- [Typst Documentation](https://typst.app/docs/)
- [LaTeX Wikibook](https://en.wikibooks.org/wiki/LaTeX)
- [TypeTex](https://typetex.app) - Full document editor with AI assistance

「开发编程」分类下的热门技能

数据月份:2026-09 · 下载/星标/安装数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。