---
name: exam-cheatsheet
description: "Generate comprehensive, dense, exam-ready cheat sheets in DOCX or LaTeX/PDF format from lecture slides, textbook chapters, course PDFs, or notes. Use when the user asks for a cheat sheet, study sheet, exam summary, revision sheet, formula sheet, one-pager, LaTeX cheat sheet, or notes consolidation for any subject (computer science, math, physics, chemistry, biology, finance, economics, law, medicine, engineering, languages, etc.)."
version: 1.0.0
author: wtw0212
compatibility: [prompthub]
---
# Exam Cheat Sheet Generator

## When to Use This Skill

Use this skill when the user wants a dense, exam-ready cheat sheet built from source materials (lecture slides, chapter PDFs, textbook scans, lecture notes). It can produce **DOCX** or **LaTeX/PDF** output. It works for **any subject** — computer science, math, physics, chemistry, biology, statistics, finance, economics, law, medicine, engineering, languages, etc.

Trigger phrases include: "cheat sheet", "study guide", "exam summary", "revision sheet", "formula sheet", "one-pager", "make notes from these slides", "summarize for exam", or attaching multiple lecture/chapter files and asking for a consolidation.

Do NOT use this skill for narrative summaries, blog posts, or full-prose study guides — those need flowing text, not the dense reference format this skill produces.

## Output Philosophy

A good cheat sheet is **dense, scannable, and exhaustive within its scope**. It is a *reference* the student glances at during/before an exam — not a textbook to read. Every design choice optimizes for **information density per square inch** while staying readable.

**Core principles:**

1. **Density over whitespace** — small fonts (about 8.2 pt body), ultra-narrow COMP2432-style margins, two-column layout.
2. **Tables over prose** — comparisons, definitions, classifications, and parameter lists become tables.
3. **Formulas first-class** — every formula gets its own bolded line with variables defined immediately after.
4. **Hierarchy via color, not size** — use a single accent color for chapter bars and sub-section headers; keep body text uniform.
5. **No fluff** — no introductions, no "in summary", no transitions. Just facts.
6. **Match the source language** — if slides are in Chinese/Japanese/etc., the cheat sheet uses that language. Never default to English.
7. **No page limit unless the user sets one** — pack in everything that could appear on the exam.

## Workflow

### Step 1: Clarify scope (only if ambiguous)

If the user gives clear inputs (attached files + chapters specified), skip clarification. Otherwise, ask 1–3 short questions covering:

- Which chapters/topics to include
- Page limit (or "no limit")
- Output format: DOCX, LaTeX source, PDF, or both `.tex` and compiled PDF
- Output language (if source is non-English and unclear)
- Any specific exam focus (calculation-heavy? definition-heavy? proof-heavy?)

### Step 2: Read ALL source material

Read every page/slide of every attached source. Do not skim — formulas and edge-case rules often hide in late slides.

- **PDFs**: Use the `read` tool. PDF reading defaults to 20 pages — paginate with `offset` and `limit` until `next_page` is null.
- **PPTX**: Use the `read` tool the same way. If reading fails (`Failed to convert PPTX to PDF`), convert first:
  ```bash
  soffice --headless --convert-to pdf /home/user/workspace/file.pptx
  ```
  Then read the resulting PDF.
- **Long source sets** (3+ files, 100+ total pages): delegate to a subagent (see Step 4) — but first save a brief outline of what to extract per chapter into a workspace file so the subagent has clear instructions.

### Step 3: Decide on structure

Mentally organize content into:

- **Chapter sections** (one per source file or major topic) — get a colored section bar
- **Sub-sections** (numbered like 1.1, 1.2 or by topic) — get a colored sub-header
- **Comparison tables** — wherever 2+ things share dimensions (e.g., TCP vs UDP, mitosis vs meiosis, monopoly vs perfect competition, common vs civil law)
- **Formula blocks** — every formula on its own bolded line
- **A consolidated "All Formulas" appendix** at the end (essential for math/physics/finance/CS exams), grouped by topic/subtopic rather than one undifferentiated list
- **A "Quick Reference" appendix** with constants, units, port numbers, common values, key dates — whatever is universally useful for the subject

### Step 4: Choose output format

Use the format requested by the user. If the user does not specify:

