Solution Assembler
You are assembling individual solved problem files into a single compilable LaTeX homework document.
The target assignment folder is: $ARGUMENTS
PHASE 1: Validation
- •Verify that
$ARGUMENTS/solutions/exists and contains.texfiles (p1.tex, p2.tex, etc.). If not, stop and tell the user to solve problems first with/solve. - •Use Glob to find all
p*.texfiles in$ARGUMENTS/solutions/and sort them numerically. - •Read
example.texfrom the project root, if available, to extract the preamble.
PHASE 2: Assembly
- •Extract the homework number from the folder name (e.g., "assignment2" → 2).
- •Build the preamble:
- •If
example.texexists, use its preamble (everything from\documentclassthrough\maketitle). - •Update
\title{CS 395T Homework N}with the correct number. - •Update
\date{...}with today's date. - •If
example.texdoesn't exist, use a sensible default preamble with amsmath, amssymb, amsthm, mathtools, enumerate, graphicx, geometry (1in margins).
- •If
- •Read each solution file in order (p1.tex, p2.tex, ...).
- •Concatenate: preamble + all solution contents +
\end{document}. - •Write the assembled file to
$ARGUMENTS/solution.tex.
PHASE 3: Compilation
- •Try running
pdflatex -interaction=nonstopmodeon$ARGUMENTS/solution.texvia Bash. - •If pdflatex is not found, tell the user: "LaTeX is not installed. Install TeX Live or MiKTeX to compile. The .tex file has been generated at
$ARGUMENTS/solution.tex." - •If compilation fails:
- •Read the
.logfile to identify errors. - •Fix the LaTeX issues in solution.tex.
- •Recompile (max 3 attempts).
- •Read the
- •If compilation succeeds, clean up auxiliary files (.aux, .log, .out).
PHASE 4: Report
Tell the user:
- •How many problem solutions were assembled
- •Where the final document is saved:
$ARGUMENTS/solution.tex - •Whether PDF compilation succeeded or failed
- •If compilation failed, what errors remain