Generate professional printable exam/test/quiz PDFs from any subject and topic. Use when asked to create a test, exam, quiz, practice problems, mock exam, worksheet, or problem set for any academic subject (math, science, history, etc.). Triggers: "make a test", "create an exam", "generate a quiz", "practice problems", "mock exam", "problem set", "worksheet", "出题", "模拟考试", "练习题". Supports multi-section difficulty tiers, KaTeX math rendering, answer keys, and professional card-based layout with color-coded sections.
Generate professional, printable exam PDFs using HTML + KaTeX + Chrome headless PDF.
--print-to-pdf.Use assets/exam-template.html as the reference implementation. Key design patterns:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
onload="renderMathInElement(document.body, {delimiters:[
{left:'$$',right:'$$',display:true},
{left:'$',right:'$',display:false}
]});"></script>
@page { size: letter; margin: 0.55in 0.6in 0.5in 0.6in; }<h1>) + subtitle with topic bulletsEach difficulty tier gets a distinct color for visual separation:
#3b82f6 — card backgrounds alternate #f0f5ff / #fff#f59e0b — card backgrounds alternate #fffbeb / #fff#ef4444 — card backgrounds alternate #fef2f2 / #fffSection headers are colored banner bars. Score table rows match section colors.
Every question is a .q-card with:
.q-top): Bold question number + question text + point value right-aligned.q-body): Sub-questions if any.work-area): White box with border, labeled "Work / Answer"<div class="q-card">
<div class="q-top">
<span class="q-num">5.</span>
<span class="q-text">Solve by completing the square: $x^2+8x+7=0$</span>
<span class="q-pts">[3]</span>
</div>
<div class="work-area wa-md"></div>
</div>
Work area sizes: wa-sm (50px), wa-md (75px), wa-lg (105px), wa-xl (140px).
Simple sub-questions (short answers like simplify $i^{15}$) → use 3-column grid:
<div class="grid-3">
<div class="grid-cell"><span class="gc-label">(a)</span> <span class="gc-q">$i^{15}$</span></div>
<div class="grid-cell"><span class="gc-label">(b)</span> <span class="gc-q">$i^{42}$</span></div>
<div class="grid-cell"><span class="gc-label">(c)</span> <span class="gc-q">$i^{101}$</span></div>
</div>
Complex sub-questions (multi-step work needed) → stacked with individual work areas:
<div class="q-body"><div class="sub-q">(a) $x^2+6x+9=0$</div></div>
<div class="sub-work wa-sm"></div>
<div class="q-body"><div class="sub-q">(b) $2x^2-5x+1=0$</div></div>
<div class="sub-work wa-md"></div>
page-break-before: always.ak-sec-a, .ak-sec-b, .ak-sec-c).ak-item)<div class="page-break"></div> between major sectionspage-break-inside: avoid to prevent splitting"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
--headless --print-to-pdf="/path/output.pdf" \
--print-to-pdf-no-header --no-sandbox --disable-gpu \
"file:///path/to/exam.html"
Work area sizing — match to expected solution length:
wa-smwa-mdwa-lgwa-xlDifficulty distribution — evenly spread across tiers. Target weak areas with "trap" questions that test common mistakes.
Point allocation — scale with difficulty:
Time budget — roughly 2-3 min per easy, 4-5 min per medium, 6-8 min per hard question.
Math formatting — use KaTeX $...$ for inline, $$...$$ for display. Use \dfrac for fractions, \sqrt{} for radicals, ^{} for exponents.
Non-math subjects — the card system works for any subject. Replace math notation with regular text. Use the grid layout for matching, multiple choice, or short-answer sets.
font-family in body@page margins and size for different paper sizes (A4: size: A4)