Generate structured LaTeX exam cheat sheets from course materials. Extracts key concepts, definitions, formulas from PDFs, Jupyter notebooks, and markdown files. Compiles to PDF with error checking.

0 stars
1 forks
TeX
33 views

SKILL.md


name: Create LaTeX Notes description: Generate structured LaTeX exam cheat sheets from course materials. Extracts key concepts, definitions, formulas from PDFs, Jupyter notebooks, and markdown files. Compiles to PDF with error checking.

Create LaTeX Notes

Purpose

This skill generates concise, exam-ready LaTeX cheat sheets from course materials in the src directory. It creates well-structured reference documents optimized for quick review during exams.

IMPORTANT: All generated notes MUST be in English, regardless of the language used during interaction with the user. The user studies in English and needs exam notes in English.

Instructions

1. Content Analysis

  • Locate source materials: Identify all course content in the specified directory under src/
  • Process multiple formats:
    • .md files: Extract headings, definitions, formulas, code examples
    • .ipynb files: Extract markdown cells, code outputs, formulas, key visualizations
    • .pdf files: Extract text content, focus on definitions, theorems, formulas
  • Prioritize content:
    • Core concepts and definitions (always include)
    • Mathematical formulas and equations (always include)
    • Key algorithms and their complexity (always include)
    • Important code snippets (include only the most critical examples)
    • Diagrams descriptions (brief text descriptions only, no images unless space permits)

2. Structure Guidelines

Use the template from templates/template.tex as the base structure:

  • 3-column layout for maximum information density
  • Grouped by topic: Organize content into logical sections with topic-focused headers
    • ✓ Good: "Linear Regression", "K-Means Clustering", "Decision Trees"
    • ✗ Bad: "Module 2: Linear Regression", "Week 4: K-Means Clustering"
    • Only include module/week numbers if user specifically requests them
  • Tabular format: Use tables with \textbf{Concept}: followed by brief explanation
  • Consistent formatting:
    • Bold for key terms
    • Math mode for formulas: $...$ for inline, $$...$$ for display
    • Code snippets: Use \texttt{...} for inline code or \begin{verbatim}...\end{verbatim} for blocks

Preventing Orphan Headers (title on one page, table on another):

Method 1: Use \topic command (Recommended for simple sections):

\topic{Topic Title}{
    \concept{Item 1}: Description.\\
    \concept{Item 2}: Description.\\
    \concept{Item 3}: Description.\\
}

The \topic command keeps the title and table together as one unbreakable block.

IMPORTANT: Always end content with \\ before closing brace to ensure bottom table border renders correctly.

Method 2: Use gather* environment (For complex sections):

\needspace{4\baselineskip}
\begin{samepage}
\begin{gather*}
    \textbf{Topic Title}\\[1pt]
    \begin{tabular}{|p{6cm}|}
        \hline
        \concept{Item 1}: Description.\\
        \concept{Item 2}: Description.\\
        \hline
    \end{tabular}
\end{gather*}
\end{samepage}
\vspace{2pt}

Use this when you need:

  • Multiple tables under one heading
  • Special formatting or custom spacing
  • Complex mathematical content with tables

Key improvements:

  • \\[1pt] instead of \\[-2pt] - better spacing between title and table
  • \needspace{4\baselineskip} - ensures minimum 4 lines available before starting
  • samepage environment - keeps content together on same page

3. Content Extraction Rules

  • Language: ALL notes MUST be in English, regardless of the language used in communication
  • Brevity first: Keep explanations to 1-2 lines maximum
  • Formulas: Include all mathematical formulas exactly as written
  • Code examples: Include only essential snippets (prefer pseudocode over full implementations)
  • Definitions: Format as "Term: Brief definition"
  • Avoid redundancy: Don't repeat information across sections
  • No prose: Use bullet points, tables, and structured formats only

4. File Organization

  • Output location: Save the generated .tex file in the same course directory (e.g., src/CM3010 Databases/.../cheat-sheet.tex)
  • Naming convention: Use descriptive names like {course-code}-cheat-sheet.tex or {topic}-notes.tex
  • Preserve template: Don't modify the original template file

5. Compilation Process

After generating the .tex file, compile it to PDF using the provided compilation script:

Compilation command:

bash .claude/skills/create-latex-notes/scripts/compile_latex.sh {tex_file_path}

The script automatically:

  • Detects available LaTeX compiler (xelatex, pdflatex, or lualatex in order of preference)
  • Creates out/ directory for auxiliary files
  • Runs compilation twice for proper references
  • Copies final PDF to source directory
  • Provides clear error messages if compilation fails

