Open main menu

Wikibooks β

LaTeX/Teacher's Corner

< LaTeX


LaTeX has specific features for teachers. We present the exam class[1] which is useful for designing exams and exercises with solutions. Interested people could also have a look at the probsoln package[2], the mathexm document class[3], or the exsheets package[4].

The exam classEdit

We present the exam class. The exam class is well suited to design exams with solutions. You just have to specify in the preamble if you want the solutions to be printed or not. You can also count the number of points.


In the preamble you can specify the following lines :

\printanswers % If you want to print answers
% \noprintanswers % If you don't want to print answers
\addpoints % if you want to count the points
% \noaddpoints % if you don't want to count the points
% Specifies the way question are displayed:
\usepackage{color} % defines a new color
\definecolor{SolutionColor}{rgb}{0.8,0.9,1} % light blue
\shadedsolutions % defines the style of the solution environment
% \framedsolutions % defines the style of the solution environment
% Defines the title of the solution environment:

You can replace the 3 first lines with the following :



  • The exam is included in the questions environment.
  • The command \question introduces a new question.
  • The number of points is specified in squared brackets.
  • The solution is given in the solution environment. It appears only if \printanswers or answers as an option of the \documentclass are specified in the preamble.

Here is an example :

\begin{questions} % Begins the questions environment
\question[2] What is the solution? % Introduces a new question which is worth 2 points
Here is the solution 
\question[5] What is your opinion?
This is my opinion

It is also possible to add stuff only if answers are printed using the \ifprintanswers command.

Only if answers are printed
Only if answers are not printed


The macro \numquestions gives the total number of questions. The macro \numpoints gives the total number of points.

This exam includes \numquestions\ questions. The total number of points is \numpoints.

The backslash after \numquestion prevents the macro from gobbling the following whitespace as it normally would.


Package exsheets is an alternative to the exam class. It can be used to create exam papers, text books including solutions etc. Many options are availble to style the output. Following a demonstrative example.

	Which one of the entries does not fit with the others?
		\task mercury
		\task iron
		\task lead
		\task zinc
	Explain your decision for the answer above.


	What is a funkyton?
		\task A dancing electron
		\task A dancing proton
		\task A dancing neutron
		\task A Dixie Dancing Duck

	Question & \ForEachQuestion{\QuestionNumber{#1}\iflastquestion{}{&} } & Total \\ \midrule
	Points   & \ForEachQuestion{\GetQuestionProperty{points}{#1}\iflastquestion{}{&} } & \pointssum* \\ 
	Reached  & \ForEachQuestion{\iflastquestion{}{&} } & \\ \bottomrule


Successor of exsheets will be package xsim.


  1. examdoc Using the exam document class
  2. Probsoln Creating problem sheets optionally with solutions
  3. mathexm documentation
  4. exsheets documentation Create exercise sheets and exams

Previous: Presentations Index Next: Curriculum Vitae