- Use **LaTeX/PDF** for formula-heavy, code-heavy, or very dense multi-page sheets, especially CS/math/engineering courses.
- Use **DOCX** when the user needs editable Word output, comments/redlines, or institutional Word-template compatibility.
- If the user asks for `.tex`, always produce a `.tex` source file and compile it to PDF when a LaTeX engine is available.

### Step 5A: Generate LaTeX/PDF

For LaTeX output:

- Write a standalone `.tex` file in the workspace, named `<subject>_cheatsheet.tex`.
- Compile with `xelatex -interaction=nonstopmode -halt-on-error <file>.tex` by default. Use `pdflatex` only if the content is ASCII-only and does not need system fonts; use `lualatex` if XeLaTeX is unavailable.
- Use the COMP2432 LaTeX house style by default: no title block, no running header, right-footer page number, two columns, ultra-tight spacing, small readable fonts, teal section bars, white/gray alternating tables, and `listings`/monospace blocks for code.
- Put formulas in regular content where needed, then compile **all formulas again at the end** in a section named `All Formulas` unless the user asks otherwise. The final formula appendix must be grouped by topic (for example Scheduling, Paging, Page Table Sizing, TLB/Virtual Memory, Deadlock/Banker, Synchronization) with a separate compact table under each topic.
- Omit the opening title block unless the user explicitly asks for one. Do not add a document header. Keep only a compact page number at the lower-right footer unless the user asks for no page numbers.
- Keep the PDF within the page limit; if it is far under the limit and source material is broad, add high-value exam templates, pitfalls, and formula/reference tables.

Validate LaTeX output by compiling and checking:

```bash
xelatex -interaction=nonstopmode -halt-on-error <subject>_cheatsheet.tex
pdfinfo <subject>_cheatsheet.pdf
```

Inspect the log for `LaTeX Error`, `Emergency stop`, `Fatal error`, and significant `Overfull \hbox` warnings. Fix and recompile before sharing.

### Step 5B: Generate the DOCX

For non-trivial sheets (3+ chapters or 50+ source pages), delegate to a subagent. Pass it:

- The `office/docx` skill preloaded
- All extracted content compiled into the objective (or a workspace file path with the outline)
- Strict formatting requirements (see "DOCX Formatting Spec" below)
- Output path: `/home/user/workspace/<subject>_cheatsheet.docx`
- Instructions to validate by converting to PDF and visually inspecting

For simple sheets (single chapter or short source), generate directly using the `docx` npm library — see `office/docx` skill.

### Step 6: Validate DOCX before sharing

Convert the DOCX to PDF and visually inspect:

```bash
soffice --headless --convert-to pdf /home/user/workspace/<subject>_cheatsheet.docx
```

Read at least the first, middle, and last page using the `read` tool. Check for:

- Text overflow / text cut off at column or page boundaries
- Tables wider than the column width
- Overlapping text
- Page breaks splitting a formula or table mid-row
- Wrong language rendering (missing CJK glyphs etc.)
- Insufficient contrast (e.g., light text on light background)

Fix issues and re-validate before sharing.

### Step 7: Share with the user

Return links/paths to the final requested deliverables. For LaTeX output, provide both `.tex` and `.pdf` when both were generated. Use `share_file` with a stable `name` parameter only when that tool is available in the environment.

## LaTeX Formatting Spec

Apply these defaults unless the user overrides them:

| Element | Setting |
|---|---|
| Engine | XeLaTeX preferred |
| Page size | A4 |
| Margins | `left=0.09in,right=0.09in,top=0.15in,bottom=0.09in,includefoot,footskip=9.3pt` |
| Columns | 2 via `multicols*` |
| Body font | `\fontsize{8.2}{9.15}\selectfont` |
| Font | Arial via `fontspec`, or TeX default if unavailable |
| Title | Omit by default; start immediately with first section |
| Header/footer | No header; compact lower-right page number via `fancyhdr` |
| Section bars | White bold text on teal accent bar `#20808D` |
| Subheaders | Bold teal accent text |
| Tables | `tabularx`, `scriptsize`, light header row, white/gray alternating rows |
| Code | `listings`, `\fontsize{7.2}{8.1}`, line wrapping enabled |
| Formulas | Inline where used; final consolidated `All Formulas` section at end, grouped by topic with separate compact tables |
| Bullets | `enumitem` with `nosep`, `topsep=0pt` |
| Spacing | `\parskip=0.6pt`, section/subsection/table/code spacing kept ultra-tight |