Alternative (manual compilation): If you need to customize the compilation process, you can modify the script at: .claude/skills/create-latex-notes/scripts/compile_latex.sh

Or compile manually:

# macOS (typical path)
/Library/TeX/texbin/xelatex -interaction=nonstopmode -output-directory=out {tex_file_path}

# Linux/other systems
xelatex -interaction=nonstopmode -output-directory=out {tex_file_path}
# or: pdflatex -interaction=nonstopmode -output-directory=out {tex_file_path}

Compilation verification:

  1. Check the exit code of the compilation command
  2. Verify the PDF file was created in the out directory
  3. If compilation fails:
    • Parse the .log file for errors
    • Report the specific line number and error message
    • Suggest corrections (common issues: missing packages, special characters, unescaped symbols)
    • Offer to fix the .tex file and recompile
  4. If successful, report the output PDF location

Error handling:

  • No compiler found: Script provides installation instructions
  • Missing packages: Suggest installation commands
  • Unicode/encoding issues: Check for special characters that need escaping
  • Overfull boxes: These are warnings, not errors - compilation still succeeds
  • Math mode errors: Check for unmatched $ symbols

6. Quality Checklist

Before finalizing, ensure:

  • All major topics from the course are covered
  • Formulas are correctly formatted in math mode
  • Content fits within page margins (no overflow)
  • Tables are properly closed (all \begin{} have matching \end{})
  • No duplicate content across sections
  • Code examples are properly escaped
  • File compiles without errors
  • PDF is readable at small font size

7. Content Prioritization

Focus on the most important exam-relevant content:

  1. Core definitions and formulas (essential)
  2. Key algorithms with complexity
  3. Critical code patterns
  4. Important examples (only most illustrative)

Pages will distribute automatically based on content volume. No need to calculate character counts.

8. Interaction Flow

  1. Identify course: Ask user which course to process if not specified
  2. Scan directory: List all source files found
  3. Extract content: Process all relevant files, prioritizing by importance
  4. Generate LaTeX: Create structured cheat sheet
  5. Save file: Write .tex file to appropriate location
  6. Compile: Run XeLaTeX compilation
  7. Verify: Check compilation success
  8. Report: Provide file locations and any warnings/errors

Template Structure

The template uses:

  • \documentclass[10pt,a4paper]{article} for compact layout
  • geometry package with 0.5cm margins
  • multicol package for 3-column layout
  • amsmath, amssymb for mathematical notation
  • \scriptsize font for maximum content density

Best Practices

  • Test compilation early: Generate a minimal version first, then add content
  • Group related topics: Keep Week 1 content together, algorithms together, etc.
  • Use consistent terminology: Match the course's terminology exactly
  • Prioritize exam-relevant content: Focus on what's testable
  • Include examples sparingly: Only the most illustrative examples
  • Cross-reference when possible: "See Week 3 for details" to save space
  • Avoid bullet points: Use \concept{} formatting instead for better structure and readability

Common LaTeX Pitfalls

  • Special characters: Escape #, $, %, &, _, {, } with backslash
  • Math mode: Always use $...$ for math symbols
  • Line breaks in tables: Use \\ not just line breaks
  • Column width: Tables with m{6cm} are already sized for 3-column layout
  • Page breaks: Use \newpage to start fresh pages when sections are complete

README

Create LaTeX Notes Skill

Generate structured, exam-ready LaTeX cheat sheets from course materials.

Quick Start

Invoke the skill:

@create-latex-notes

Then provide a course:

Create cheat sheet for CM3065 Intelligent Signal Processing

Requirements

  • XeLaTeX, pdfLaTeX, or LuaLaTeX compiler installed on your system
    • macOS: Install MacTeX (includes all compilers)
    • Linux: sudo apt-get install texlive-xetex or texlive-full
    • Windows: Install MiKTeX or TeX Live

The provided compilation script (scripts/compile_latex.sh) automatically detects which compiler is available and uses it. You can customize the script if needed for your specific system setup.

Features

  • Multi-format support: Processes .md, .ipynb, and .pdf files
  • Dense layout: 3-column A4 format optimized for maximum information
  • Auto-compilation: Generates both .tex and .pdf files with error checking
  • English output: All notes generated in English regardless of interaction language
  • Orphan header prevention: Custom \topic command keeps titles with content
  • Optimized spacing: Minimal gaps between sections for maximum density

What Gets Included

Priority (highest to lowest):

  1. Core definitions and concepts
  2. Mathematical formulas
  3. Algorithms with complexity analysis
  4. Essential code snippets
  5. Selected examples

Content is organized by topics (not module/week numbers) for better reference during exams.

File Structure

