| 1 |
%\iffalse |
| 2 |
% kfupm-math-exam.dtx generated using makedtx version 1.2 (c) Nicola Talbot |
| 3 |
% Command line args: |
| 4 |
% -src "kfupm-math-exam\.cls=>kfupm-math-exam.cls" |
| 5 |
% -doc "kfupm-math-exam.tex" |
| 6 |
% kfupm-math-exam |
| 7 |
% Created on 2022/7/25 6:06 |
| 8 |
%\fi |
| 9 |
%\iffalse |
| 10 |
%<*package> |
| 11 |
%% \CharacterTable |
| 12 |
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 13 |
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 14 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 15 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 16 |
%% Dollar \$ Percent \% Ampersand \& |
| 17 |
%% Acute accent \' Left paren \( Right paren \) |
| 18 |
%% Asterisk \* Plus \+ Comma \, |
| 19 |
%% Minus \- Point \. Solidus \/ |
| 20 |
%% Colon \: Semicolon \; Less than \< |
| 21 |
%% Equals \= Greater than \> Question mark \? |
| 22 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 23 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 24 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 25 |
%% Right brace \} Tilde \~} |
| 26 |
%</package> |
| 27 |
%\fi |
| 28 |
% \iffalse |
| 29 |
% Doc-Source file to use with LaTeX2e |
| 30 |
% Copyright (C) 2022 Mohammed Alshahrani, all rights reserved. |
| 31 |
% \fi |
| 32 |
% \iffalse |
| 33 |
%<*driver> |
| 34 |
\documentclass{article} |
| 35 |
\usepackage[utf8]{inputenc} |
| 36 |
|
| 37 |
\title{KFUP MATH EXAM \\ |
| 38 |
{\large version 0.1.0}} |
| 39 |
\author{ Mohammed Alshahrani} |
| 40 |
\date{July 2022} |
| 41 |
|
| 42 |
\begin{document} |
| 43 |
\DocInput{kfupm-math-exam.dtx} |
| 44 |
\end{document} |
| 45 |
%</driver> |
| 46 |
%\fi |
| 47 |
% |
| 48 |
%\maketitle |
| 49 |
% |
| 50 |
%\section{Usage} |
| 51 |
%\begin{verbatim} |
| 52 |
%\documentclass[ |
| 53 |
% % all of the below options are optional and can be left out |
| 54 |
% % course name |
| 55 |
% course = {{MATH333: Methods of Applied Mathematics I}}, |
| 56 |
% % quartile (default: 3) |
| 57 |
% quartile = {{}}, |
| 58 |
% % assignment number/name (default: 1) |
| 59 |
% examtitle = {{Exam 1}},%Monday, %Wednesday, |
| 60 |
% examdate = {{Monday March 1, 2022}}, |
| 61 |
% topic = {{}}, |
| 62 |
% dept= {{/MATH}}, |
| 63 |
% numofquestions=20, |
| 64 |
% numofversions=4, |
| 65 |
% numofoptions=5, |
| 66 |
% firstexercise = 1, |
| 67 |
% term = {{Term 213}}, |
| 68 |
% betweenquestions=4.5cm |
| 69 |
%]{kfupm-math-exam} |
| 70 |
% |
| 71 |
% |
| 72 |
%\instructions{ |
| 73 |
%\underline{\large{\bf Important Instructions:}} |
| 74 |
%\begin{enumerate} |
| 75 |
% \begin{normalsize} |
| 76 |
% \item Instruction 1 |
| 77 |
% \item Instruction 2 |
| 78 |
% \item Instruction 3 |
| 79 |
% \item Instruction 4 |
| 80 |
% \item Instruction 5 |
| 81 |
% |
| 82 |
% \end{normalsize} |
| 83 |
%\end{enumerate} |
| 84 |
%} |
| 85 |
% |
| 86 |
%\begin{document} |
| 87 |
% |
| 88 |
% |
| 89 |
% |
| 90 |
%\versioncover{1} |
| 91 |
% |
| 92 |
%\newpage |
| 93 |
% |
| 94 |
%\begin{itemize} |
| 95 |
% \item i |
| 96 |
% |
| 97 |
%\end{itemize} |
| 98 |
% |
| 99 |
%\newpage |
| 100 |
%\versioncover{12} |
| 101 |
% |
| 102 |
%\newpage |
| 103 |
% |
| 104 |
% |
| 105 |
%\end{document} |
| 106 |
%\end{verbatim} |
| 107 |
% |
| 108 |
% |
| 109 |
%\StopEventually{} |
| 110 |
%\section{The Code} |
| 111 |
%\iffalse |
| 112 |
% \begin{macrocode} |
| 113 |
%<*kfupm-math-exam.cls> |
| 114 |
% \end{macrocode} |
| 115 |
%\fi |
| 116 |
% kfupm-math-exam.cls |
| 117 |
% Department of Mathematics |
| 118 |
% King Fahd University of Petroleum and Minerals |
| 119 |
% A LaTeX2e document class for preparing the exams of the department of mathematics, KFUPM. |
| 120 |
|
| 121 |
% --- METADATA ----------------------------------------------------------------- |
| 122 |
\def\fileversion{0.1.0} |
| 123 |
\def\filedate{2022/07/25} |
| 124 |
\NeedsTeXFormat{LaTeX2e} |
| 125 |
\ProvidesClass{kfupm-math-exam}[\filedate\space Version \fileversion\space by |
| 126 |
Department of Mathematics, KFUPM] |
| 127 |
% --- OPTION PROCESSSING ------------------------------------------------------- |
| 128 |
\RequirePackage{kvoptions} \SetupKeyvalOptions{ |
| 129 |
family = kfupmmathexam, |
| 130 |
prefix = kfupmmathexam@, |
| 131 |
setkeys = \kvsetkeys |
| 132 |
} |
| 133 |
\DeclareStringOption[212]% |
| 134 |
{term} |
| 135 |
\DeclareStringOption[Exam]% |
| 136 |
{topic} |
| 137 |
\DeclareStringOption[King Fahd University of Petroleum \& Minerals]% |
| 138 |
{university} |
| 139 |
\DeclareStringOption[Department of Mathematics]% |
| 140 |
{dept} |
| 141 |
\DeclareStringOption[MATH101 CALCULUS I]% |
| 142 |
{course} |
| 143 |
\DeclareStringOption[3]% |
| 144 |
{quartile} |
| 145 |
\DeclareStringOption[1]% |
| 146 |
{examtitle} |
| 147 |
\DeclareStringOption[March 9, 2022]% |
| 148 |
{examdate} |
| 149 |
\DeclareStringOption[4]% |
| 150 |
{numofversions} |
| 151 |
\DeclareStringOption[15]% |
| 152 |
{numofquestions} |
| 153 |
\DeclareStringOption[5]% |
| 154 |
{numofoptions} |
| 155 |
\DeclareStringOption[0123456]% |
| 156 |
{studentnumber} |
| 157 |
\DeclareStringOption[[email protected]]% |
| 158 |
{email} |
| 159 |
\DeclareStringOption[1]% |
| 160 |
{firstexercise} |
| 161 |
\DeclareStringOption[3.5cm]{betweenquestions} |
| 162 |
\DeclareStringOption[0.762cm]{spaceafterbody} |
| 163 |
\DeclareStringOption[0.5cm]{betweenoptions} |
| 164 |
% pass unrecognized options to `article` class |
| 165 |
\DeclareDefaultOption{% |
| 166 |
\PassOptionsToClass{\CurrentOption}{article}% |
| 167 |
} |
| 168 |
% process all options |
| 169 |
\ProcessKeyvalOptions{kfupmmathexam} |
| 170 |
% load parent class with some default options |
| 171 |
\LoadClass[a4paper, 12pt]{article} |
| 172 |
% --- PACKAGES AND SETUP ------------------------------------------------------- |
| 173 |
\RequirePackage[ |
| 174 |
paperheight=33cm, |
| 175 |
paperwidth=21.5cm, |
| 176 |
headheight = 20pt, |
| 177 |
margin = 2cm, |
| 178 |
tmargin = \dimexpr 2cm - 10pt \relax, |
| 179 |
]{geometry} % set up nicer margins |
| 180 |
\addtolength{\footskip}{20pt} |
| 181 |
\RequirePackage{fancyhdr} % for headers and footers |
| 182 |
\RequirePackage{graphicx} % for including figures |
| 183 |
\RequirePackage{amsmath} % use AMS math package |
| 184 |
\RequirePackage{amssymb} % use AMS symbols |
| 185 |
\RequirePackage{amsthm} % for writing proofs |
| 186 |
\RequirePackage{array} % for setting up arguments to columns |
| 187 |
\RequirePackage{booktabs} % for professional tables |
| 188 |
\RequirePackage% |
| 189 |
[tworuled, linesnumbered, noend, noline]% |
| 190 |
{algorithm2e} % for typesetting pseudo-code |
| 191 |
\RequirePackage{xcolor} % for colored text (comments in algorithms) |
| 192 |
\RequirePackage{trimspaces, xstring} % for multiple author parsing |
| 193 |
\RequirePackage[shortlabels]{enumitem} \labelsep=.75cm |
| 194 |
\RequirePackage{mathrsfs} |
| 195 |
\RequirePackage{xparse} |
| 196 |
\RequirePackage{environ} |
| 197 |
\RequirePackage{pgfplots} |
| 198 |
\pgfplotsset{compat=newest} |
| 199 |
\RequirePackage{tcolorbox} |
| 200 |
|
| 201 |
% option post-processing |
| 202 |
\newcommand{\kme@temp}{} |
| 203 |
\newcommand{\kme@sub}[4]{% |
| 204 |
\ifnum#3 = 1\relax% |
| 205 |
\ifnum#4 = 1\relax% |
| 206 |
\renewcommand{\kme@temp}{#1}% |
| 207 |
\else% |
| 208 |
\StrBefore{#1}{#2}[\kme@temp]% |
| 209 |
\fi% |
| 210 |
\else% |
| 211 |
\ifnum#3 = #4\relax% |
| 212 |
\StrBehind[\numexpr#3 - 1\relax]{#1}{#2}[\kme@temp]% |
| 213 |
\else% |
| 214 |
\StrBetween[\numexpr#3 - 1\relax,#3]{#1}{#2}{#2}[\kme@temp]% |
| 215 |
\fi% |
| 216 |
\fi% |
| 217 |
\expandafter\trim@spaces\expandafter{\kme@temp}% |
| 218 |
} |
| 219 |
\newcommand{\kme@authorProcessed}[1]{% |
| 220 |
\kme@sub{\kfupmmathexam@name}{;}{#1}{\arabic{kme@numAuthors}}~% |
| 221 |
(\kme@sub{\kfupmmathexam@studentnumber}{;}{#1}{\arabic{kme@numAuthors}})\\% |
| 222 |
\texttt{\kme@sub{\kfupmmathexam@email}{;}{#1}{\arabic{kme@numAuthors}}}% |
| 223 |
% if there are more authors, do a recursive call for the next one |
| 224 |
\ifnum#1 < \arabic{kme@numAuthors}\relax\and\kme@authorProcessed{\numexpr#1 + 1\relax}\fi% |
| 225 |
} |
| 226 |
\newcommand{\kme@authorsProcessed}{% |
| 227 |
% count number of authors; one more than number of semicolons |
| 228 |
\StrCount{\kfupmmathexam@name}{;}[\kme@numAuthors]% |
| 229 |
\newcounter{kme@numAuthors}% |
| 230 |
\setcounter{kme@numAuthors}{\kme@numAuthors}% |
| 231 |
\stepcounter{kme@numAuthors}% |
| 232 |
% produce output |
| 233 |
\kme@authorProcessed{1}% |
| 234 |
} |
| 235 |
% look for figures in the figures directory |
| 236 |
\graphicspath{{figures/}} |
| 237 |
% set up headers and footers; same for all pages |
| 238 |
\setlength{\headheight}{10pt} |
| 239 |
\newcommand{\kfupmmathexam@setupHF}{% |
| 240 |
\fancyhf{} |
| 241 |
\fancyhead[L]{\sffamily \small KFUPM } |
| 242 |
\fancyhead[C]{\sffamily Page \thepage ~of \pageref{LastPage}} |
| 243 |
\fancyhead[R]{\sffamily Term \kfupmmathexam@term} |
| 244 |
\fancyfoot[L]{\sffamily /\kfupmmathexam@dept} |
| 245 |
\fancyfoot[R]{\sffamily\bfseries\thepage} |
| 246 |
\renewcommand{\headrulewidth}{0.5pt} |
| 247 |
\renewcommand{\footrulewidth}{0.5pt} |
| 248 |
} |
| 249 |
\fancypagestyle{plain}{\kfupmmathexam@setupHF{}} \kfupmmathexam@setupHF{} |
| 250 |
\pagestyle{fancy} |
| 251 |
\NewDocumentCommand{\coverpage}{O{\kfupmmathexam@course} O{\kfupmmathexam@examtitle} O{\kfupmmathexam@term} O{\kfupmmathexam@examdate}}{% |
| 252 |
\thispagestyle{empty} |
| 253 |
\begin{center} |
| 254 |
\begin{large} |
| 255 |
Kink Fahd University of Petroleum and Minerals\\ |
| 256 |
Mathematics\\ |
| 257 |
\vspace*{2cm} |
| 258 |
{\bf #1} \\ |
| 259 |
{\bf #2} \\ |
| 260 |
{\bf #3} \\ |
| 261 |
{\bf #4} \\ |
| 262 |
|
| 263 |
\vspace*{3cm} |
| 264 |
{\bf{\Huge{\fbox{EXAM COVER }}}}\\ |
| 265 |
\vspace*{2cm} |
| 266 |
{\bf Number of versions: \kfupmmathexam@numofversions } \\ |
| 267 |
{\bf Number of questions: \kfupmmathexam@numofquestions } \\ |
| 268 |
{\bf Number of Answers: \kfupmmathexam@numofoptions } \\ |
| 269 |
|
| 270 |
\vspace*{0.2cm} |
| 271 |
|
| 272 |
\end{large} |
| 273 |
|
| 274 |
\vfill |
| 275 |
|
| 276 |
\tiny{This exam was prepared using EXAM SHUFFLER} |
| 277 |
\tiny{For questions send an email to Dr. Mohammed Alshahrani ([email protected]) } |
| 278 |
\end{center} |
| 279 |
\newpage |
| 280 |
} |
| 281 |
\newcommand{\versioncover}[1]{ |
| 282 |
\thispagestyle{empty} |
| 283 |
\begin{center} |
| 284 |
\begin{large} |
| 285 |
Kink Fahd University of Petroleum and Minerals \\ |
| 286 |
Mathematics \\ |
| 287 |
\vspace*{4.5cm} |
| 288 |
{\bf \fbox{ \codestr{CODE}{#1} } } \hfill {\bf \fbox{ \codestr{CODE}{#1} }} \\ |
| 289 |
{\bf math333 } \\ |
| 290 |
{\bf exam 1 } \\ |
| 291 |
{\bf 182 } \\ |
| 292 |
{\bf monday march 13 } \\ |
| 293 |
{\bf Net Time Allowed: 120 minutes } \\ |
| 294 |
|
| 295 |
\vspace*{0.2cm} |
| 296 |
|
| 297 |
\end{large} |
| 298 |
\end{center} |
| 299 |
\ifthenelse{\equal{#1}{0}}{ |
| 300 |
\begin{center} |
| 301 |
\vspace*{6cm} |
| 302 |
{\bf {\Huge{MASTER VERSION}}} \\ |
| 303 |
\end{center} |
| 304 |
}{ |
| 305 |
\large{Name: }\hrulefill |
| 306 |
|
| 307 |
\vspace{3mm} |
| 308 |
|
| 309 |
\large{ID: } \hrulefill \large{ Sec: } \hrulefill \large{.} |
| 310 |
|
| 311 |
\vspace{1cm} |
| 312 |
|
| 313 |
\large{\bf{Check that this exam has {\underline{ \thenumberofquestions }} questions.}} |
| 314 |
|
| 315 |
\vspace{1cm} |
| 316 |
|
| 317 |
\getInstructions |
| 318 |
} |
| 319 |
\newpage |
| 320 |
|
| 321 |
\renewcommand{\thepage}{\noindent Term 182, math333, exam 1 \hfill Page {\bf \arabic{page} of \pagecount{\thenumberofpages} } \hfill {\bf \fbox{ \codestr{CODE}{#1} }}} |
| 322 |
\setcounter{page}{1} |
| 323 |
|
| 324 |
} |
| 325 |
% ensure that the title is inserted in the document |
| 326 |
\title{\coverpage} |
| 327 |
\author{} |
| 328 |
\date{} |
| 329 |
\AtBeginDocument{\pagestyle{myheadings}}%\maketitle |
| 330 |
|
| 331 |
% add some keywords |
| 332 |
\SetKw{And}{and} \SetKw{Or}{or} \SetKw{To}{to} |
| 333 |
% make it possible to not have line numbers on a single line |
| 334 |
\let\oldnl\nl |
| 335 |
\newcommand{\nonl}{\renewcommand{\nl}{\let\nl\oldnl}} |
| 336 |
% style algorithm captions |
| 337 |
\newcommand{\kfupmmathexam@capsty}[1]{\!} |
| 338 |
\SetAlCapSty{kfupmmathexam@capsty} \SetAlCapNameFnt{\scshape\hspace{.69em}} |
| 339 |
% get rid of semicolons |
| 340 |
\DontPrintSemicolon |
| 341 |
% comment formatting |
| 342 |
\newcommand\agacommfont[1]{\footnotesize\ttfamily\textcolor{gray}{#1}} |
| 343 |
\SetCommentSty{agacommfont} |
| 344 |
% --- USEFUL MACROS ------------------------------------------------------------ |
| 345 |
\newcommand*{\R}{{\mathbb R}} |
| 346 |
\newcommand*{\N}{{\mathbb N}} |
| 347 |
\newcommand*{\Z}{{\mathbb Z}} |
| 348 |
\newcommand*{\Q}{{\mathbb Q}} |
| 349 |
|
| 350 |
% lengths and commands of the exam options |
| 351 |
\newcount\numberofversions |
| 352 |
\numberofversions=\kfupmmathexam@numofversions |
| 353 |
\advance\numberofversions +1 |
| 354 |
\newcounter{numberofquestions} |
| 355 |
\setcounter{numberofquestions}{\kfupmmathexam@numofquestions} |
| 356 |
\newcounter{numberofpages} |
| 357 |
\setcounter{numberofpages}{0} |
| 358 |
% --- define new database for exam questions ---- |
| 359 |
\newcounter{examcodecounter} |
| 360 |
\setcounter{examcodecounter}{1} |
| 361 |
|
| 362 |
|
| 363 |
\ExplSyntaxOn |
| 364 |
\str_new:N \l_alphabets_str |
| 365 |
\str_set:Nn \l_alphabets_str {abcdefghigklmnopqrstuvwxuz} |
| 366 |
\newcommand{\instructions}[1]{ |
| 367 |
\tl_set:Nn \l_tmpa_str {#1} |
| 368 |
} |
| 369 |
\newcommand{\getInstructions}[1]{ |
| 370 |
\tl_use:N \l_tmpa_str |
| 371 |
} |
| 372 |
\int_new:N \l_tmppages_int |
| 373 |
\int_set:Nn \l_tmppages_int {0} |
| 374 |
\cs_set:Npn \l_calc_pages_int:n #1 { |
| 375 |
\int_set:Nn \l_tmppages_int {\int_div_truncate:nn {#1}{2}} |
| 376 |
\int_set:Nn \l_tmppages_int {\int_compare:nNnTF {0}={\int_mod:nn {#1}{2}}{\l_tmppages_int}{\l_tmppages_int+1}} |
| 377 |
\int_use:N \l_tmppages_int |
| 378 |
} |
| 379 |
\newcommand{\pagecount}[1]{ |
| 380 |
\l_calc_pages_int:n {15} |
| 381 |
} |
| 382 |
|
| 383 |
|
| 384 |
\str_new:N \l_exam_code_str |
| 385 |
\int_new:N \l_exam_version_int |
| 386 |
\cs_set:Npn \l_concat_codenumber_str:nn #1#2 { |
| 387 |
\int_set:Nn \l_exam_version_int {100+#2} |
| 388 |
\str_clear_new:N \l_partone_str |
| 389 |
\str_clear_new:N \l_parttwo_str |
| 390 |
\str_set:Nn \l_partone_str {#1} |
| 391 |
\str_set:Nx \l_parttwo_str {\int_use:N \l_exam_version_int} |
| 392 |
\str_set:Nx \l_parttwo_str {\str_range:Nnn \l_parttwo_str {-2}{-1}} |
| 393 |
\str_concat:NNN \l_exam_code_str \l_partone_str \l_parttwo_str |
| 394 |
\str_use:N \l_exam_code_str |
| 395 |
} |
| 396 |
\newcommand{\codestr}[2]{ |
| 397 |
\int_compare:nNnTF {0}={#2}{MASTER}{ |
| 398 |
\l_concat_codenumber_str:nn {#1}{#2} |
| 399 |
} |
| 400 |
} |
| 401 |
|
| 402 |
% working with list |
| 403 |
|
| 404 |
\ExplSyntaxOff |
| 405 |
%\iffalse |
| 406 |
% \begin{macrocode} |
| 407 |
%</kfupm-math-exam.cls> |
| 408 |
% \end{macrocode} |
| 409 |
%\fi |
| 410 |
%\Finale |
| 411 |
\endinput |