% ============================================================
% exam-demo.tex — LaTeX Exam Template
% Demo version — free to use
%
% Compile twice:
% pdflatex exam-demo.tex
% pdflatex exam-demo.tex
%
% For the student copy: comment out the ANSWER KEY block at the end.
% ============================================================
\documentclass[12pt,a4paper]{article}
% ── Packages ─────────────────────────────────────────────────
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath, amssymb}
\usepackage{geometry}
\usepackage{enumitem}
\usepackage{array, booktabs, tabularx}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{multicol}
\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage{helvet}
\usepackage{setspace}
\usepackage{tikz}
\usepackage{answers}
\usepackage{hyperref}
\hypersetup{
hidelinks=true,
}
% ── Layout ───────────────────────────────────────────────────
\geometry{top=1.5cm, bottom=2cm, left=1.5cm, right=1.5cm, columnsep=0.7cm}
\setlength{\columnseprule}{0.4pt}
\renewcommand{\familydefault}{\sfdefault}
\setstretch{1.0}
\setlength{\parskip}{0pt}
\setlength{\parindent}{0pt}
% ── Color theme — Navy Blue ───────────────────────────────────
\definecolor{corPrimaria} {RGB}{31,56,100}
\definecolor{corSecundaria}{RGB}{155,195,230}
\definecolor{corSutil} {RGB}{70,110,160}
\definecolor{corFundo} {RGB}{232,242,252}
% ── Header / Footer ──────────────────────────────────────────
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[L]{\footnotesize\color{corSutil}
\textit{Free template} \textbf{questionbank} \textit{for \LaTeX{} —
full version with question bank, random selection and automatic answer key
available in the store.}}
\fancyfoot[R]{\small\color{corSutil} Page~\thepage\ of \pageref{LastPage}}
% ── Colored section header ────────────────────────────────────
\newcommand{\testsection}[2][]{%
\vspace{6pt}%
\noindent\colorbox{corPrimaria}{%
\begin{minipage}{\dimexpr\linewidth-2\fboxsep\relax}
\color{white}\textbf{\normalsize #2}%
\ifx&\else\textbf{\normalsize\ --- \textit{#1}}\fi
\end{minipage}}\par\vspace{1pt}%
\noindent{\color{corSecundaria}\rule{\linewidth}{0.8pt}}\smallskip}
% ── Question environment ─────────────────────────────────────
\newcounter{questao}
\newenvironment{question}[1][]{%
\stepcounter{questao}%
\par\vspace{4pt}%
\noindent\textbf{\arabic{questao}.}\enspace
\ifx&\else\textbf{(#1)}\enspace\fi
\ignorespaces
}{%
\par\vspace{2pt}\noindent\rule{\linewidth}{0.3pt}\vspace{1pt}%
}
% ── Answer choices ────────────────────────────────────────────
\newenvironment{choices}{%
\begin{enumerate}[label=(\alph*),leftmargin=2em,itemsep=0pt,parsep=0pt,topsep=3pt]}%
{\end{enumerate}}
% ── Context box ──────────────────────────────────────────────
\newmdenv[backgroundcolor=corFundo,linewidth=0pt,
innerleftmargin=10pt,innerrightmargin=10pt,
innertopmargin=6pt,innerbottommargin=6pt]{context}
% ── Instructions box ─────────────────────────────────────────
\newmdenv[backgroundcolor=corFundo,linecolor=corPrimaria,linewidth=1pt,
innerleftmargin=10pt,innerrightmargin=10pt,
innertopmargin=6pt,innerbottommargin=6pt,roundcorner=4pt]{instructions}
% ── Work spaces ───────────────────────────────────────────────
\newcount\nlines
\newlength{\worklineskip}\setlength{\worklineskip}{0pt}
\newcommand{\worklines}[1][5]{%
\par\vspace{1mm}%
\noindent\textit{\small\color{corSutil}Work:}\par\noindent
\nlines=#1\relax
\loop\ifnum\nlines>0
\rule{\columnwidth}{0.3pt}\\[\worklineskip]%
\advance\nlines by -1
\repeat\par\vspace{1mm}}
\newlength{\gridcell}\setlength{\gridcell}{5mm}
\newcommand{\workgrid}[1][5]{%
\par\vspace{1mm}%
\noindent\textit{\small\color{corSutil}Work:}\par\noindent
\begin{tikzpicture}[x=\gridcell,y=\gridcell]
\pgfmathsetmacro{\cols}{int(floor(\columnwidth/\gridcell))}%
\foreach \r in {0,...,#1}{\draw[gray!35,line width=0.3pt](0,-\r)--(\cols,-\r);}%
\foreach \c in {0,...,\cols}{\draw[gray!35,line width=0.3pt](\c,0)--(\c,-#1);}%
\draw[black!55,line width=0.6pt](0,0) rectangle (\cols,-#1);
\end{tikzpicture}\par\vspace{1mm}}
\newcommand{\answerline}[1][Answer]{%
\par\smallskip\noindent\textbf{#1:}\enspace\dotfill\par}
% ── Automatic answer key ──────────────────────────────────────
\Newassociation{sol}{Res}{ans}
\renewenvironment{Res}[1]{\noindent\textbf{#1.}\enspace}{\quad}
% ═════════════════════════════════════════════════════════════
\begin{document}
\thispagestyle{fancy}
% ── Exam header ───────────────────────────────────────────────
\noindent\rule{\linewidth}{2pt}\vspace{1pt}
\noindent\begin{tabularx}{\linewidth}{@{}X r@{}}
{\large\bfseries\color{corPrimaria} MATHEMATICS EXAM} &
{\small\bfseries
Class\,\underline{\hspace{1.3cm}}\enspace
Term\,\underline{\hspace{0.9cm}}\enspace
Year\,\underline{\hspace{0.9cm}}} \\
\end{tabularx}
\vspace{1pt}\noindent\rule{\linewidth}{0.4pt}\vspace{3pt}
\noindent\begin{tabularx}{\linewidth}{@{}X@{\hspace{6pt}}X@{}}
\small\textbf{Student:}\enspace\dotfill &
\small\textbf{School:}\enspace\dotfill \\[5pt]
\small\textbf{Teacher:}\enspace\dotfill &
\small\textbf{Date:}\enspace\underline{\hspace{2.2cm}}\quad
\textbf{Score:}\enspace\underline{\hspace{1.5cm}} \\
\end{tabularx}
\vspace{2pt}\noindent\rule{\linewidth}{2pt}\vspace{4pt}
\begin{instructions}
\noindent\textbf{Instructions:}
\begin{itemize}[noitemsep,leftmargin=1.4em]
\item Read each question carefully before answering.
\item Calculators are not permitted.
\item Show all your work; answers without supporting work will not receive credit.
\item Write legibly in pen (blue or black ink).
\end{itemize}
\end{instructions}
\medskip
\Opensolutionfile{ans}[answer_key]
% ════════════════════════════════════════════════════════════
% PART I — MULTIPLE CHOICE
% ════════════════════════════════════════════════════════════
\begin{multicols}{2}
\testsection[2 points each]{PART I --- MULTIPLE CHOICE}
\begin{question}[2 pts]
What is the value of $x$ in the equation $3x - 7 = 2$?
\begin{choices}
\item $x = 1$
\item $x = 2$
\item $x = 3$
\item $x = 4$
\end{choices}
\begin{sol}(c) $x = 3$\end{sol}
\end{question}
\begin{question}[2 pts]
What is the area of a triangle with base $10\,\text{cm}$
and height $8\,\text{cm}$?
\begin{choices}
\item $40\,\text{cm}^2$
\item $80\,\text{cm}^2$
\item $18\,\text{cm}^2$
\item $160\,\text{cm}^2$
\end{choices}
\begin{sol}(a) $A = 40\,\text{cm}^2$\end{sol}
\end{question}
\begin{question}[2 pts]
Which fraction is equivalent to $0.625$?
\begin{choices}
\item $\dfrac{3}{5}$
\item $\dfrac{5}{8}$
\item $\dfrac{2}{3}$
\item $\dfrac{7}{10}$
\end{choices}
\begin{sol}(b) $\dfrac{5}{8}$\end{sol}
\end{question}
\begin{question}[2 pts]
A fair die is rolled. What is the probability
of getting a number greater than 4?
\begin{choices}
\item $\dfrac{1}{6}$
\item $\dfrac{1}{3}$
\item $\dfrac{1}{2}$
\item $\dfrac{2}{3}$
\end{choices}
\begin{sol}(b) $P = \dfrac{2}{6} = \dfrac{1}{3}$\end{sol}
\end{question}
\end{multicols}
% ════════════════════════════════════════════════════════════
% PART II — OPEN-ENDED QUESTIONS
% ════════════════════════════════════════════════════════════
\testsection[3 points each]{PART II --- OPEN-ENDED QUESTIONS}
\begin{question}[3 pts]
Solve the system of equations and find the values of $x$ and $y$:
\[
\begin{cases}
2x + 3y = 12 \\
x - y = 1
\end{cases}
\]
\workgrid[6]
\answerline[$x$]
\answerline[$y$]
\begin{sol}$x=3,\; y=2$\end{sol}
\end{question}
\begin{question}[3 pts]
A principal of \$3{,}000.00 was invested at a simple interest rate of
$2.5\%$ per month for 6 months. Calculate the interest earned and
the final amount.
\worklines[7]
\answerline[Interest]
\answerline[Final amount]
\begin{sol}Interest $=$ \$450.00;\; Final amount $=$ \$3{,}450.00\end{sol}
\end{question}
% ════════════════════════════════════════════════════════════
% PART III — PROBLEM SOLVING
% ════════════════════════════════════════════════════════════
\testsection[5 points]{PART III --- PROBLEM SOLVING}
\begin{question}[5 pts]
\begin{context}
A rectangular swimming pool is $15\,\text{m}$ long, $6\,\text{m}$ wide,
and $1.8\,\text{m}$ deep. A pump fills the pool at a flow rate of
$90\,\text{L}$ per minute.
\end{context}
\textbf{a)} Calculate the volume of the pool in m³ and in liters.\par
\textbf{b)} How long (in hours) will the pump take to fill the pool?
\worklines[10]
\answerline[Volume (m³)]
\answerline[Volume (liters)]
\answerline[Time (hours)]
\begin{sol}$162\,\text{m}^3$;\; $162{,}000\,\text{L}$;\; $30\,\text{h}$\end{sol}
\end{question}
% ════════════════════════════════════════════════════════════
{\color{corSecundaria}\rule{\linewidth}{2pt}}
\begin{center}
\textit{\small\color{corSutil}\textbf{Good luck!}}
\end{center}
\Closesolutionfile{ans}
% ════════════════════════════════════════════════════════════
% ANSWER KEY — comment out this block for the student copy
% ════════════════════════════════════════════════════════════
\newpage
\pagestyle{fancy}
\fancyhead[C]{\small\color{corSutil}\textit{--- FOR TEACHER USE ONLY ---}}
\testsection{ANSWER KEY}
\begin{multicols}{2}
\Readsolutionfile{ans}
\end{multicols}
\bigskip
{\color{corFundo}\rule{\linewidth}{6pt}}
\vspace{4pt}
\noindent\colorbox{corPrimaria}{%
\begin{minipage}{\dimexpr\linewidth-2\fboxsep\relax}
\color{white}\small
\textbf{Want more?} This template is a free demo of the
\textbf{questionbank} package for \LaTeX{}.
The full version includes a modular question bank, random question
selection (Fisher-Yates), filtering by type, difficulty and tags,
5 color themes, work spaces (ruled lines, grid, blank),
automatic answer key generation, and much more.
\url{https://texdrop.com/}
\end{minipage}}
\end{document}

PDF Preview
Create an account to compile and preview