.claude/skills/create-latex-notes/
├── SKILL.md                                          # Main skill instructions
├── examples.md                                       # Usage examples
├── README.md                                         # This file
├── scripts/
│   └── compile_latex.sh                              # Universal LaTeX compilation script
├── templates/
│   └── template.tex                                  # LaTeX template (compact 3-column)
└── examples/
    ├── machine-learning-cheat-sheet.tex              # Machine Learning with Python
    ├── machine-learning-cheat-sheet.pdf              # (compiled PDF)
    ├── cm2015-programming-with-data-cheat-sheet.tex  # CM2015 Programming with Data
    ├── cm2025-computer-security-cheat-sheet.tex      # CM2025 Computer Security
    ├── cm2045-professional-practice-cheat-sheet.tex  # CM2045 Professional Practice
    ├── fcs-foundations-of-cs-cheat-sheet.tex         # Foundations of Computer Science
    ├── software-design-cheat-sheet.tex               # Software Design
    ├── databases-networks-web-cheat-sheet.tex        # Databases Networks and the Web
    └── algorithms-data-structures-cheat-sheet.tex    # Algorithms and Data Structures

Template Features

This template is optimized for exam cheat sheets:

Layout

  • ✅ 3-column layout for maximum density
  • ✅ 0.5cm margins on all sides
  • ✅ No page numbers (\pagestyle{empty})
  • ✅ No column separators (cleaner look)
  • \scriptsize font for compact text

Spacing

  • ✅ Zero display math spacing (\abovedisplayskip{0pt})
  • ✅ Minimal vertical spacing between topics
  • \raggedright for better narrow column text flow

Custom Commands

  • \topic{Title}{content} - Prevents orphan headers
  • \concept{Term} - Bold formatting for key terms
  • \formula{math} - Colored formulas

Orphan Prevention

The \topic command uses:

  • \needspace{4\baselineskip} - Ensures minimum space
  • samepage environment - Keeps title with table
  • gather* environment - Groups content
  • Negative vspace - Eliminates gaps

Formatting Best Practices

✅ Do This

\topic{Linear Regression}{%
    \concept{Simple}: $y = \beta_0 + \beta_1 x$\\
    \concept{Multiple}: $y = X\beta$\\
    \concept{MSE}: $\frac{1}{n}\sum(y-\hat{y})^2$%
}

❌ Don't Do This

% Don't use module numbers in headers
\textbf{Module 2: Linear Regression}

% Don't use bullet points
\textbullet\ Item one
\textbullet\ Item two

% Don't forget \\ at the end
\concept{Last item}: Description.

Tips

  • Start small: Test with 1-2 topics first, then expand
  • Focus on testable content: Prioritize what appears in exams
  • Keep it brief: 1-2 line explanations maximum
  • Use formulas liberally: They convey info efficiently
  • Avoid bullet points: Use \concept{} formatting instead
  • Pages auto-distribute: No need to calculate space manually

Customizing Compilation

If you need to customize the LaTeX compilation for your system:

  1. Edit the compilation script: Open scripts/compile_latex.sh
  2. Modify compiler settings: Change compiler flags or order of preference
  3. Add system-specific paths: Update paths to LaTeX binaries if needed

Example modifications:

# Change compiler preference order
if command -v pdflatex &> /dev/null; then
    COMPILER="pdflatex"
# Add custom path for macOS
elif [ -f "/Library/TeX/texbin/xelatex" ]; then
    COMPILER="/Library/TeX/texbin/xelatex"

The skill will automatically use your modified script.

Common Issues

Compilation errors?

  • Check for unescaped special characters: #, $, %, &, _, {, }
  • Verify math mode: wrap formulas in $...$
  • Ensure all \begin{...} have matching \end{...}
  • Make sure content ends with \\ before closing }

No compiler found?

  • Install a LaTeX distribution (see Requirements section)
  • Or modify scripts/compile_latex.sh to add your compiler path

Bottom table border missing?

  • Always end content with \\ in \topic{}{content\\}

Orphan headers (title on one page, table on another)?

  • Use \topic{}{} command instead of manual formatting
  • It automatically prevents orphans

Text overflow?

  • Shorten explanations
  • Use abbreviations consistently
  • Consider splitting complex topics into multiple smaller topics

Examples

See examples.md for detailed usage scenarios and formatting guidelines.

All example cheat sheets are available in the examples/ directory:

Version History

  • v3.1 (2025-10-27): Added universal compilation script, moved all examples to examples/ directory
  • v3.0 (2025-10-27): Removed density calculator, optimized spacing, added examples directory
  • v2.0 (2025-10-27): Compact template, orphan prevention, concept-based formatting
  • v1.0 (2025): Initial version