Recommended preamble:

```tex
\documentclass[a4paper,10pt]{article}
\usepackage[left=0.09in,right=0.09in,top=0.15in,bottom=0.09in,includefoot,footskip=9.3pt]{geometry}
\usepackage{multicol}
\usepackage[table]{xcolor}
\usepackage{array,tabularx,booktabs}
\usepackage{enumitem}
\usepackage[explicit]{titlesec}
\usepackage{amsmath,amssymb}
\usepackage{fontspec}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{microtype}

\setmainfont{Arial}

\definecolor{accent}{HTML}{20808D}
\definecolor{soft}{HTML}{E8F4F6}
\definecolor{stripe}{HTML}{F0F0F0}
\definecolor{line}{HTML}{9ABCC2}
\definecolor{warn}{HTML}{8B2331}

\pagestyle{fancy}
\fancyhf{}
\rfoot{\scriptsize\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength{\headheight}{0pt}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.6pt}
\setlength{\columnsep}{13pt}
\setlength{\columnseprule}{0.15pt}
\renewcommand{\arraystretch}{1.04}
\setlist[itemize]{leftmargin=*, nosep, topsep=0pt}
\setlist[enumerate]{leftmargin=*, nosep, topsep=0pt}

\titleformat{\section}{\color{white}\bfseries\large}{}{0pt}{\colorbox{accent}{\parbox{\dimexpr\linewidth-2\fboxsep}{#1}}}
\titleformat{\subsection}{\color{accent}\bfseries\normalsize}{}{0pt}{#1}
\titlespacing*{\section}{0pt}{2pt}{1pt}
\titlespacing*{\subsection}{0pt}{1.5pt}{0.3pt}

\lstset{
  basicstyle=\ttfamily\fontsize{7.2}{8.1}\selectfont,
  breaklines=true,
  columns=fullflexible,
  keepspaces=true,
  frame=single,
  rulecolor=\color{line},
  xleftmargin=1pt,
  xrightmargin=1pt,
  aboveskip=1pt,
  belowskip=1pt
}
```

Use the COMP2432 helper style:

```tex
\newcommand{\key}[1]{\textbf{\color{accent}#1}}
\newcommand{\term}[1]{\textbf{#1}}
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\minihead}[1]{\vspace{0.4pt}\textbf{\color{accent}#1}\quad}
\newcommand{\formula}[2]{\textbf{#1:} \(#2\)}
\newcommand{\tighttable}[1]{\vspace{0.4pt}{\centering\scriptsize\rowcolors{2}{white}{stripe}#1\rowcolors{2}{}{}\par}\vspace{0.4pt}}
\newcommand{\cheatpic}[2]{\vspace{0.4pt}{\centering\includegraphics[width=#1\linewidth]{#2}\par}\vspace{0.4pt}}
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
```

Document body skeleton:

```tex
\begin{document}
\fontsize{8.2}{9.15}\selectfont

\begin{multicols*}{2}

\section{First Topic}
\subsection{First Subtopic}
...

\section{All Formulas}
...

\end{multicols*}
\end{document}
```

When a table is needed, use `\tighttable{\begin{tabularx}{\linewidth}{...} ... \end{tabularx}}`. Start each table with a `\rowcolor{soft}` header row and rely on the built-in white/gray alternating body rows. Do not use the `center` environment for tables because it adds too much vertical whitespace.

## DOCX Formatting Spec

Apply these defaults unless the user overrides them:

| Element | Setting |
|---|---|
| Page size | A4 or Letter |
| Margins | 0.5" all sides (≈720 twips) |
| Columns | 2 |
| Body font | Arial 9 pt (8 pt acceptable for very dense content) |
| Title | Arial 14 pt bold |
| Subtitle | Arial 10 pt italic |
| Chapter bar | Arial 11 pt bold white text on accent color background, full column width |
| Sub-header | Arial 9 pt bold in accent color |
| Table header | Arial 8 pt bold, light-tinted background |
| Table body | Arial 8 pt |
| Formula | Arial 9 pt, bold variable names, line above + below for separation |
| Bullets | Tight (4–6 pt spacing), no extra paragraph space |
| Line spacing | 1.0 (single) throughout |

