{"skill":{"slug":"math-worksheets","displayName":"Math Worksheets","summary":"Generate professional math practice worksheets and full answer keys as PDFs. Compiles LaTeX to PDF using tectonic (free, no account needed). Supports any mat...","description":"---\nname: math-worksheets\ndescription: Generate professional math practice worksheets and full answer keys as PDFs. Compiles LaTeX to PDF using tectonic (free, no account needed). Supports any math topic from elementary through high school (Pre-Algebra, Algebra 1/2, Geometry, Pre-Calc). Handles coordinate plane grids, geometric figures, tables, and multi-part problems. Use when a user asks for a math worksheet, practice problems, homework help sheet, or answer key for any K-12 math topic.\n---\n\n# Math Worksheet Generator\n\nGenerate a student worksheet PDF + full step-by-step answer key PDF for any K-12 math topic. Compiles LaTeX with `tectonic` (no TeX installation required — it auto-downloads packages).\n\n## Model Selection (Automatic)\n\nThis skill auto-detects the best available reasoning model and uses it for problem generation. Reasoning models (o1, o3, DeepSeek R1, Gemini DeepThink) work through math step-by-step and make significantly fewer errors than standard models.\n\nModel rankings are kept fresh via a three-layer fallback:\n1. **Hosted JSON** (fetched from GitHub, 7-day cache) — updated by maintainers as models ship\n2. **Bundled JSON** (`references/model-rankings.json`) — updated with each skill release on ClawhHub\n3. **Hardcoded defaults** in the script — last-resort, never stale enough to cause failures\n\nTo update rankings without waiting for a skill release: edit the hosted JSON at the GitHub URL in `references/model-rankings.md`. The skill picks it up within 7 days.\n\n**Step 0 — run model detection before anything else:**\n\n```bash\nSKILL_DIR=\"$(dirname \"$0\")\"\nresult=$(bash \"$SKILL_DIR/scripts/check_reasoning_model.sh\")\nstatus=$(echo \"$result\" | awk '{print $1}')   # FOUND, FALLBACK, or NONE\nmodel_alias=$(echo \"$result\" | awk '{print $2}')\nmodel_full=$(echo \"$result\" | awk '{print $3}')\n```\n\nThen branch on the status:\n\n**`FOUND_REASONING`** (o3, o1, DeepThink, DeepSeek R1) — best case, use for problem generation:\n```\nsessions_spawn(task=\"<problem generation prompt>\", model=model_alias)\n```\nNo warning needed. Sub-agent writes the .tex files + verify script, announces completion.\n\n**`FOUND_STRONG`** (Claude Opus) — excellent quality, use it without alarming the user:\n```\nsessions_spawn(task=\"<generation prompt>\", model=model_alias)\n```\nOptionally add a quiet note: *\"Using Opus — solid math accuracy and excellent LaTeX. For the hardest Algebra 2 problems, a reasoning model (DeepThink/o1) would be marginally better.\"*\n\n**`NONE`** — standard model only; proceed but surface a clear recommendation:\n```\n⚠️ No reasoning model or Opus detected. Worksheet generated with [current model].\nFor best accuracy, especially on multi-step problems, configure one of:\n  • Gemini 2.5 Pro DeepThink  — google.generativeai.com (free tier available)\n  • o1 / o3                   — platform.openai.com\n  • DeepSeek R1               — platform.deepseek.com (very affordable)\n  • Claude Opus               — console.anthropic.com\nSymPy verification will catch most errors regardless.\n```\n\n| Status | Model examples | Action |\n|---|---|---|\n| `FOUND_REASONING` | DeepThink, o1, o3, R1 | Spawn silently, no warning |\n| `FOUND_STRONG` | Claude Opus 4.x | Spawn silently, optional quiet note |\n| `NONE` | Sonnet, Flash, GPT-4o | Use current model + show recommendation |\n\n## Prerequisites\n\n```bash\nbrew install tectonic   # macOS/Linux — downloads packages on demand\n```\n\nOutput directory (create if needed): `~/Documents/Worksheets/`\n\n## Workflow\n\n### 1. Gather requirements\n\nAsk (or infer from context):\n- **Student**: name, grade, course (e.g. \"8th grade, Pre-Algebra\")\n- **Topic**: e.g. \"factoring trinomials\", \"solving two-step equations\"\n- **Problem count**: default 10 if not specified\n- **Format preference**: timed quiz, homework practice, mixed difficulty, or topic drill\n\n**Photo input shortcut**: If the user sends a photo of homework or a textbook page, use the `image` tool to extract problem types, format, and difficulty — then mirror that style exactly.\n\n### 2. Design problems\n\nDesign problems appropriate to the student's level. Increase difficulty gradually across the set. Every problem must be mathematically correct — verify your own solutions.\n\nSee `references/problem-library.md` for topic-specific problem type menus.\n\n### 3. Write LaTeX source\n\nWrite **three** `.tex` files to `/tmp/`:\n- `ws_TOPIC_DATE.tex` — student worksheet (blank work areas)\n- `ak_TOPIC_DATE.tex` — answer key (full step-by-step solutions)\n- `ss_TOPIC_DATE.tex` — skills summary / study guide (cheat sheet)\n\nThe **skills summary** is a 1–2 page reference card the student can use while working through the worksheet or when studying. It contains:\n- One section per distinct skill tested (2–5 sections typical)\n- A **formula/rule box** (blue) per skill — the key facts and formulas\n- A **mini worked example** (green) per skill — brief pattern demonstration, simpler than worksheet problems\n- An optional **watch-out box** (orange) — common mistakes worth flagging\n- Optional **key vocabulary** section at the bottom\n\nSee `references/latex-templates.md` → \"Skills Summary / Study Guide Template\" for the full shell and box macros.\n\nSee `references/latex-templates.md` for document templates, coordinate planes, tables, geometric figures, and answer key patterns.\n\n**Required packages** (include in every document):\n```latex\n\\usepackage[margin=1in, top=0.75in, bottom=0.75in]{geometry}\n\\usepackage{amsmath, amssymb}\n\\usepackage{tikz, pgfplots}\n\\usepackage{enumitem, fancyhdr, multicol, array, booktabs}\n\\pgfplotsset{compat=1.18}\n```\n\n**Work space defaults**: `\\vspace{5cm}` per problem; `8cm` for multi-step; `10cm+` for graphs.\n\n### 4. Write and run the verification file\n\nBefore compiling, write `/tmp/verify_TOPIC_DATE.json` — a structured data file describing each problem and its expected answer. The bundled `scripts/verify.py` evaluates this using SymPy. No generated code is ever executed.\n\n```bash\nbash \"$SKILL_DIR/scripts/run_verify.sh\" /tmp/verify_TOPIC_DATE.json\n```\n\n**JSON format:**\n```json\n{\n  \"topic\": \"graphing polynomials\",\n  \"problems\": [\n    {\"id\": 1, \"type\": \"solve\",  \"expr\": \"x**2 - 5*x + 6\",      \"expected\": [2, 3]},\n    {\"id\": 2, \"type\": \"factor\", \"expr\": \"x**2 - 7*x + 12\",     \"expected\": \"(x-3)*(x-4)\"},\n    {\"id\": 3, \"type\": \"eval\",   \"expr\": \"(x-1)*(x+2)\", \"at\": {\"x\": 0}, \"expected\": -2},\n    {\"id\": 4, \"type\": \"zeros\",  \"expr\": \"x*(x-3)**2\",           \"expected\": [0, 3]},\n    {\"id\": 5, \"type\": \"expand\", \"expr\": \"(x+2)**2\",             \"expected\": \"x**2 + 4*x + 4\"},\n    {\"id\": 6, \"type\": \"manual\", \"desc\": \"Graph sketch — verify visually\"}\n  ]\n}\n```\n\n**Type reference:**\n\n| Type | Verifiable? | What it checks |\n|---|---|---|\n| `solve` | ✅ | Roots of expr=0 match expected list |\n| `factor` | ✅ | Factored form matches expected |\n| `expand` | ✅ | Expanded form matches expected |\n| `eval` | ✅ | expr evaluated at given values matches expected |\n| `zeros` | ✅ | Zeros of expr match expected list |\n| `manual` | 👁 | Flagged for human review — never fails automatically |\n\nUse `manual` for: graph sketches, sign charts, word problem setups, proofs.\n\n**If verification fails (exit 1):** fix the LaTeX answer key and re-run. Do not compile until the answer key is correct.\n\n### 5. Compile\n\n```bash\nSKILL_DIR=\"$(dirname \"$0\")\"\nbash \"$SKILL_DIR/scripts/compile.sh\" /tmp/ws_TOPIC_DATE.tex ~/Documents/Worksheets/\nbash \"$SKILL_DIR/scripts/compile.sh\" /tmp/ak_TOPIC_DATE.tex ~/Documents/Worksheets/\nbash \"$SKILL_DIR/scripts/compile.sh\" /tmp/ss_TOPIC_DATE.tex ~/Documents/Worksheets/\n```\n\n### 5. Deliver\n\nSend all three PDFs via the same channel the request came from:\n- **Telegram** → `message` tool with `filePath` (copy to `~/.openclaw/media/outbound/` first)\n- **iMessage/SMS** → `imsg` skill\n- **Email** → `gog` skill (send all three as attachments)\n\nSuggested send order: skills summary first (study guide), then worksheet, then answer key.\n\n**Printing**: Do NOT print unless explicitly asked. If asked, print worksheet + skills summary (not answer key, unless requested). Use `lpr -P <printer_name>`.\n\n## Quality Checklist\n\nBefore compiling, verify each problem:\n- [ ] Mathematically correct (you checked the solution)\n- [ ] Unambiguous problem statement\n- [ ] Appropriate difficulty for the student's level\n- [ ] Sufficient work space\n- [ ] Diagrams/graphs/tables included where needed\n- [ ] Problems vary across the set (not all the same sub-type)\n\n## File Naming\n\n```\nws_algebra2_factoring_2026-02-22.pdf   ← worksheet\nak_algebra2_factoring_2026-02-22.pdf   ← answer key\nss_algebra2_factoring_2026-02-22.pdf   ← skills summary / study guide\n```\n\nPrefix with student name when known: `leo_ws_...`, `leo_ak_...`, `leo_ss_...`\n\n## Troubleshooting\n\n| Problem | Fix |\n|---|---|\n| `tectonic` not found | `brew install tectonic` |\n| Slow first compile | Downloading packages from CTAN — wait 30–60s, faster after |\n| LaTeX error on line N | Check paired `$...$`, matching `\\begin{}/\\end{}` |\n| pgfplots not rendering | Ensure `\\pgfplotsset{compat=1.18}` is in preamble |\n| PDF not created | Read full tectonic output for the specific error |\n","tags":{"latest":"2.0.0"},"stats":{"comments":0,"downloads":361,"installsAllTime":0,"installsCurrent":0,"stars":2,"versions":2},"createdAt":1771803214897,"updatedAt":1778491612653},"latestVersion":{"version":"2.0.0","createdAt":1771915684382,"changelog":"**Major update: worksheet verification now uses structured data files (JSON), improving reliability and security.**\n\n- Replaced code-based verification (\"verify.py\" with explicit Python check calls) with a JSON-based format, interpreted by the bundled script.\n- Updated documentation to require a JSON verification file describing each problem and its expected answer.\n- `scripts/verify.py` now parses the JSON verification file and evaluates answers using SymPy—no generated code is executed.\n- Removed legacy script `scripts/fetch_model_config.sh` as part of verification process cleanup.\n- README and guides updated to reflect the new workflow for problem verification.","license":null},"metadata":null,"owner":{"handle":"trondw","userId":"s175jxj1rjk3azjdda2kdgbaps884t6j","displayName":"Trond Wuellner","image":"https://avatars.githubusercontent.com/u/1905060?v=4"},"moderation":null}