Problem Set Generator
Write your problems in a few lines of simple markup and this problem set generator turns them into a LaTeX file. One switch in the file prints the problem set or its solution key, and students can get a homework template with an answer box for every part.
# Title [points] starts a problem, (a) [points] a part, - or -* a choice (* = correct), Solution: a solution. Other lines are LaTeX text.
LaTeX
\documentclass[11pt,letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[margin=2.5cm]{geometry}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{comment}
% true: solutions are printed (key); false: they are left out (problem set).
\newif\ifsolutions
\solutionsfalse
\ifsolutions
\newenvironment{solution}{\begin{proof}[Solution]}{\end{proof}}
\else
\excludecomment{solution}
\fi
\newcommand{\answerspace}{\ifsolutions\else\vspace{4cm}\fi}
% \problem{number}{title}{points}
\newcommand{\problem}[3]{\par\bigskip\noindent\textbf{Problem #1\ifx&\else: #2\fi}\ifx&\else\hfill\textit{(#3)}\fi\par\smallskip}
\pagestyle{fancy}
\fancyhf{}
\lhead{MATH 221: Linear Algebra}
\rhead{Problem Set 3}
\cfoot{\thepage}
\setlength{\parindent}{0pt}
\setlength{\parskip}{4pt}
\begin{document}
\begin{center}
{\large MATH 221: Linear Algebra}\\[2pt]
{\LARGE\bfseries Problem Set 3\ifsolutions\ --- Solutions\fi}\\[4pt]
Prof. A. Example \quad\textbullet\quad
Due Friday, October 10 \quad\textbullet\quad
Total: 20 points
\end{center}
\noindent Name: \rule{6cm}{0.4pt} \hfill Collaborators: \rule{5cm}{0.4pt}\par
\noindent\textit{Show all your work. You may discuss the problems, but write up your own solutions.}\par
\problem{1}{Eigenvalues}{10 points}
Let $A = \begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix}$.
\begin{enumerate}[label=(\alph*)]
\item \textit{(4 points)} Find the characteristic polynomial of $A$.
\begin{solution}
$\det(A - \lambda I) = (2-\lambda)^2 - 1 = \lambda^2 - 4\lambda + 3$.
\end{solution}
\item \textit{(6 points)} Find the eigenvalues and an eigenvector for each.
\begin{solution}
$\lambda_1 = 1$ with $v_1 = (1,-1)^T$, and $\lambda_2 = 3$ with $v_2 = (1,1)^T$.
\end{solution}
\end{enumerate}
\problem{2}{Rank}{4 points}
Which matrix has rank 2?
\begin{enumerate}[label=(\Alph*)]
\item $\begin{pmatrix} 1 & 2 \\ 2 & 4 \end{pmatrix}$
\item $\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}$
\item $\begin{pmatrix} 0 & 0 \\ 0 & 0 \end{pmatrix}$
\end{enumerate}
\begin{solution}
Answer: (B).
Its determinant is $-2 \neq 0$.
\end{solution}
\problem{3}{Proof}{6 points}
Show that if $A$ is invertible, then $0$ is not an eigenvalue of $A$.
\begin{solution}
If $Av = 0$ for some $v \neq 0$, then $v = A^{-1}Av = 0$, a contradiction.
\end{solution}
\end{document}
Problems: 3 · Points: 20
In the file, \solutionsfalse hides every solution and \solutionstrue prints them.
Have old problem sets only on paper or as PDFs? Convert them to LaTeX.
Convert a fileHow to make a problem set
Write the problems
Start each problem with # and a title, add [10] for its points, and write the statement below in LaTeX, with math in $…$. Lines starting with (a), (b) become parts, - lines become multiple-choice options, and a line starting with Solution: holds the answer.
Choose what to print
The problem set hides every solution, the solution key prints them under each problem, and the homework answer template replaces them with empty solution boxes for students. All three come from the same problems, so the problem set and its key never drift apart.
Compile and hand out
Download the .tex file and compile it with pdfLaTeX, for example by uploading it to a new Overleaf project. Every page carries the course and the problem set title in its header, and the first page has lines for the student's name and collaborators.
What the LaTeX file contains
One switch for the solutions
Solutions sit in a solution environment. With \solutionsfalse at the top of the file the comment package removes them; change it to \solutionstrue and the same problem set prints as a key, each solution set like a proof and ending with a box.
Parts, choices and points
Parts are lettered (a), (b), (c) with enumitem, and choices are lettered (A), (B), (C). Points can sit on a problem or on its parts; a problem without its own points adds up its parts, and the header shows the total for the whole problem set.
Answer space and labels
For handwritten work, add 4 or 8 cm of space after each problem or part; it disappears automatically in the key. Problems can be labelled Problem, Exercise or Question, and the file uses only standard packages such as amsmath, amsthm and fancyhdr.
For students
A homework answer template
Paste the problems from your problem set, choose Homework answer template and add your name. Each problem and part gets its own solution box, so you only write the answers, and your name appears in the page header.
Writing math quickly
Use $…$ for inline math and \[ … \] for displayed equations, align for multi-line derivations, and \frac, \sum, \int and \begin{pmatrix} for most homework. Compile often, so a missing brace is easy to find.
Building a long equation?
Use the equation editor to build a formula with buttons and a live preview, then paste the LaTeX into your problem set.
LaTeX equation editorOfficial references: The LaTeX Project · amsmath (CTAN)

Problem set questions
- What is a problem set?
- A problem set is a group of exercises assigned as homework, usually weekly, in subjects such as mathematics, physics, computer science and economics. Students hand in written solutions, and the instructor often publishes a solution key afterwards.
- How to use LaTeX for math homework?
- Choose Homework answer template, paste the problems, download the file and write each answer inside its solution environment, with math between $ signs. Compile it on Overleaf or with pdflatex to get a clean PDF to hand in.
- Is it worth doing homework in LaTeX?
- For math-heavy courses, usually yes once you know the basics: the result is easy to read, easy to correct and easy to reuse. It is slower at first, and for a short problem set handwriting can still be quicker.
- How to add questions to homework in LaTeX?
- Here, start a new line with # and the title, and (a), (b) for its parts. In the downloaded file, copy a \problem{number}{title}{points} block and its text, and change the number.
- How to write a problem set in LaTeX?
- Use the article class with amsmath for the math, a numbered heading for each problem, enumerate for the parts and an environment for solutions you can hide. The problem set generator writes exactly that from your problems.
- How to make problem sets?
- Pick problems that practise the week's material, start with routine ones and end with one or two harder ones, give points, and write the solutions while you write the problems. Then the problem set and its key are ready together.
- How to answer a problem set?
- Answer each part separately, show the steps, justify each claim and mark the final result. The answer template gives every part its own solution box, which keeps a problem set tidy for the grader.
- How do I add solutions that can be hidden?
- Write a line starting with Solution: after the problem or part. The file wraps it in a solution environment that \solutionsfalse removes and \solutionstrue prints, so one source gives both versions.
- Can I use this homework template in Overleaf?
- Yes. Download the .tex file and upload it to a new Overleaf project; it compiles with pdfLaTeX, the default, because every package it uses is part of a standard TeX installation.
- Should I use the LaTeX exam class instead?
- The exam class has built-in points, grading tables and solutions, and suits exams. This problem set generator writes a plain article file with a few packages, which is easier to read and change; both are fine choices.
- Can a problem set include multiple-choice questions?
- Yes. Write each option on a line starting with -, and use -* for the correct one. The options are lettered (A), (B), (C), and the key starts that problem's solution with the right letter.
- Is there a free problem set generator?
- Yes, this one. It is free, needs no account, runs in your browser and writes a LaTeX problem set, a solution key or an answer template from the same problems.
- How are points counted?
- Add [10] after a problem title or [3] after a part letter. A problem without its own points takes the sum of its parts, and the header shows the total for the problem set.
Have a whole page of notes, a scan or a PDF? Convert it to LaTeX that compiles.
Convert a file