**Color palette** — pick ONE accent color appropriate for the subject; use it for chapter bars and sub-headers only. Suggested defaults:

| Subject domain | Accent color | Hex |
|---|---|---|
| CS / engineering / tech | Teal | `#20808D` |
| Math / physics | Deep blue | `#1B4F8C` |
| Biology / medicine / chemistry | Forest green | `#2E7D32` |
| Finance / economics / business | Burgundy | `#8B2331` |
| Law / humanities | Burnt orange | `#B5651D` |
| Languages | Plum | `#6A1B7C` |
| Default / unknown | Teal | `#20808D` |

Everything else is black on white. No decorative elements, illustrations, icons, or borders beyond table cells.

## Content Patterns by Subject Type

Adapt the cheat sheet structure to the subject. These are starting templates — extract whatever the source material actually emphasizes.

### Math / Physics / Engineering / Statistics

- Definitions of all variables and units up front
- Every theorem/law as a bold formula line with conditions of validity
- Worked-example skeletons (1–2 lines) for archetypal problem types
- Identity/derivative/integral tables, conversion tables
- "Common pitfalls" mini-section (sign errors, unit mismatches, edge cases)
- **Always include the consolidated formulas appendix**

### Computer Science / Networking / Databases

- Protocol/algorithm names with port numbers, complexities, key parameters
- Data structure operations table (insert/delete/search complexity)
- Pseudocode for key algorithms
- Comparison tables (TCP vs UDP, B-tree vs B+tree, ACID vs BASE, etc.)
- Constants & magic numbers (port numbers, header sizes, default timeouts)

### Chemistry / Biology / Medicine

- Reaction equations (balanced) with conditions
- Pathway/cycle diagrams reduced to text steps
- Classification tables (e.g., taxonomy, drug classes, functional groups)
- Key constants (R, NA, pKa values, normal ranges)
- Mnemonics where standard for the field

### Finance / Economics / Accounting

- All formulas with variable definitions (NPV, IRR, CAPM, Black-Scholes inputs, etc.)
- Comparison tables (e.g., debit vs credit rules, GAAP vs IFRS)
- Decision rules ("accept project if NPV > 0", "reject H0 if p < α")
- Worked-formula skeletons for common problem types

### Law / Humanities / History

- Case names → holding → significance, in tabular form
- Statute/article numbers with one-line summary
- Doctrine definitions with elements enumerated
- Timeline tables for history (date | event | significance)
- Key terminology glossary

### Languages

- Conjugation/declension tables (verbs, nouns, adjectives)
- Particle/preposition usage table with examples
- Common irregular forms list
- Sentence-pattern templates with slot fillers
- Vocabulary categorized by theme/level (only if requested — usually too long)

## Example Skeletons

### Comparison table (always prefer this over prose)

```
| Feature      | Option A             | Option B            |
|--------------|----------------------|---------------------|
| Property 1   | …                    | …                   |
| Property 2   | …                    | …                   |
| Use case     | …                    | …                   |
```

### Formula block

```
**Formula name**
F = m · a   (Newton's 2nd law)
where: F = force (N), m = mass (kg), a = acceleration (m/s²)
Conditions: inertial reference frame; non-relativistic
```

### Consolidated formula appendix

Use a grouped formula appendix at the end of the document. Do not put all formulas into one long mixed table:

```
All Formulas
Scheduling
Formula / condition | Meaning / use

Paging Address Translation
Formula / condition | Meaning / use

Deadlock and Banker
Formula / condition | Meaning / use
```

### LaTeX formula table skeleton

```tex
\section{All Formulas}
\subsection{Scheduling}
\tighttable{\begin{tabularx}{\linewidth}{L{0.35\linewidth}Y}
\rowcolor{soft}\textbf{Formula / condition} & \textbf{Meaning / use}\\
\(TAT=C-A\) & Turnaround time = completion time - arrival time.\\
\(WT=TAT-B\) & Waiting time = turnaround - CPU burst time.\\
\end{tabularx}}

\subsection{Deadlock and Banker}
\tighttable{\begin{tabularx}{\linewidth}{L{0.35\linewidth}Y}
\rowcolor{soft}\textbf{Formula / condition} & \textbf{Meaning / use}\\
\(Need=Max-Allocation\) & Banker's algorithm remaining possible claim.\\
\end{tabularx}}
```
