Here is a sample of my exam basic structure. I know there is room for improvement but I haven't had much time to deal with it. After consultation with the author the exam
class, adding:
\makeatletter
\newcommand{\firstquestion}[1]{%
\@ifundefined{tbl@#1@firstq}%
{0}%
{\csname tbl@#1@firstq\endcsname}%
}
\newcommand{\lastquestion}[1]{%
\@ifundefined{tbl@#1@lastq}%
{0}%
{\csname tbl@#1@lastq\endcsname}%
}
\newcounter{qcounter}
\newcommand{\numqinrange}[1]{%
\setcounter{qcounter}{\lastquestion{#1}}%
\addtocounter{qcounter}{-\firstquestion{#1}}%
\stepcounter{qcounter}%
\arabic{qcounter}%
}
\makeatother
%---------------------------------------------------------------------
to the preamble enables the user to access the number of questions in a range with the command \numqinrange{myrange}
, first with \firstquestion{myrange}
and last question with \lastquestion{myrange}
. See the example below:
\documentclass[letterpaper,addpoints]{exam}
\usepackage[bottom=3cm,top=3cm,right=2cm,left=2cm]{geometry} % Optional geometry specifications
\usepackage{amsmath,amssymb,tikz,calc} % Optional packages
\usepackage{lipsum}
\parindent0pt
%--------------------------------------------------------------------
% Thanks to the author of the exam class Philip Hirschhorn
% This adds the option to count the number of questions in the range.
% Thus we would use \numqinrange{myrange} to get the number of questions in the range.
% You can also say \firstquestion{myrange} to get the first question and \lastquestion{myrange} to get the last question.
\makeatletter
\newcommand{\firstquestion}[1]{%
\@ifundefined{tbl@#1@firstq}%
{0}%
{\csname tbl@#1@firstq\endcsname}%
}
\newcommand{\lastquestion}[1]{%
\@ifundefined{tbl@#1@lastq}%
{0}%
{\csname tbl@#1@lastq\endcsname}%
}
\newcounter{qcounter}
\newcommand{\numqinrange}[1]{%
\setcounter{qcounter}{\lastquestion{#1}}%
\addtocounter{qcounter}{-\firstquestion{#1}}%
\stepcounter{qcounter}%
\arabic{qcounter}%
}
\makeatother
%---------------------------------------------------------------------
\pagestyle{headandfoot} % Used for the header and footer options
\firstpageheadrule % Head rules for fancy page style
\runningheadrule
% Header is optional and may vary depending on your exams.
\firstpageheader{Intermediate Algebra$|$MTH103}{Final Exam}{November 30, 2012}
\runningheader{MTH103}{Final Exam}{\iflastpage{End of exam}{\emph{continued}}}
\firstpagefooter{}{Please go on to the next page\ldots}{Page \thepage\ of \numpages}
\runningfooter{}{\iflastpage{AT THIS POINT, GO OVER YOUR WORK}{Please go on to the next page\ldots}}{Page \thepage\ of \numpages}
% This command is specific to a question so not really needed here.
\def\Bsqr{%
\lower1ex\hbox{%
\begin{tikzpicture}
\draw (0,0)rectangle(0.5,0.5);
\end{tikzpicture}}}
\begin{document}
\begin{coverpages}
% Here you can put anything as your cover page. Specifics about your exam.
\lipsum[1-2]
% Defining the grading tables. We use \fullwidth to ensure it acts as an instruction.
\fullwidth{\Large \textbf{Structured Questions}}
\begin{flushleft}
%
% Grading table for the structured questions, Part A and Part B range.
\partialgradetable{structuredquestions}[h][questions]
\hfill
\partialgradetable{OptionalPartA}[h][questions] \raisebox{1.5\baselineskip}{\rotatebox{-90}{\textbf{Part A}}}
\vskip0.5\baselineskip\hfill
\partialgradetable{OptionalPartB}[h][questions] \raisebox{1.5\baselineskip}{\rotatebox{-90}{\textbf{Part B}}}
\end{flushleft}
\vfill
\hrule\vspace{0.125cm}
\centerline{DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO}
\end{coverpages}
% Structured questions section.
\fullwidth{\Large \textbf{Structured Questions}}
\vskip\baselineskip
% Implementing the \numqinrange{myrange} to count the number of question in the structured section grading range
This section contains \numqinrange{structuredquestions} question(s) of which \textbf{all} must be answered on your answer sheet.
\begingradingrange{structuredquestions}
\begin{questions}
\question
\begin{parts}
\part Simplify the following numerical expressions.\label{q1}
\begin{subparts}
\subpart[3] $\dfrac{9^{-1}2^3}{3^2}\cdot \dfrac{(-3)^3}{-2^3}$\label{q1a}\vskip\baselineskip
\subpart[3] $\dfrac{\frac{2}{5}-\left|\frac{5}{3}-\frac{5}{2}\right|}{\frac{2}{5}\div 6\div\left(-\frac{2}{39}\right)}$\label{q1b}\vskip\baselineskip
\end{subparts}
\part[2] Use the results in (\ref{q1}) above to place the appropriate relational symbol ($<,>,\mbox{ or }=$) to make the following statement true.
\[ \dfrac{9^{-1}2^3}{3^2}\cdot \dfrac{(-3)^3}{-2^3} \quad \Bsqr \quad \dfrac{\frac{2}{5}-\left|\frac{5}{3}-\frac{5}{2}\right|}{\frac{2}{5}\div 6\div\left(-\frac{2}{39}\right)}\]
\part[4] If the results in (\ref{q1}) are rational numbers, determine their decimal representation and describe it (i.e. state whether it is terminating or recurring.)\label{q3}
\part[2] Using (\ref{q3}.) above, approximate (\ref{q1a}) and (\ref{q1b}) in (\ref{q1}) to 2 s.f. and 2 d.p. respectively.
\end{parts}\vspace{0.25cm}
\endgradingrange{structuredquestions}
\fullwidth{\hrulefill\par\flushright \textbf{Total Points: \pointsonpage{\thepage} points}}
\newpage
%--------------------------------------------------------------------------
\fullwidth{\Large \textbf{Optional Questions}}
\vskip0.5\baselineskip
\fullwidth{This section contains 2 subsections: Part A and Part B. Choose \textbf{ONE} subsection and answer \textbf{all} questions.}\vskip0.25\baselineskip
\fullwidth{%
\fbox{%
\makebox[\dimexpr\textwidth-2\fboxsep-0.79999pt\relax]{%
\rule{0pt}{1cm}\Large%
\newlength{\word}
\settoheight{\word}{\Large\textbf{Part A}}
\raisebox{\dimexpr1cm-2\word\relax}{\textbf{Part A}}}}}
\vskip\baselineskip
\begingradingrange{OptionalPartA}
\question Let $f(x)=2x^3+11x^2-7x-6$
\begin{parts}
\part[1] Use the Rational Zeros Theorem to determine the potential rational zeros for $f(x)$.
\part[3] Hence, factorize completely $f(x)$.
\part[3] Solve $f(x)=0$.\vskip\baselineskip
\end{parts}
\endgradingrange{OptionalPartA}
\fullwidth{\hrulefill\par\flushright \textbf{Total Points: \pointsonpage{\thepage} points}}
\newpage
\fullwidth{%
\fbox{%
\makebox[\dimexpr\textwidth-2\fboxsep-0.79999pt\relax]{%
\rule{0pt}{1cm}\Large%
%\newlength{\word}
\settoheight{\word}{\Large\textbf{Part B}}
\raisebox{\dimexpr1cm-2\word\relax}{\textbf{Part B}}}}}
\vskip\baselineskip
\begingradingrange{OptionalPartB}
\question[5] Find the \textbf{sum} of $a$, $b$, $c$ and $d$ if $\dfrac{x^3-2x^2+3x+5}{x+2}=ax^2+bx+c+\dfrac{d}{x+2}$.\vskip\baselineskip
\question
\begin{parts}
\part[8] Show that $\dfrac{x+3}{x^2-y^2}\div\dfrac{x^2+2x-3}{x^2+xy}-\dfrac{y}{x^2-x-xy+y}=\dfrac{1}{x-1}$
\part[6] Simplify $3-\dfrac{3}{\raisebox{1.1ex}{$1-$}\left(\raisebox{1.1ex}{$\dfrac{3}{3-\dfrac{\mathstrut 3}{x^2}}$}\right)}$\vskip\baselineskip
\end{parts}
\endgradingrange{OptionalPartB}
\fullwidth{\hrulefill\par\flushright \textbf{Total Points: \pointsonpage{\thepage} points}}
\end{questions}
\end{document}
Best Answer
If you want the
question
andsolution
environments to behave exactly like they do in theexam
document class then you'll need to copy the relevant code fromexam.cls
.However, if you just want something that looks similar, then you could define your own environment, perhaps something like the following, which uses the
enumitem
to do the hard work:Similarly, you can define your own
solution
environment:Of course, you could get more adventurous by using a
theorem
package, e.gamsthm
if you wanted more formatting.Finally, another idea is to simply include the
pdf
version of your previous exams using thepdfpages
, in which case you don't need to worry about these environments at all!Here's a complete MWE to build from: