%% nswexam.cls -- HSC-style exam papers for NSW Mathematics %% Version 0.2, 2026-11-25. Free to use and adapt. %% %% Compile with XeLaTeX or LuaLaTeX, twice: totals, page numbers and the %% cover come from the previous run. pdfLaTeX is not supported. %% Uses only packages in a basic TeX Live 2023 (Ubuntu 24.04) install, so %% it also compiles in AI chat sandboxes. No image files are needed. %% %% ---------------------------------------------------------------- usage %% \documentclass[answers, boldvectors]{nswexam} %% answers solutions in red, correct options marked, solutions cover %% boldvectors \vect is bold unless changed (default: tilde underneath) %% fallbackfonts always use TeX Gyre Termes + Latin Modern Math %% %% \examsetup{ %% institution = ..., year = 2026, exam = Year 12 Trial HSC Examination, %% course = Mathematics Extension 2, subtitle = ..., %% reading time = 10 minutes, working time = 3 hours, %% student id = Number, student boxes = 9 (0 = a line), class label = Class, %% section details = false (true: student number atop every section, so %% sections can be separated for marking), %% booklets = true (false: students answer on lines in the paper), %% written sections time = ... (one time for all sections after Section I), %% logo = {any LaTeX}, footer = {...}, copyright = {...}, %% watermark = ..., comments = {...}, reference sheet = file.pdf, %% calculators = true, expected marks = 100 } %% %% \begin{document} %% \makecover %% \sectionone[15 minutes] % multiple choice; omit if none %% \begin{questions} %% \question[1] Stem ... % each multiple choice question is [1] %% \begin{choices} % \begin{choices}[2]: 2 per row %% \choice ... \CorrectChoice ... \choice ... \choice ... %% \end{choices} %% \begin{solution} ... \end{solution} %% \end{questions} %% \examsection[2 hours 45 minutes]{II} % Section II, III, ...: one %% \begin{questions} % questions environment each %% \question % total = sum of its parts %% \begin{parts} %% \part[2] \topic{MEX-N1} ... % marks print in the right margin %% \answerlines{6} % lines to write on (paper only) %% \begin{solution} ... \allocate{1 mark: method} ... \end{solution} %% \part \begin{subparts} \subpart[1] ... \end{subparts} %% \end{parts} %% \end{questions} %% \extrawritingspace[2] % pages of lines at the back %% \mcanswersheet % answer sheet for Section I %% \end{document} %% %% Vectors: \vect{u} follows the paper's style; \vectorstyle{bold} or %% \vectorstyle{tilde} changes it until the next \question. %% \tvec{u} is always tilde, \bvec{u} always bold. %% \ihat \jhat \khat \proj{a}{b} (a onto b) \colvec{1,0,3} %% Maths: \Re \Im \Arg \cosec \N \Z \Q \R \C \abs{x} \floor{x} \ceil{x} %% Other: \allocate{text} \topic{code} \blankpage %% contributors environment with \contributor{name}{affiliation} %% ---------------------------------------------------------------------- \NeedsTeXFormat{LaTeX2e} \ProvidesClass{nswexam}[2026/11/25 v0.2 NSW exam house style] \RequirePackage{iftex} \ifPDFTeX \ClassError{nswexam}{nswexam needs XeLaTeX or LuaLaTeX} {Compile with xelatex or lualatex. pdfLaTeX cannot load the fonts.} \fi \newif\ifnswexam@answers \newif\ifnswexam@boldvectors \newif\ifnswexam@fallbackfonts \DeclareOption{answers}{\nswexam@answerstrue} \DeclareOption{solutions}{\nswexam@answerstrue} \DeclareOption{boldvectors}{\nswexam@boldvectorstrue} \DeclareOption{tildevectors}{\nswexam@boldvectorsfalse} \DeclareOption{fallbackfonts}{\nswexam@fallbackfontstrue} \DeclareOption*{\PassOptionsToClass{\CurrentOption}{exam}} \ProcessOptions\relax \LoadClass[12pt,a4paper]{exam} %% ------------------------------------------------------------ packages \RequirePackage[a4paper, margin=2cm, bottom=2.8cm, footskip=1cm, headheight=15pt]{geometry} \RequirePackage{etoolbox} \RequirePackage{xcolor} \RequirePackage{graphicx} \RequirePackage{amsmath} \RequirePackage{mathtools} \RequirePackage{fontspec} \RequirePackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math} \RequirePackage{siunitx} \RequirePackage{cancel} \RequirePackage{tabularx} \RequirePackage{enumitem} \RequirePackage{tikz} \usetikzlibrary{arrows.meta, calc, angles, quotes, patterns, patterns.meta, decorations.markings, intersections, shapes.geometric} \RequirePackage{pgfplots} \pgfplotsset{compat=1.18} \RequirePackage[stamp=false]{draftwatermark} \RequirePackage{pdfpages} \RequirePackage{refcount} \RequirePackage[hidelinks]{hyperref} %% --------------------------------------------------------------- fonts %% Times New Roman or STIX Two where installed (Mac, Windows, Overleaf); %% otherwise TeX Gyre Termes with Latin Modern Math, borrowing Termes %% digits and letters so that maths matches the text. \newcommand\nswexam@termestext{% \setmainfont{texgyretermes}[Extension=.otf, Ligatures=TeX, UprightFont=*-regular, BoldFont=*-bold, ItalicFont=*-italic, BoldItalicFont=*-bolditalic]} \newcommand\nswexam@termesmath{% \setmathfont{latinmodern-math.otf}% \setmathfont{texgyretermes-regular.otf}[range={up/{num,Latin,latin}}]% \setmathfont{texgyretermes-italic.otf}[range={it/{Latin,latin}}]% \setmathfont{texgyretermes-bold.otf}[range={bfup/{num,Latin,latin}}]} \ifnswexam@fallbackfonts \nswexam@termestext \nswexam@termesmath \else \IfFontExistsTF{Times New Roman} {\setmainfont{Times New Roman}[Ligatures=TeX]} {\IfFontExistsTF{STIXTwoText-Regular.otf} {\setmainfont{STIXTwoText}[Extension=.otf, Ligatures=TeX, UprightFont=*-Regular, BoldFont=*-Bold, ItalicFont=*-Italic, BoldItalicFont=*-BoldItalic]} {\nswexam@termestext}} \IfFontExistsTF{STIXTwoMath-Regular.otf} {\setmathfont{STIXTwoMath-Regular.otf}} {\nswexam@termesmath} \fi \newfontfamily\nswexam@sans{texgyreheros}[Extension=.otf, Ligatures=TeX, UprightFont=*-regular, BoldFont=*-bold, ItalicFont=*-italic, BoldItalicFont=*-bolditalic] \linespread{1.1} \setlength{\parindent}{0pt} \setlength{\parskip}{0.5em plus 0.2em} %% ------------------------------------------------------------ settings \ExplSyntaxOn \keys_define:nn { nswexam } { institution .tl_set:N = \l__nswexam_institution_tl , year .tl_set:N = \l__nswexam_year_tl , year .initial:n = \the\year , exam .tl_set:N = \l__nswexam_exam_tl , exam .initial:n = Examination , course .tl_set:N = \l__nswexam_course_tl , subtitle .tl_set:N = \l__nswexam_subtitle_tl , logo .tl_set:N = \l__nswexam_logo_tl , reading~time .tl_set:N = \l__nswexam_readingtime_tl , reading~time .initial:n = 10~minutes , working~time .tl_set:N = \l__nswexam_workingtime_tl , working~time .initial:n = 3~hours , section~one~time .tl_set:N = \l__nswexam_sectiononetime_tl , section~one~time .initial:n = 15~minutes , section~two~time .tl_set:N = \l__nswexam_sectiontwotime_tl , written~sections~time .tl_set:N = \l__nswexam_writtentime_tl , student~id .tl_set:N = \l__nswexam_studentid_tl , student~id .initial:n = Number , student~boxes .tl_set:N = \l__nswexam_studentboxes_tl , student~boxes .initial:n = 0 , class~label .tl_set:N = \l__nswexam_classlabel_tl , class~label .initial:n = Class , footer .tl_set:N = \l__nswexam_footer_tl , copyright .tl_set:N = \l__nswexam_copyright_tl , watermark .tl_set:N = \l__nswexam_watermark_tl , comments .tl_set:N = \l__nswexam_comments_tl , reference~sheet .tl_set:N = \l__nswexam_referencesheet_tl , expected~marks .tl_set:N = \l__nswexam_expectedmarks_tl , booklets .bool_set:N = \l__nswexam_booklets_bool , booklets .initial:n = true , section~details .bool_set:N = \l__nswexam_sectiondetails_bool , section~details .initial:n = false , calculators .bool_set:N = \l__nswexam_calculators_bool , calculators .initial:n = true , } \NewDocumentCommand \examsetup { +m } { \keys_set:nn { nswexam } {#1} } % Accessors for the code below: \nswexam@val{course}, \nswexam@ifempty{..} \cs_new:Npn \nswexam@val #1 { \tl_use:c { l__nswexam_ #1 _tl } } \cs_new:Npn \nswexam@ifempty #1 { \tl_if_empty:cTF { l__nswexam_ #1 _tl } } \cs_new:Npn \nswexam@ifbool #1 { \bool_if:cTF { l__nswexam_ #1 _bool } } % Totals, read from the previous run. exam.cls stores points per question; % this class stores each section's numeral, first question and time. \cs_new:Npn \nswexam@qpoints #1 { \cs_if_exist_use:cF { pointsofq@ \int_to_roman:n {#1} } { 0 } } \cs_new:Npn \__nswexam_plus_points:n #1 { + \nswexam@qpoints {#1} } \cs_new:Npn \nswexam@sumpoints #1#2 { \fp_eval:n { 0 \int_step_function:nnN {#1} {#2} \__nswexam_plus_points:n } } \cs_new:Npn \nswexam@numquestions { \cs_if_exist_use:cF { exam@numquestions } { 0 } } \cs_new:Npn \nswexam@numpoints { \cs_if_exist_use:cF { exam@numpoints } { 0 } } \cs_new:Npn \nswexam@auxval #1#2 { \cs_if_exist_use:cF { nswexam@aux@ #1 } {#2} } \cs_new:Npn \nswexam@nsec { \nswexam@auxval { nsec } { 0 } } \cs_new:Npn \nswexam@sfield #1#2 { \cs_if_exist_use:c { nswexam@s #1 @ #2 } } \cs_new:Npn \nswexam@sfirst #1 { \cs_if_exist_use:cF { nswexam@s #1 @first } { 1 } } \cs_new:Npn \nswexam@slast #1 { \int_compare:nNnTF {#1} < { \nswexam@nsec } { \int_eval:n { \nswexam@sfirst { \int_eval:n { #1 + 1 } } - 1 } } { \nswexam@numquestions } } \cs_new:Npn \nswexam@smarks #1 { \nswexam@sumpoints { \nswexam@sfirst {#1} } { \nswexam@slast {#1} } } \cs_new:Npn \nswexam@ifstime #1#2 { \cs_if_exist:cT { nswexam@s #1 @time } { \tl_if_empty:cF { nswexam@s #1 @time } {#2} } } % the last written section's first question onwards, for a combined block \cs_new:Npn \nswexam@writtenmarks { \nswexam@sumpoints { \nswexam@auxval { writtenfirstq } { 1 } } { \nswexam@numquestions } } \NewDocumentCommand \colvec { m } { \begin{pmatrix} \clist_use:nn {#1} { \\ } \end{pmatrix} } % \prg_replicate:nn for \extrawritingspace[n] \cs_new_eq:NN \nswexam@replicate \prg_replicate:nn \ExplSyntaxOff % Written into the .aux file and read back on the next run. \def\nswexam@aux@sec#1#2#3#4{% \expandafter\gdef\csname nswexam@s#1@num\endcsname{#2}% \expandafter\gdef\csname nswexam@s#1@first\endcsname{#3}% \expandafter\gdef\csname nswexam@s#1@time\endcsname{#4}} \def\nswexam@aux@answer#1#2#3{% \expandafter\gdef\csname nswexam@ans@#1@c\endcsname{#2}% \expandafter\gdef\csname nswexam@ans@#1@n\endcsname{#3}} \newcommand\nswexam@writeaux[1]{\immediate\write\@auxout{#1}} \newcommand\nswexam@markword[1]{\ifnum\numexpr#1\relax=1 mark\else marks\fi} %% --------------------------------------------------------------- maths % Vectors: \vect follows the current style, which returns to the paper's % default at every \question. \newcommand\nswexam@utilde[1]{\mathpalette\nswexam@utilde@{#1}} \newcommand\nswexam@utilde@[2]{% \vtop{\offinterlineskip\ialign{##\cr$\m@th#1#2$\cr\noalign{\kern.15ex}% \hidewidth$\m@th\scriptscriptstyle\sim$\hidewidth\cr}}} \newif\ifnswexam@defaultbold \ifnswexam@boldvectors\nswexam@defaultboldtrue\fi \NewDocumentCommand\vect{m}{% \ifnswexam@boldvectors\symbf{#1}\else\nswexam@utilde{#1}\fi} \NewDocumentCommand\tvec{m}{\nswexam@utilde{#1}} \NewDocumentCommand\bvec{m}{\symbf{#1}} \NewDocumentCommand\vectorstyle{m}{% \ifstrequal{#1}{bold}{\global\nswexam@boldvectorstrue}{% \ifstrequal{#1}{tilde}{\global\nswexam@boldvectorsfalse}{% \ClassError{nswexam}{Unknown vector style `#1'} {Write \string\vectorstyle{tilde} or \string\vectorstyle{bold}.}}}} \newcommand\nswexam@resetvectors{% \ifnswexam@defaultbold\global\nswexam@boldvectorstrue \else\global\nswexam@boldvectorsfalse\fi} \NewDocumentCommand\ihat{}{\vect{i}} \NewDocumentCommand\jhat{}{\vect{j}} \NewDocumentCommand\khat{}{\vect{k}} \NewDocumentCommand\proj{mm}{\operatorname{proj}_{\vect{#2}}\vect{#1}} \DeclareMathOperator{\cosec}{cosec} \DeclareMathOperator{\Arg}{Arg} % unicode-math sets \Re and \Im at \begin{document}, so replace them after it. \AddToHook{begindocument/end}{% \renewcommand\Re{\operatorname{Re}}% \renewcommand\Im{\operatorname{Im}}} \newcommand\N{\mathbb{N}} \newcommand\Z{\mathbb{Z}} \newcommand\Q{\mathbb{Q}} \newcommand\R{\mathbb{R}} \newcommand\C{\mathbb{C}} \DeclarePairedDelimiter\abs{\lvert}{\rvert} \DeclarePairedDelimiter\floor{\lfloor}{\rfloor} \DeclarePairedDelimiter\ceil{\lceil}{\rceil} % House binomials: tighter than amsmath, matrix-style in display. \renewcommand{\tbinom}[2]{\genfrac{(}{)}{-1pt}{1}{#1}{#2}} \renewcommand{\dbinom}[2]{\left(\genfrac{}{}{-1pt}{0}{#1}{#2}\right)} \renewcommand{\binom}[2]{\mathchoice {\begin{pmatrix}#1\\#2\end{pmatrix}}{\tbinom{#1}{#2}} {\tbinom{#1}{#2}}{\tbinom{#1}{#2}}} %% ------------------------------------------------------------- diagrams % House diagram macros come later. Shared defaults for now: \tikzset{>={Triangle[length=0.5em,width=0.25em]}, dotty/.style={pattern={Dots[angle=30,distance=2pt]}}} \pgfplotsset{cartesian/.style={axis lines=center, axis line style={->}, scale only axis, xlabel={$x$}, ylabel={$y$}}} %% ----------------------------------------------------- questions, marks \addpoints \unframedsolutions \SolutionEmphasis{\color{red}} \renewcommand{\solutiontitle}{\noindent} \CorrectChoiceEmphasis{\color{red}\bfseries} \ifnswexam@answers\printanswers\else\noprintanswers\fi \pointname{} \pointsinrightmargin \renewcommand\partshook{\setlength{\itemsep}{1.2em}} \renewcommand\subpartshook{\setlength{\itemsep}{0.8em}} \renewcommand\subpartlabel{(\thesubpart)} \setlength\dottedlinefillheight{2em} \newcommand\nswexam@mcstyle{% \noqformat \renewcommand\questionlabel{\textbf{\thequestion}}% \pointformat{}} \newcommand\nswexam@writtenstyle{% \qformat{\textbf{Question \thequestion} (\nswexam@qpoints{\value{question}}\ \nswexam@markword{\nswexam@qpoints{\value{question}}})% \nswexam@ifbool{booklets}{\quad Use the Question \thequestion\ Writing Booklet}{}% \hfill}% \pointformat{\textbf{\thepoints}}} \nswexam@writtenstyle % \topic{code}: syllabus tag for checking tools; shown only with answers. \NewDocumentCommand\topic{m}{% \ifnswexam@answers{\color{gray}\scriptsize[#1]}\space\fi\ignorespaces} % \allocate{text}: a marking note, right-aligned in blue. \newcommand\nswexam@tick{\tikz[baseline=0pt, x=1em, y=1em] \draw[line width=0.09em, line cap=round, line join=round] (0,0.35) -- (0.25,0.05) -- (0.65,0.75);} % (TeXbook's \signed: stays on the line if it fits, else moves to the next.) \NewDocumentCommand\allocate{m}{% \unskip\nobreak\hfil\penalty50\hskip1em\null\nobreak\hfill \mbox{\color{blue}\small\nswexam@tick\ #1}% {\parfillskip=0pt\finalhyphendemerits=0\par}} % \answerlines{n}: n dotted lines to write on. Not printed with answers. \NewDocumentCommand\answerlines{m}{% \ifprintanswers\else \par\fillwithdottedlines{\dimexpr#1\dottedlinefillheight\relax}% \fi} %% --------------------------------------------- multiple choice options % Same syntax as exam.cls, plus \begin{choices}[2] for a grid (graphs). % The correct option is recorded for \mcanswersheet. \let\nswexam@listchoices\choices \let\endnswexam@listchoices\endchoices \ExplSyntaxOn \tl_new:N \l__nswexam_body_tl \seq_new:N \l__nswexam_items_seq \int_new:N \l__nswexam_correct_int \dim_new:N \l__nswexam_cell_dim \cs_new_protected:Npn \__nswexam_correct_mark: { } \RenewDocumentEnvironment { choices } { O{1} +b } { \__nswexam_choices:nn {#1} {#2} } { } \cs_new_protected:Npn \__nswexam_choices:nn #1#2 { \tl_set:Nn \l__nswexam_body_tl {#2} \tl_replace_all:Nnn \l__nswexam_body_tl { \CorrectChoice } { \choice \__nswexam_correct_mark: } \seq_set_split:NnV \l__nswexam_items_seq { \choice } \l__nswexam_body_tl \seq_pop_left:NN \l__nswexam_items_seq \l_tmpa_tl \int_zero:N \l__nswexam_correct_int \seq_map_indexed_inline:Nn \l__nswexam_items_seq { \tl_if_in:nnT {##2} { \__nswexam_correct_mark: } { \int_set:Nn \l__nswexam_correct_int {##1} } } \int_compare:nNnT { \l__nswexam_correct_int } = { 0 } { \ClassWarningNoLine { nswexam } { Question~\int_use:N \c@question\space has~no~\string\CorrectChoice } } \nswexam@writeaux { \token_to_str:N \nswexam@aux@answer { \int_use:N \c@question } { \int_use:N \l__nswexam_correct_int } { \seq_count:N \l__nswexam_items_seq } } \int_compare:nNnTF {#1} > { 1 } { \__nswexam_grid:n {#1} } { \begin{nswexam@listchoices} #2 \end{nswexam@listchoices} } } \cs_new_protected:Npn \__nswexam_grid:n #1 { \par \noindent \begin{minipage}{\linewidth} % one block, so the grid never splits \dim_set:Nn \l__nswexam_cell_dim { \linewidth / #1 - 1em } \noindent \seq_map_indexed_inline:Nn \l__nswexam_items_seq { \__nswexam_grid_cell:nn {##1} {##2} \int_compare:nNnTF { \int_mod:nn {##1} {#1} } = { 0 } { \int_compare:nNnF {##1} = { \seq_count:N \l__nswexam_items_seq } { \par \vspace{1.5em} \noindent } } { \hfill } } \end{minipage} \par } \cs_new_protected:Npn \__nswexam_grid_cell:nn #1#2 { \begin{minipage}[t]{\l__nswexam_cell_dim} \vspace{0pt} \legacy_if:nT { printanswers } { \tl_if_in:nnT {#2} { \__nswexam_correct_mark: } { \color{red} \bfseries } } \makebox[2em][l]{ \int_to_Alph:n {#1} . } \begin{minipage}[t]{ \dim_eval:n { \linewidth - 2em } } \vspace{0pt} #2 \end{minipage} \end{minipage} } \ExplSyntaxOff %% ------------------------------------------------------------- sections \newcounter{nswexam@section} \newif\ifnswexam@inmc \newif\ifnswexam@inwritten \newif\ifnswexam@hasmc \newif\ifnswexam@firstq \newif\ifnswexam@contnotes % "continues on page" notes: written paper only \newcount\nswexam@writtencount \newcommand\nswexam@sectionrule{\par\medskip\hrule height 1pt\bigskip} \newcommand\nswexam@label[1]{% \edef\nswexam@tmp{nswexam:s\the\c@nswexam@section:#1}% \expandafter\label\expandafter{\nswexam@tmp}} \newcommand\nswexam@ifallowtime[2]{\if\relax\detokenize{#1}\relax\else#2\fi} % Student number (boxes or a line) and class, right-aligned. \newcommand\nswexam@boxes[1]{\tikz[baseline=0.2cm]{% \foreach \i in {1,...,#1} \draw (\i*0.7-0.7,0) rectangle ++(0.7,0.7);}} \newcommand\nswexam@studentinfo{% {\raggedleft Student \nswexam@val{studentid}:\ \ifnum\nswexam@val{studentboxes}>0 \nswexam@boxes{\nswexam@val{studentboxes}}% \else\rule{6cm}{0.5pt}\fi\par\vspace{0.8em} \nswexam@val{classlabel}: \rule{6cm}{0.5pt}\par}} % "Section II" or "Sections II--IV", for instructions. \newcommand\nswexam@writtenphrase{% \ifnum\nswexam@auxval{writtencount}{1}>1 Sections \nswexam@auxval{writtenfirst}{II}--\nswexam@auxval{writtenlast}{II}% \else Section \nswexam@auxval{writtenfirst}{II}\fi} % \nswexam@startsection{numeral}{time}{1 = multiple choice, 0 = written} \newcommand\nswexam@startsection[3]{% \clearpage \stepcounter{nswexam@section}% \nswexam@writeaux{\string\nswexam@aux@sec{\the\c@nswexam@section}% {\unexpanded{#1}}{\number\numexpr\c@question+1\relax}{\unexpanded{#2}}}% \ifnum#3=1 \global\nswexam@inmctrue\global\nswexam@inwrittenfalse \global\nswexam@hasmctrue \global\nswexam@contnotesfalse \nswexam@mcstyle \else \global\nswexam@inmcfalse\global\nswexam@inwrittentrue \ifnum\nswexam@writtencount=0 \nswexam@writeaux{\gdef\string\nswexam@aux@writtenfirst{\unexpanded{#1}}}% \nswexam@writeaux{\gdef\string\nswexam@aux@writtenfirstq{% \number\numexpr\c@question+1\relax}}% \fi \global\advance\nswexam@writtencount by 1 \nswexam@writeaux{\gdef\string\nswexam@aux@writtenlast{\unexpanded{#1}}}% \ifnswexam@answers\global\nswexam@contnotesfalse \else\global\nswexam@contnotestrue\fi \nswexam@writtenstyle \fi \xdef\nswexam@sectionfirstq{\number\numexpr\c@question+1\relax}% \gdef\nswexam@currentnum{#1}% \global\nswexam@firstqtrue \nswexam@label{start}% \ifnswexam@inwritten\ifnswexam@answers\else \nswexam@ifbool{sectiondetails}{\nswexam@studentinfo\vspace{1em}}{}% \fi\fi \ifnum\nswexam@nsec=1 \else{\Large\bfseries Section #1\par}\fi \textbf{\nswexam@smarks{\the\c@nswexam@section}\ \nswexam@markword{\nswexam@smarks{\the\c@nswexam@section}}\\ Attempt Questions \nswexam@sfirst{\the\c@nswexam@section}--% \nswexam@slast{\the\c@nswexam@section}% \nswexam@ifallowtime{#2}{\\Allow about #2 for this section}}\par \ifnswexam@answers\else \ifnswexam@inmc Use the multiple-choice answer sheet for Questions \nswexam@sfirst{\the\c@nswexam@section}--% \nswexam@slast{\the\c@nswexam@section}.\par \else \nswexam@ifbool{booklets} {Answer each question in the appropriate writing booklet. Extra writing booklets are available.\par} {Answer the questions in the spaces provided. These spaces provide guidance for the expected length of response.\par}% \ifnswexam@hasmc For questions in Section #1, your\else Your\fi\ responses should include relevant mathematical reasoning and/or calculations.\par \ifnum\nswexam@auxval{extra}{0}=1 Extra writing space is provided at the back of this paper. If you use this space, clearly indicate which question you are answering.\par \fi \fi \fi \nswexam@sectionrule} \NewDocumentCommand\sectionone{O{\nswexam@val{sectiononetime}}}{% \nswexam@startsection{I}{#1}{1}} \NewDocumentCommand\examsection{O{} m}{% \nswexam@startsection{#2}{#1}{0}} \NewDocumentCommand\sectiontwo{O{\nswexam@val{sectiontwotime}}}{% \nswexam@startsection{II}{#1}{0}} % Before every \question: reset vectors; in a written section using % booklets, each question after the first ends and starts a new page. \newcommand\nswexam@endnote[1]{% \ifnswexam@answers\else\par\vspace{1.5em}{\centering\bfseries #1\par}\fi} \newcommand\nswexam@beforequestion{% \nswexam@resetvectors \ifnswexam@firstq\global\nswexam@firstqfalse \else\ifnswexam@inwritten\nswexam@ifbool{booklets} {\nswexam@endnote{End of Question \thequestion}\clearpage}{}\fi \fi} % exam.cls restarts numbering at each questions environment; carry it on so % each section follows the one before. \let\nswexam@questions\questions \def\questions{% \edef\nswexam@savedquestion{\the\value{question}}% \nswexam@questions \setcounter{question}{\nswexam@savedquestion}% \let\nswexam@question\question \def\question{\nswexam@beforequestion\nswexam@question}} \AtEndEnvironment{questions}{% \nswexam@label{end}% \ifnswexam@inwritten \ifnum\c@nswexam@section<\nswexam@nsec\relax \nswexam@ifbool{booklets} {\nswexam@endnote{End of Question \thequestion}} {\nswexam@endnote{End of Section \nswexam@currentnum}}% \else \nswexam@endnote{End of paper}% \fi \fi \ifnswexam@inmc \ifnum\nswexam@sumpoints{\nswexam@sectionfirstq}{\value{question}}=% \numexpr\value{question}-\nswexam@sectionfirstq+1\relax\else \ClassWarningNoLine{nswexam}{Multiple choice questions should be worth 1 mark each: write \string\question[1]}% \fi \fi} \AtEndDocument{% \nswexam@writeaux{\gdef\string\nswexam@aux@nsec{\the\c@nswexam@section}}% \nswexam@writeaux{\gdef\string\nswexam@aux@writtencount{% \the\nswexam@writtencount}}% \ifnswexam@hasmc\nswexam@writeaux{\gdef\string\nswexam@aux@hasmc{1}}\fi \nswexam@ifempty{expectedmarks}{}{% \ifnum\nswexam@numpoints=\nswexam@val{expectedmarks}\relax\else \ClassWarningNoLine{nswexam}{The paper totals \nswexam@numpoints\space marks, not \nswexam@val{expectedmarks}}% \fi}} %% ---------------------------------------------------- headers, footers \pagestyle{headandfoot} \newcommand\nswexam@footertext{% \nswexam@ifempty{footer} {\nswexam@ifempty{institution}{} {\textcopyright\ \nswexam@val{institution}, \nswexam@val{year}}} {\nswexam@val{footer}}} % No "continues" note on the page where a section's questions end. \newcommand\nswexam@sectionendpage{% \getpagerefnumber{nswexam:s\the\c@nswexam@section:end}} \newcommand\nswexam@footer{\parbox[t]{\textwidth}{\centering \ifnswexam@contnotes\ifnum\value{page}=\nswexam@sectionendpage\relax\else \ifincomplete{\textbf{Question \IncompleteQuestion\ continues on page \the\numexpr\value{page}+1\relax}\\[3pt]}{}\fi\fi -- \thepage\ --\\ {\scriptsize\itshape\nswexam@footertext\par}}} \firstpageheader{}{}{} \firstpagefooter{}{}{} \runningheader{\ifnswexam@contnotes\ifcontinuation{\textbf{Question \ContinuedQuestion\ (continued)}}{}\fi}{}{} \runningfooter{}{\nswexam@footer}{} %% ----------------------------------------------------------- the cover \newcommand\nswexam@logo{% \nswexam@ifempty{logo} {\nswexam@ifempty{institution}{}{{\Large\bfseries\nswexam@val{institution}\par}}} {{\nswexam@val{logo}\par}}} \newcommand\nswexam@yearbox{% {\setlength{\fboxsep}{0.5em}\setlength{\fboxrule}{0.5pt}% \fbox{\textbf{\huge\nswexam@val{year}}}\ \textbf{\MakeUppercase{\nswexam@val{exam}}}\par}} % A two-column block: rule and bold label on the left, content on the right. \newenvironment{nswexam@block}[1]{% \par\noindent \begin{minipage}[t]{3cm}\raggedright \vspace{-1.3em}\rule{2.9cm}{0.5pt}\par\textbf{#1}% \end{minipage}% \begin{minipage}[t]{\dimexpr\linewidth-3cm\relax}% \setlist[itemize]{label={\tiny$\bullet$}, itemsep=0.1em, leftmargin=1em, topsep=0.3em, after=\vspace{0.4em}}} {\end{minipage}\par\vspace{1.5em}} % "page 3" or "pages 3--7", from two labels \newcommand\nswexam@pages[2]{% \ifnum\getpagerefnumber{#1}=\getpagerefnumber{#2}\relax page \getpagerefnumber{#1}% \else pages \getpagerefnumber{#1}--\getpagerefnumber{#2}% \fi} % One section on the cover. \newcommand\nswexam@coversection[1]{% \ifnum\nswexam@nsec>1 \textbf{Section \nswexam@sfield{#1}{num} -- \nswexam@smarks{#1}\ \nswexam@markword{\nswexam@smarks{#1}}}% \else \textbf{Questions \nswexam@sfirst{#1}--\nswexam@slast{#1} -- \nswexam@smarks{#1}\ \nswexam@markword{\nswexam@smarks{#1}}}% \fi \ (\nswexam@pages{nswexam:s#1:start}{nswexam:s#1:end}) \begin{itemize} \item Attempt Questions \nswexam@sfirst{#1}--\nswexam@slast{#1} \nswexam@ifstime{#1}{\item Allow about \nswexam@sfield{#1}{time} for this section} \end{itemize}} % All written sections together, when `written sections time' is set. \newcommand\nswexam@coverwritten{% \textbf{\nswexam@writtenphrase\ -- \nswexam@writtenmarks\ marks} (\nswexam@pages{nswexam:s\nswexam@firstwrittenidx:start} {nswexam:s\nswexam@nsec:end}) \begin{itemize} \item Attempt Questions \nswexam@auxval{writtenfirstq}{1}--\nswexam@numquestions \item Allow about \nswexam@val{writtentime} for these sections \end{itemize}} \newcommand\nswexam@firstwrittenidx{\ifnum\nswexam@auxval{hasmc}{0}=1 2\else 1\fi} \ExplSyntaxOn \cs_new_protected:Npn \nswexam@coversections { \bool_lazy_and:nnTF { ! \tl_if_empty_p:N \l__nswexam_writtentime_tl } { \int_compare_p:nNn { \nswexam@auxval { writtencount } { 0 } } > { 1 } } { \int_compare:nNnT { \nswexam@auxval { hasmc } { 0 } } = { 1 } { \nswexam@coversection { 1 } } \nswexam@coverwritten } { \int_step_inline:nn { \nswexam@nsec } { \nswexam@coversection {##1} } } } \ExplSyntaxOff \NewDocumentCommand\makecover{}{% \DraftwatermarkOptions{stamp=false}% \begingroup \nswexam@sans \noindent \begin{minipage}[t]{0.4\linewidth}\vspace{0pt}\nswexam@logo\end{minipage}% \hfill \begin{minipage}[t]{0.6\linewidth}\vspace{0pt}% \ifnswexam@answers\else\nswexam@studentinfo\fi \end{minipage}\par \vspace{1.5em} \nswexam@yearbox \vspace{0.5em} {\fontsize{34}{40}\selectfont\nswexam@val{course}\par}% \nswexam@ifempty{subtitle} {\ifnswexam@answers\vspace{0.3em}{\huge Solutions\par}\fi} {\vspace{0.3em}{\huge\nswexam@val{subtitle}\par}}% \vspace{1.5em} \ifnswexam@answers \vfill \nswexam@ifempty{comments}{}{% \begin{nswexam@block}{General Comments} \nswexam@val{comments} \end{nswexam@block}}% \else \begin{nswexam@block}{General Instructions} \begin{itemize} \item Reading time -- \nswexam@val{readingtime} \item Working time -- \nswexam@val{workingtime} \item Write using black pen \nswexam@ifbool{calculators}{\item Calculators approved by NESA may be used}{} \nswexam@ifempty{referencesheet}{}{\item A reference sheet is provided at the back of this paper} \item \ifnum\nswexam@auxval{hasmc}{0}=1 For questions in \nswexam@writtenphrase, show\else Show\fi\ relevant mathematical reasoning and/or calculations \item Write your Student \nswexam@val{studentid} and \nswexam@val{classlabel} at the top of this page% \nswexam@ifbool{sectiondetails}{ and of each section}{} \end{itemize} \end{nswexam@block} \begin{nswexam@block}{Total marks: \nswexam@numpoints} \nswexam@coversections \end{nswexam@block} \fi \endgroup \clearpage \nswexam@ifempty{copyright}{}{% \vspace*{\fill}{\small\itshape\nswexam@val{copyright}\par}\clearpage}% \nswexam@ifempty{watermark}{}{\DraftwatermarkOptions{stamp=true}}} \AtBeginDocument{% \nswexam@ifempty{watermark}{}{% \DraftwatermarkOptions{angle=60, scale=0.8, colorspec=0.94, stamp=true}% \SetWatermarkText{\nswexam@sans\nswexam@val{watermark}}}% \hypersetup{pdftitle={\nswexam@val{year}\space\nswexam@val{course}\space \nswexam@val{exam}}}} %% ------------------------------------------------- back of the paper \NewDocumentCommand\extrawritingspace{O{1}}{% \nswexam@writeaux{\gdef\string\nswexam@aux@extra{1}}% \ifprintanswers\else \clearpage\global\nswexam@contnotesfalse \nswexam@replicate{#1}{% \clearpage {\large\bfseries Extra writing space\par} \textbf{If you use this space, clearly indicate which question you are answering.}\par\medskip \fillwithdottedlines{\stretch{1}}}% \clearpage \fi} % Multiple choice answer sheet for Section I; shaded with answers. \newcommand\nswexam@bubble[2]{% letter number, shade (1 or 0) \ifnum#2=1 \def\nswexam@fill{black!35}\else\def\nswexam@fill{white}\fi \tikz[baseline=(b.base)]\node[draw, ellipse, minimum width=1.1cm, minimum height=0.6cm, inner sep=0pt, fill=\nswexam@fill] (b) {\small\@Alph{#1}};} \NewDocumentCommand\mcanswersheet{}{% \clearpage\global\nswexam@contnotesfalse \DraftwatermarkOptions{stamp=false}% \begingroup \nswexam@sans \nswexam@studentinfo \vspace{2em} {\footnotesize\nswexam@yearbox}\vspace{0.3em} {\Large\bfseries\nswexam@val{course}\par} {\Large\bfseries Multiple-choice answer sheet\par} \vspace{1.5em} Select the alternative A, B, C or D that best answers the question. Fill in the response oval completely.\par \vspace{2em} \ifnum\nswexam@auxval{hasmc}{0}=1 \edef\nswexam@a{\nswexam@sfirst{1}}% \edef\nswexam@b{\nswexam@slast{1}}% \foreach \q in {\nswexam@a,...,\nswexam@b}{% \edef\nswexam@n{\ifcsname nswexam@ans@\q @n\endcsname \csname nswexam@ans@\q @n\endcsname\else 4\fi}% \edef\nswexam@c{\ifcsname nswexam@ans@\q @c\endcsname \csname nswexam@ans@\q @c\endcsname\else 0\fi}% \noindent\hspace{3cm}\makebox[2em][r]{\textbf{\q}}\hspace{1.5em}% \foreach \k in {1,...,\nswexam@n}{% \def\nswexam@shade{0}% \ifprintanswers\ifnum\k=\nswexam@c\relax\def\nswexam@shade{1}\fi\fi \nswexam@bubble{\k}{\nswexam@shade}\hspace{0.8em}}% \par\vspace{0.7em}}% \fi \endgroup \clearpage \nswexam@ifempty{watermark}{}{\DraftwatermarkOptions{stamp=true}}} \AtEndDocument{% \ifnswexam@answers\else\nswexam@ifempty{referencesheet}{}{% \clearpage\global\nswexam@contnotesfalse \DraftwatermarkOptions{stamp=false}% \IfFileExists{\nswexam@val{referencesheet}} {\includepdf[pages=-]{\nswexam@val{referencesheet}}} {\thispagestyle{empty}\vspace*{\fill} \begin{center}\nswexam@sans{\Large\bfseries Reference sheet}\par \medskip Attach the NESA reference sheet here.\end{center} \vspace*{\fill}}}\fi} %% --------------------------------------------------------------- extras \NewDocumentCommand\blankpage{}{% \clearpage\vspace*{\fill}\begin{center}BLANK PAGE\end{center}% \vspace*{\fill}\clearpage} \newcommand\contributor[2]{#1 & #2 \\ \hline} \newenvironment{contributors} {\clearpage\global\nswexam@contnotesfalse \DraftwatermarkOptions{stamp=false}\vspace*{\fill} \center\def\arraystretch{1.5}% \center, not \begin{center}: tabularx \tabularx{0.7\textwidth}{@{}X@{\hspace{1.5em}}X@{}}% needs this name \textbf{Contributors} & \textbf{Affiliation} \\ \hline} {\endtabularx\endcenter\vspace*{\fill}\clearpage}% ship inside the group, unstamped \endinput