| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2022 by Alexander Bartolomey |
| 4 |
% ------------------------------------------- |
| 5 |
% MIT License |
| 6 |
% |
| 7 |
% Copyright (c) 2022 |
| 8 |
% |
| 9 |
% Permission is hereby granted, free of charge, to any person obtaining a copy |
| 10 |
% of this software and associated documentation files (the "Software"), to deal |
| 11 |
% in the Software without restriction, including without limitation the rights |
| 12 |
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 13 |
% copies of the Software, and to permit persons to whom the Software is |
| 14 |
% furnished to do so, subject to the following conditions: |
| 15 |
% |
| 16 |
% The above copyright notice and this permission notice shall be included in all |
| 17 |
% copies or substantial portions of the Software. |
| 18 |
% |
| 19 |
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 |
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 |
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 22 |
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 23 |
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 24 |
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 25 |
% SOFTWARE. |
| 26 |
% \fi |
| 27 |
% \iffalse |
| 28 |
%<*driver> |
| 29 |
\ProvidesFile{csassignments.dtx} |
| 30 |
%</driver> |
| 31 |
% \begin{macrocode} |
| 32 |
\NeedsTeXFormat{LaTeX2e} |
| 33 |
\ProvidesClass{csassignments}[2022/07/28 v1.0.2 Assignments Class for CS] |
| 34 |
% \end{macrocode} |
| 35 |
% |
| 36 |
%<*driver> |
| 37 |
\documentclass[a4paper]{ltxdoc} |
| 38 |
\EnableCrossrefs |
| 39 |
\CodelineIndex |
| 40 |
\RecordChanges |
| 41 |
\usepackage[utf8]{inputenc} |
| 42 |
\usepackage[T1]{fontenc} |
| 43 |
\usepackage{mathtools} |
| 44 |
\usepackage{amsmath} |
| 45 |
\usepackage{amssymb} |
| 46 |
\usepackage{url} |
| 47 |
\usepackage{helvet} |
| 48 |
\renewcommand{\familydefault}{\sfdefault} |
| 49 |
\begin{document} |
| 50 |
\DocInput{csassignments.dtx} |
| 51 |
\end{document} |
| 52 |
%</driver> |
| 53 |
% \end{macrocode} |
| 54 |
% \fi |
| 55 |
% |
| 56 |
% \CheckSum{574} |
| 57 |
% |
| 58 |
% \CharacterTable |
| 59 |
% {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 |
| 60 |
% 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 |
| 61 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 62 |
% Exclamation \! Double quote \" Hash (number) \# |
| 63 |
% Dollar \$ Percent \% Ampersand \& |
| 64 |
% Acute accent \' Left paren \( Right paren \) |
| 65 |
% Asterisk \* Plus \+ Comma \, |
| 66 |
% Minus \- Point \. Solidus \/ |
| 67 |
% Colon \: Semicolon \; Less than \< |
| 68 |
% Equals \= Greater than \> Question mark \? |
| 69 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 70 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 71 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 72 |
% Right brace \} Tilde \~} |
| 73 |
% |
| 74 |
% \changes{v1.0.0}{2022/06/01}{Publish class with documentation} |
| 75 |
% \changes{v1.0.1}{2022/06/07}{Rename class to not collide with existing assignments class} |
| 76 |
% \changes{v1.0.2}{2022/07/28}{Fix a bug where verb+\ClassWarning+ lacked the right number of arguments} |
| 77 |
% |
| 78 |
% \GetFileInfo{csassignments.cls} |
| 79 |
% |
| 80 |
% \title{The \texttt{csassignments} class} |
| 81 |
% \date{} |
| 82 |
% \author{Alexander Bartolomey} |
| 83 |
% \maketitle |
| 84 |
% \tableofcontents |
| 85 |
% |
| 86 |
% \StopEventually{} ^^A |
| 87 |
% |
| 88 |
% \section{Introduction} |
| 89 |
% |
| 90 |
% This class file is designed for assignments of university courses, specifically |
| 91 |
% in the field of computer science, but can easily be adapted to other fields. It |
| 92 |
% provides macros for counting exercise points, adding a grading table, a helpful |
| 93 |
% document title block including several non-standard information, and page |
| 94 |
% headers with compressed author details. |
| 95 |
% |
| 96 |
% It supports German and English language by default, by requirement of the |
| 97 |
% author's university. |
| 98 |
% |
| 99 |
% Additional to the layout utilities, the class provides several commonly used |
| 100 |
% macros for computer science topics, namely several mathematical operators, |
| 101 |
% mathmode utilities and special environments for proofs and theorem. Those are a |
| 102 |
% condensed version of macros defined in |
| 103 |
% \url{https://github.com/zoomoid/AlphabetClasses}. |
| 104 |
% |
| 105 |
% \section{Getting Started} |
| 106 |
% |
| 107 |
% Use the class like any default document class |
| 108 |
% |
| 109 |
% \begin{verbatim} |
| 110 |
% \documentclass[<option>]{csassignments} |
| 111 |
% |
| 112 |
% \course{} |
| 113 |
% \group{} |
| 114 |
% \due{} |
| 115 |
% |
| 116 |
% \member{}{}{} |
| 117 |
% % ... |
| 118 |
% |
| 119 |
% \begin{document} |
| 120 |
% \maketitle |
| 121 |
% \gradingtable |
| 122 |
% |
| 123 |
% \exercise[<Exercise Points>]{<Exercise Title>} |
| 124 |
% \subexercise{} |
| 125 |
% \end{document} |
| 126 |
% \end{verbatim} |
| 127 |
% |
| 128 |
% Because it inherits from \texttt{article}, you can pass down any options that |
| 129 |
% \texttt{article} understands. |
| 130 |
% |
| 131 |
% \section{Initial Code} |
| 132 |
% First, we define the document class and set some initial lengths. |
| 133 |
% \begin{macrocode} |
| 134 |
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} |
| 135 |
\ProcessOptions\relax |
| 136 |
\LoadClass[a4paper,11pt]{article} |
| 137 |
\makeatletter |
| 138 |
\setlength{\parindent}{0pt} |
| 139 |
\setlength{\parskip}{0.6em} |
| 140 |
% \end{macrocode} |
| 141 |
% |
| 142 |
% \section{Required Packages} |
| 143 |
% |
| 144 |
% Notably, the class introduces several dependencies. Here's a list of the |
| 145 |
% packages required by \texttt{csassignments}: |
| 146 |
% |
| 147 |
% \begin{description} |
| 148 |
% \item[geometry] \texttt{CTAN:macros/latex/contrib/geometry} |
| 149 |
% \item[inputenc] \texttt{CTAN:macros/latex/base} |
| 150 |
% \item[babel] \texttt{CTAN:macros/latex/required/babel/base} |
| 151 |
% \item[titlesec] \texttt{CTAN:macros/latex/contrib/titlesec} |
| 152 |
% \item[enumitem] \texttt{CTAN:macros/latex/contrib/enumitem} |
| 153 |
% \item[tocloft] \texttt{CTAN:macros/latex/contrib/tocloft} |
| 154 |
% \item[float] \texttt{CTAN:macros/latex/contrib/float} |
| 155 |
% \item[ifthen] \texttt{CTAN:macros/latex/base} |
| 156 |
% \item[translations] \texttt{CTAN:macros/latex/contrib/translations} |
| 157 |
% \item[csquotes] \texttt{CTAN:macros/latex/contrib/csquotes} |
| 158 |
% \item[fancyhdr] \texttt{CTAN:macros/latex/contrib/fancyhdr} |
| 159 |
% \item[microtype] \texttt{CTAN:macros/latex/contrib/microtype} |
| 160 |
% \item[stmaryrd] \texttt{CTAN:fonts/stmaryrd} |
| 161 |
% \item[graphicx] \texttt{CTAN:macros/latex/required/graphics} |
| 162 |
% \item[pdfpages] \texttt{CTAN:macros/latex/contrib/pdfpages} |
| 163 |
% \item[hyperref] \texttt{CTAN:macros/latex/contrib/hyperref} |
| 164 |
% \item[tikz] \texttt{CTAN:graphics/pgf/base} |
| 165 |
% \item[microtype] \texttt{CTAN:macros/latex/contrib/microtype} |
| 166 |
% \item[amsmath] \texttt{CTAN:macros/latex/required/amsmath} |
| 167 |
% \item[amsthm] \texttt{CTAN:macros/latex/required/amscls} |
| 168 |
% \item[amssymb] \texttt{CTAN:macros/latex/required/amscls} |
| 169 |
% \item[mathtools] \texttt{CTAN:macros/latex/contrib/mathtools} |
| 170 |
% \item[totcount] \texttt{CTAN:macros/latex/contrib/totcount} |
| 171 |
% \item[changepage] \texttt{CTAN:macros/latex/contrib/changepage} |
| 172 |
% \item[etoolbox] \texttt{CTAN:macros/latex/contrib/etoolbox} |
| 173 |
% \item[environ] \texttt{CTAN:macros/latex/contrib/environ} |
| 174 |
% \item[multicol] \texttt{CTAN:macros/latex/required/tools} |
| 175 |
% \item[tgpagella] \texttt{CTAN:fonts/tex-gyre} |
| 176 |
% \item[suffix] \texttt{CTAN:macros/latex/contrib/bigfoot} |
| 177 |
% \end{description} |
| 178 |
% |
| 179 |
% \begin{macrocode} |
| 180 |
\RequirePackage[left=2.5cm,right=2.5cm,top=2cm,bottom=2cm, |
| 181 |
includeheadfoot]{geometry} |
| 182 |
\RequirePackage[utf8]{inputenc} |
| 183 |
\RequirePackage[english]{babel} |
| 184 |
\RequirePackage{titlesec} |
| 185 |
\RequirePackage{enumitem} |
| 186 |
\RequirePackage{graphicx} |
| 187 |
\RequirePackage{tocloft} |
| 188 |
\RequirePackage{float} |
| 189 |
\RequirePackage{ifthen} |
| 190 |
\RequirePackage{translations} |
| 191 |
\RequirePackage{csquotes} |
| 192 |
\RequirePackage{fancyhdr} |
| 193 |
\RequirePackage{microtype} |
| 194 |
\RequirePackage{stmaryrd} |
| 195 |
\RequirePackage{pdfpages} |
| 196 |
\RequirePackage[hidelinks, unicode]{hyperref} |
| 197 |
\RequirePackage{tikz} |
| 198 |
\RequirePackage{microtype} |
| 199 |
\RequirePackage[fleqn]{amsmath} |
| 200 |
\RequirePackage{amsthm} |
| 201 |
\RequirePackage{amssymb} |
| 202 |
\RequirePackage{mathtools} |
| 203 |
\RequirePackage{totcount} |
| 204 |
\RequirePackage{changepage} |
| 205 |
\RequirePackage{etoolbox} |
| 206 |
\RequirePackage{environ} |
| 207 |
\RequirePackage{multicol} |
| 208 |
\RequirePackage{tgpagella} |
| 209 |
\RequirePackage{suffix} |
| 210 |
\usetikzlibrary{arrows,calc} |
| 211 |
% \end{macrocode} |
| 212 |
% |
| 213 |
% \section{Translations} |
| 214 |
% \texttt{csassignments} comes with several predefined prefixes that are localized in both |
| 215 |
% English and German: |
| 216 |
% \begin{macrocode} |
| 217 |
\DeclareLanguage{english} |
| 218 |
\DeclareLanguage{german} |
| 219 |
\select@language{english} |
| 220 |
\ProvideTranslation{german}{prefixAuthor}{Eingereicht von} |
| 221 |
\ProvideTranslation{english}{prefixAuthor}{Handed in by} |
| 222 |
\ProvideTranslationFallback{prefixAuthor}{Handed in by} |
| 223 |
\ProvideTranslation{german}{prefixDate}{am} |
| 224 |
\ProvideTranslation{english}{prefixDate}{on} |
| 225 |
\ProvideTranslationFallback{prefixDate}{on} |
| 226 |
\ProvideTranslation{ngerman}{exercise}{Aufgabe} |
| 227 |
\ProvideTranslation{english}{exercise}{Exercise} |
| 228 |
\ProvideTranslationFallback{exercise}{Exercise} |
| 229 |
\ProvideTranslation{ngerman}{exerciseAbbrev}{Aufg.} |
| 230 |
\ProvideTranslation{english}{exerciseAbbrev}{Ex.} |
| 231 |
\ProvideTranslationFallback{exerciseAbbrev}{Ex.} |
| 232 |
\ProvideTranslation{ngerman}{subexercise}{Teilaufgabe} |
| 233 |
\ProvideTranslation{english}{subexercise}{Subexercise} |
| 234 |
\ProvideTranslationFallback{subexercise}{Subexercise} |
| 235 |
\ProvideTranslation{ngerman}{points}{Punkte} |
| 236 |
\ProvideTranslation{english}{points}{Points} |
| 237 |
\ProvideTranslationFallback{points}{Points} |
| 238 |
\ProvideTranslation{ngerman}{sheet}{Abgabe} |
| 239 |
\ProvideTranslation{english}{sheet}{Exercise Sheet} |
| 240 |
\ProvideTranslationFallback{sheet}{Exercise Sheet} |
| 241 |
\ProvideTranslation{ngerman}{studentId}{Matr.Nr.} |
| 242 |
\ProvideTranslation{english}{studentId}{Student ID} |
| 243 |
\ProvideTranslationFallback{studentId}{Student ID} |
| 244 |
% \end{macrocode} |
| 245 |
% |
| 246 |
% \section{Grouping Exercises} |
| 247 |
% To support the grading table, we need to initialize several counters for both counting up |
| 248 |
% the awarded points of exercises but also for labels of exercises and subexercises. |
| 249 |
% \begin{macrocode} |
| 250 |
\newtotcounter{exercisenumber} |
| 251 |
\newtotcounter{subexercisenumber} |
| 252 |
\newtotcounter{totalpoints} |
| 253 |
\edef\exerciseLabelGradingTable{} |
| 254 |
\edef\gradingTableExercisePoints{} |
| 255 |
\edef\PTableA{} |
| 256 |
\edef\PTableB{} |
| 257 |
\edef\PTHead{} |
| 258 |
\newcommand{\@addPT}[2]{ |
| 259 |
\edef\gradingTableExerciseLabel{\GetTranslation{exerciseAbbrev} #1 &} |
| 260 |
\edef\gradingTableExercisePoints{\qquad / $#2$ &} |
| 261 |
\xappto\PTableA{\gradingTableExerciseLabel} |
| 262 |
\xappto\PTableB{\gradingTableExercisePoints} |
| 263 |
\xappto\PTHead{c | } |
| 264 |
} |
| 265 |
% \end{macrocode} |
| 266 |
% \begin{macro}{\gradingtable} |
| 267 |
% You can toggle the displaying of the grading table by adding \cmd{\gradingtable} at some point |
| 268 |
% in your document before the first exercise. It requires the compiler to run twice, in order |
| 269 |
% expand the control sequence created on the first run, where exercise labels and points were |
| 270 |
% appended in order to be combined in a subsequent run. |
| 271 |
% \begin{macrocode} |
| 272 |
\newcommand{\gradingtable}{% |
| 273 |
\ifdef{\PTHeadSaved}{% |
| 274 |
{\Large\bfseries Grading Table}\\% |
| 275 |
\begin{table}[h!] |
| 276 |
\renewcommand\arraystretch{2}% |
| 277 |
\begin{tabular}{\expandonce{\PTHeadSaved} c} |
| 278 |
\PTableASaved {\Large$\Sigma$}\\ \hline |
| 279 |
\PTableBSaved \qquad / $\totalpointsSaved$ |
| 280 |
\end{tabular} |
| 281 |
\renewcommand{\arraystretch}{1}% |
| 282 |
\end{table} |
| 283 |
}{\texttt{Compile again}\ClassWarning{csassignments}{Compile again to % |
| 284 |
properly display grading table}} |
| 285 |
} |
| 286 |
% \end{macrocode} |
| 287 |
% \end{macro} |
| 288 |
% |
| 289 |
% \begin{macro}{\exercise} |
| 290 |
% \begin{macro}{\exercise*} |
| 291 |
% On top-level, assignments consist of one or more exercise. The |
| 292 |
% \cmd{\exercise}\oarg{exercise points}\marg{exercise title} macro provides a |
| 293 |
% numbered section title for your assignment. The mandatory argument should |
| 294 |
% contain the exercise's title which is then included in the section title, or |
| 295 |
% be left blank, in which case nothing is appended to the exercise title. The |
| 296 |
% optional argument contains the points rewarded for the exercise in total. |
| 297 |
% |
| 298 |
% Exercise points are added up in the first run of pdflatex (or your TeX |
| 299 |
% backend of choice) and written to the auxilliary file. On the second run, |
| 300 |
% the grading table is added to the top of the document, by inclusion of the |
| 301 |
% points stored in the first run. \textbf{This is the reason csassignments |
| 302 |
% requires two or more runs when used with the grading table}. |
| 303 |
% |
| 304 |
% If you do not specify points, that is, leave the optional argument field |
| 305 |
% empty, the awarded points for the exercise will be set to zero, but the |
| 306 |
% exercise will not be included in the grading table. |
| 307 |
% |
| 308 |
% If you do not specify a title, no empty parentheses are printed. |
| 309 |
% |
| 310 |
% Using the starred version of the exercise command will allow you to |
| 311 |
% explicitly exclude exercise from the grading table (similar to |
| 312 |
% \cmd{section*}\marg{section title} not being included in the table of |
| 313 |
% contents). Note that you can set points on explicitly excluded exercises. |
| 314 |
% The exercise will not count towards the total number of points, but the |
| 315 |
% points for the exercise will still be included in the right column of the |
| 316 |
% exercise's title line. This might be particularly helpful for modelling |
| 317 |
% bonus exercises. |
| 318 |
% \begin{macrocode} |
| 319 |
\newcommand{\@pointsPerExercise}[1]{ |
| 320 |
\ifstrempty{#1}{}{{\quad\large\bfseries/#1 \GetTranslation{points}}} |
| 321 |
} |
| 322 |
\newcommand{\@exerciseLabel}[1]{ |
| 323 |
\quad\ifstrempty{#1}{}{\bfseries(#1)} |
| 324 |
} |
| 325 |
\newcommand\exercise[2][]{ |
| 326 |
\penalty150 |
| 327 |
\ifblank{#1}{\def\points{0}}{\def\points{#1}} |
| 328 |
\stepcounter{exercisenumber} |
| 329 |
\setcounter{subexercisenumber}{0} |
| 330 |
\par |
| 331 |
\vspace{1.5\baselineskip} |
| 332 |
{ |
| 333 |
{\Large\bfseries\GetTranslation{exercise}\ \arabic{exercisenumber}} |
| 334 |
\@exerciseLabel{#2} |
| 335 |
\@exerciseRules |
| 336 |
\notblank{#1}{\@pointsPerExercise{#1}}{} |
| 337 |
} |
| 338 |
\par |
| 339 |
\notblank{#1}{ |
| 340 |
\addtocounter{totalpoints}{\points} |
| 341 |
\@addPT{\arabic{exercisenumber}}{\points} |
| 342 |
}{} |
| 343 |
} |
| 344 |
\WithSuffix\newcommand\exercise*[2][]{ |
| 345 |
\penalty150 |
| 346 |
\ifblank{#1}{\def\points{0}}{\def\points{#1}} |
| 347 |
\stepcounter{exercisenumber} |
| 348 |
\setcounter{subexercisenumber}{0} |
| 349 |
\par |
| 350 |
\vspace{1.5\baselineskip} |
| 351 |
{ |
| 352 |
{\Large\bfseries\GetTranslation{exercise}\ \arabic{exercisenumber}} |
| 353 |
\@exerciseLabel{#2} |
| 354 |
\@exerciseRules |
| 355 |
\notblank{#1}{\@pointsPerExercise{#1}}{} |
| 356 |
} |
| 357 |
\par |
| 358 |
\addtocounter{totalpoints}{\points} |
| 359 |
} |
| 360 |
\AtEndDocument{ |
| 361 |
\makeatletter |
| 362 |
\immediate\write\@mainaux{\string\gdef\string\PTableASaved{\PTableA}} |
| 363 |
\immediate\write\@mainaux{\string\gdef\string\PTableBSaved{\PTableB}} |
| 364 |
\immediate\write\@mainaux{\string\gdef\string\PTHeadSaved{\PTHead}} |
| 365 |
\immediate\write\@mainaux{\string\gdef\string\totalpointsSaved% |
| 366 |
{\arabic{totalpoints}}} |
| 367 |
\makeatother |
| 368 |
} |
| 369 |
% \end{macrocode} |
| 370 |
% \end{macro} |
| 371 |
% \end{macro} |
| 372 |
% \begin{macro}{\subexercise} |
| 373 |
% Subexercises are the subsection to section equivalent for exercises. In fact, |
| 374 |
% their counters behave the same way as subsection counters do. |
| 375 |
% \cmd{\subexercise}\oarg{Subexercise title} will make a new subexercise under the |
| 376 |
% current exercise. Note that point counting for subexercises is not supported. |
| 377 |
% Rather, points are only awarded on the exercise level. Therefore, subexercises |
| 378 |
% are rather semantical for the exercise's reading flow. |
| 379 |
% \begin{macrocode} |
| 380 |
\newcommand{\subexercise}[1][]{ |
| 381 |
\penalty150 |
| 382 |
\stepcounter{subexercisenumber} |
| 383 |
\par |
| 384 |
\vspace{0.5\baselineskip} |
| 385 |
{ |
| 386 |
{\bfseries\GetTranslation{subexercise}\ (\alph{subexercisenumber})} |
| 387 |
\quad\ifstrempty{#1}{}{(#1)} |
| 388 |
\@subexerciseRules |
| 389 |
} |
| 390 |
\par |
| 391 |
} |
| 392 |
% \end{macrocode} |
| 393 |
% \end{macro} |
| 394 |
% \begin{macrocode} |
| 395 |
\def\Vhrulefill{\leavevmode\leaders\hrule height 0.7ex depth |
| 396 |
\dimexpr0.4pt-0.7ex\hfill\kern0pt} |
| 397 |
% \end{macrocode} |
| 398 |
% \begin{macro}{\exerciseRules} |
| 399 |
% \begin{macro}{\subexerciseRules} |
| 400 |
% To add line-spanning horizontal rules between exercises and subexercises, |
| 401 |
% respectively, for better visual separation, add \cmd{\exerciseRules} add some |
| 402 |
% point in the document before the first exercise. |
| 403 |
% \begin{macrocode} |
| 404 |
\newcommand{\exerciseRules}{ |
| 405 |
\renewcommand{\@exerciseRules}{\hspace{1em}\Vhrulefill} } |
| 406 |
\newcommand{\subexerciseRules}{ |
| 407 |
\renewcommand{\@subexerciseRules}{\hspace{0em}\Vhrulefill} } |
| 408 |
\newcommand{\@exerciseRules}{} |
| 409 |
\newcommand{\@subexerciseRules}{} |
| 410 |
% \end{macrocode} |
| 411 |
% \end{macro} |
| 412 |
% \end{macro} |
| 413 |
% |
| 414 |
% \begin{macro}{\noPoints} |
| 415 |
% To remove points and grading entirely from the |
| 416 |
% document, add \cmd{\noPoints} at some point in the document before the first |
| 417 |
% exercise. This overwrites the grading table macro and defines the exercise |
| 418 |
% command to not count points. |
| 419 |
% \begin{macrocode} |
| 420 |
\newcommand{\nopoints}{ |
| 421 |
\renewcommand{\@pointsPerExercise}{} |
| 422 |
\renewcommand{\gradingtable}{} |
| 423 |
\renewcommand{\exercise}{\@exerciseNoPoints} |
| 424 |
} |
| 425 |
\newcommand{\@exerciseNoPoints}[1]{ |
| 426 |
\def\points{0} |
| 427 |
\stepcounter{exercisenumber} |
| 428 |
\setcounter{subexercisenumber}{0} |
| 429 |
\par |
| 430 |
\vspace{1.5\baselineskip} |
| 431 |
{ {\Large\bfseries\GetTranslation{exercise}\ \arabic{exercisenumber}} |
| 432 |
\@exerciseLabel{#1} \@exerciseRules } |
| 433 |
\par |
| 434 |
} |
| 435 |
% \end{macrocode} |
| 436 |
% \end{macro} |
| 437 |
% \section{Document Title} |
| 438 |
% The \texttt{csassignments} class offers several customizations to the default title of article. |
| 439 |
% Namely, we can omit the default fields \cmd{\title}, \cmd{\author}, and \cmd{\date}, and |
| 440 |
% replace them with something more fitting to an assignment: |
| 441 |
% \begin{macrocode} |
| 442 |
\newcommand{\@course}{Assignment} |
| 443 |
\newcommand{\@sheet}{} |
| 444 |
\newcommand{\@group}{} |
| 445 |
\newcommand{\@prefixId}{\GetTranslation{studentId} } |
| 446 |
\newcommand{\@members}{} |
| 447 |
\newcommand{\@member}[2][]% |
| 448 |
{\notblank{#1}{#2, \notblank{#1}{\@prefixId{#1}}{} \\}{#2}} |
| 449 |
\newcommand{\@due}{} |
| 450 |
\newcommand{\@prefixAuthor}{\GetTranslation{prefixAuthor}} |
| 451 |
\newcommand{\@prefixDate}{\GetTranslation{prefixDate}} |
| 452 |
% \end{macrocode} |
| 453 |
% \begin{macro}{\course} |
| 454 |
% \begin{macro}{\sheet} |
| 455 |
% \begin{macro}{\group} |
| 456 |
% \begin{macro}{\due} |
| 457 |
% \begin{macro}{\member} |
| 458 |
% Course name with \cmd{\course}\marg{Course}, sheet number with \cmd{\sheet}\marg{sheet number}, |
| 459 |
% group name with \cmd{\group}\marg{group name}, due date with \cmd{\due}\marg{due date}, |
| 460 |
% and all members of the group with repeated \cmd{\member}\oarg{student id}\marg{name}. |
| 461 |
% \begin{macrocode} |
| 462 |
\newcommand{\course}[1]{\expandafter\notblank\expandafter{#1}% |
| 463 |
{\def\@course{#1}}{}} |
| 464 |
\newcommand{\sheet}[1]{\def\@sheet{\GetTranslation{sheet} #1}} |
| 465 |
\newcommand{\group}[1]{\renewcommand{\@group}{#1}} |
| 466 |
\newcommand{\due}[1]{\renewcommand{\@due}{#1}} |
| 467 |
\newcommand{\member}[2][]{ |
| 468 |
\expandafter\renewcommand\expandafter\@members\expandafter |
| 469 |
{\@members\@member[#1]{#2}} |
| 470 |
\expandafter\renewcommand\expandafter\pdfmembers\expandafter |
| 471 |
{\pdfmembers\pdfmember[#1]{#2}} |
| 472 |
} |
| 473 |
% \end{macrocode} |
| 474 |
% \end{macro} |
| 475 |
% \end{macro} |
| 476 |
% \end{macro} |
| 477 |
% \end{macro} |
| 478 |
% \end{macro} |
| 479 |
% |
| 480 |
% \begin{macro}{\PrefixId} |
| 481 |
% \begin{macro}{\PrefixAuthor} |
| 482 |
% \begin{macro}{\PrefixDate} |
| 483 |
% Additionally, you can redefine the prefixes prepended to the individual parts of the title, for example, |
| 484 |
% the default (english) prefix for the members line in the title block is ``Handed in by'', which you can |
| 485 |
% replace by using \cmd{\PrefixDate}\marg{custom due date prefix}. |
| 486 |
% \begin{macrocode} |
| 487 |
\newcommand{\PrefixId}[1]{\renewcommand{\@prefixId}{#1}} |
| 488 |
\newcommand{\PrefixAuthor}[1]{\renewcommand{\@prefixAuthor}{#1}} |
| 489 |
\newcommand{\PrefixDate}[1]{\renewcommand{\@prefixDate}{#1}} |
| 490 |
% \end{macrocode} |
| 491 |
% \end{macro} |
| 492 |
% \end{macro} |
| 493 |
% \end{macro} |
| 494 |
% |
| 495 |
% \begin{macrocode} |
| 496 |
\renewcommand{\and}{\\} |
| 497 |
\renewcommand{\maketitle}{ |
| 498 |
\thispagestyle{empty} |
| 499 |
{\bfseries\Huge\@course} |
| 500 |
\par |
| 501 |
\expandafter\notblank\expandafter\@sheet{{\LARGE\@sheet\\}}{} |
| 502 |
\par |
| 503 |
\expandafter\notblank\expandafter\@members{ |
| 504 |
{\footnotesize\bfseries\@prefixAuthor}\\ |
| 505 |
\hspace*{4pt}{\large{\vspace*{4pt}\begin{tabular}[t]{@{}l} |
| 506 |
\@members |
| 507 |
\end{tabular}}}\\ |
| 508 |
}{} |
| 509 |
\expandafter\notblank\expandafter\@due{ |
| 510 |
{\footnotesize\bfseries\@prefixDate}\\ |
| 511 |
\vspace*{4pt}{\hspace*{4pt}{\large\@due}}\\ |
| 512 |
}{} |
| 513 |
\vskip \baselineskip |
| 514 |
\pagestyle{fancy} |
| 515 |
} |
| 516 |
\renewcommand{\headrulewidth}{1pt} |
| 517 |
\setlength\headheight{4\baselineskip} |
| 518 |
\rhead{ |
| 519 |
\begin{tabular}{r} |
| 520 |
\textbf{\@course} \\ |
| 521 |
\@sheet \\ |
| 522 |
{\small\@due} |
| 523 |
\end{tabular} |
| 524 |
} |
| 525 |
\lhead{ |
| 526 |
\small{% |
| 527 |
\begin{tabular}{l} |
| 528 |
\@members |
| 529 |
\end{tabular}% |
| 530 |
} |
| 531 |
} |
| 532 |
% \end{macrocode} |
| 533 |
% |
| 534 |
% Lastly, the class handles PDF metadata creation using \texttt{hyperref} from the provided |
| 535 |
% macros, i.e., \cmd{\course}, \cmd{\group} etc. |
| 536 |
% \begin{macrocode} |
| 537 |
\newcommand{\@pdfauthorprefix}{\expandafter\notblank\expandafter% |
| 538 |
{\@group}{Group \@group: }{}\relax} |
| 539 |
\newcommand{\pdfmembers}{} |
| 540 |
\newcommand{\pdfmember}[2][]{\expandafter\notblank\expandafter% |
| 541 |
{#1}{#2, {#1};}{#2}} |
| 542 |
\AtBeginDocument{\hypersetup{ |
| 543 |
pdftitle = {\texorpdfstring{Assignment \@sheet}{}}, |
| 544 |
pdfauthor = {\texorpdfstring{\@pdfauthorprefix\pdfmembers}{}}, |
| 545 |
pdfsubject = {\texorpdfstring{\@course}{}} |
| 546 |
}} |
| 547 |
% \end{macrocode} |
| 548 |
% |
| 549 |
% \section{Math Helpers} |
| 550 |
% |
| 551 |
% \texttt{csassignments} includes several frequently used macros for mathmode, that were, |
| 552 |
% and still are, helpful with assignment work during several computer science courses. |
| 553 |
% Most of them were originally created in one of the \textsc{AlphabetClasses} packages, |
| 554 |
% which featured a lot more definitions. |
| 555 |
% |
| 556 |
% This class only contains a condensed version of them: |
| 557 |
% |
| 558 |
% \begin{macro}{\N} |
| 559 |
% \begin{macro}{\Z} |
| 560 |
% \begin{macro}{\R} |
| 561 |
% \begin{macro}{\Q} |
| 562 |
% \begin{macro}{\C} |
| 563 |
% \begin{macro}{\F} |
| 564 |
% \begin{macro}{\primefield} |
| 565 |
% These macros define common number spaces and fields as double font in mathmode. Notably, |
| 566 |
% \cmd{\primefield} makes a double-printed P, as notation for an arbitrary prime field. |
| 567 |
% \begin{macrocode} |
| 568 |
\newcommand{\N}{\ensuremath{\mathbf{N}}} |
| 569 |
\newcommand{\Z}{\ensuremath{\mathbf{Z}}} |
| 570 |
\newcommand{\R}{\ensuremath{\mathbf{R}}} |
| 571 |
\newcommand{\Q}{\ensuremath{\mathbf{Q}}} |
| 572 |
\newcommand{\C}{\ensuremath{\mathbf{C}}} |
| 573 |
\newcommand{\F}{\ensuremath{\mathbb{F}}} |
| 574 |
\newcommand{\primefield}{\ensuremath{\mathbb{P}}} |
| 575 |
% \end{macrocode} |
| 576 |
% \end{macro} |
| 577 |
% \end{macro} |
| 578 |
% \end{macro} |
| 579 |
% \end{macro} |
| 580 |
% \end{macro} |
| 581 |
% \end{macro} |
| 582 |
% \end{macro} |
| 583 |
% |
| 584 |
% \begin{macro}{\modring} |
| 585 |
% Denoting a ring of integers modulo \(n\) is easily done in short notation with \cmd{\modring}, |
| 586 |
% see \(\mathbb{Z}/\!n\:\), which even works in regular text due to custom trailing spacing. |
| 587 |
% \begin{macrocode} |
| 588 |
\newcommand{\modring}[2]{#1/\!#2\:} |
| 589 |
% \end{macrocode} |
| 590 |
% \end{macro} |
| 591 |
% \begin{macro}{\derivative} |
| 592 |
% The \cmd{\derivative}\marg{variable} prints a typical \(\frac{d}{dx}\) as a shorthand macro. |
| 593 |
% Notably it is not even shorter than the explicit fracture, it is just a convenience macro created |
| 594 |
% at a time when writing \LaTeX for assignments was supported by semantic macros (a thing \LaTeX |
| 595 |
% clearly lacks). |
| 596 |
% \begin{macrocode} |
| 597 |
\newcommand{\derivative}[1]{\ensuremath{\frac{d}{d#1}}} |
| 598 |
% \end{macrocode} |
| 599 |
% \end{macro} |
| 600 |
% |
| 601 |
% \begin{macro}{\matadd} |
| 602 |
% \begin{macro}{\matmul} |
| 603 |
% \begin{macro}{\matswap} |
| 604 |
% These macros are helpful when visualizing matrix operations, namely addition of rows, |
| 605 |
% scalar multiplication of a row, and swapping of rows. Arguments of the macros are identical |
| 606 |
% to the group operation's parameter. |
| 607 |
% \begin{macrocode} |
| 608 |
\newcommand{\matadd}[3]{\ensuremath{\xmapsto{\mathrm{add}_{#1,#2,#3}}}} |
| 609 |
\newcommand{\matmul}[2]{\ensuremath{\xmapsto{\mathrm{mul}_{#1,#2}}}} |
| 610 |
\newcommand{\matswap}[2]{\ensuremath{\xmapsto{\mathrm{sw}_{#1,#2}}}} |
| 611 |
% \end{macrocode} |
| 612 |
% \end{macro} |
| 613 |
% \end{macro} |
| 614 |
% \end{macro} |
| 615 |
% |
| 616 |
% \begin{macro}{\forall} |
| 617 |
% \begin{macro}{\exists} |
| 618 |
% To make logic quantors look a bit better, we redefine the ``for all'' and ``exists'' quantors with |
| 619 |
% a bit more horizontal space left and right |
| 620 |
% \begin{macrocode} |
| 621 |
\renewcommand{\forall}{\ensuremath{\hskip 2pt \oforall \hskip 2pt}} |
| 622 |
\renewcommand{\exists}{\ensuremath{\hskip 2pt \oexists \hskip 2pt}} |
| 623 |
% \end{macrocode} |
| 624 |
% \end{macro} |
| 625 |
% \end{macro} |
| 626 |
% \begin{macro}{\floor} |
| 627 |
% \begin{macro}{\ceil} |
| 628 |
% \begin{macro}{\abs} |
| 629 |
% These are some commonly used mathematical functions, that is, rounding up or down, |
| 630 |
% and the absolute function of a value. |
| 631 |
% \begin{macrocode} |
| 632 |
\newcommand{\ceil}[1]{\ensuremath{\left\lceil #1 \right \rceil}} |
| 633 |
\newcommand{\floor}[1]{\ensuremath{\left\lfloor #1 \right \rfloor}} |
| 634 |
\newcommand{\abs}[1]{\ensuremath{\left\vert#1\right\vert}} |
| 635 |
% \end{macrocode} |
| 636 |
% \end{macro} |
| 637 |
% \end{macro} |
| 638 |
% \end{macro} |
| 639 |
% |
| 640 |
% \begin{macro}{\rfrac} |
| 641 |
% For inline math, regular fractions tend to either stretch the line height, |
| 642 |
% resulting in optical heterogeneity of multiple lines, or setting the letters |
| 643 |
% in the fraction so small that they become unreadable. For small, inline fractions, |
| 644 |
% \cmd{\rfrac}\marg{numerator}\marg{denominator} offers a less optically noisy option, |
| 645 |
% by setting the numerator and denominator in a diagonal arrangement, rahter than purely |
| 646 |
% vertical. Here are some examples: \({}^{1}\!/_{n}\), \({}^{2n}\!/_{k}\), \({}^{100}\!/_{4}\). |
| 647 |
% \begin{macrocode} |
| 648 |
\newcommand{\rfrac}[2]{{}^{#1}\!/_{#2}} |
| 649 |
% \end{macrocode} |
| 650 |
% \end{macro} |
| 651 |
% |
| 652 |
% \begin{macro}{\mod} |
| 653 |
% The macro defines the usual modulus function with a bit of extra space to the left and right. |
| 654 |
% \begin{macrocode} |
| 655 |
\renewcommand{\mod}{\ \mathrm{mod}\ } |
| 656 |
% \end{macrocode} |
| 657 |
% \end{macro} |
| 658 |
% |
| 659 |
% \begin{macro}{\rel} |
| 660 |
% To make a new, arbitrary relation, that is, a symbol for with \texttt{amsmath} ensures horizontal |
| 661 |
% space left and right using \cmd{\mathrel} |
| 662 |
% \begin{macrocode} |
| 663 |
\newcommand{\rel}[1]{\ensuremath{\mathrel{#1}}} |
| 664 |
% \end{macrocode} |
| 665 |
% \end{macro} |
| 666 |
% |
| 667 |
% \begin{macro}{\QED} |
| 668 |
% Ending a proof the way tought at RWTH Aachen University, with a square flushed to the right of |
| 669 |
% the line, can be done by simply adding \cmd{\QED}. |
| 670 |
% Note however that it is semantically more elegant to use \texttt{amsthm} with either predefined |
| 671 |
% \texttt{proof} environment, or any custom environment, as these usually also handle adding a label |
| 672 |
% to the block, e.g., ``\textbf{Proof}.'' or ``\textbf{Lemma}''. |
| 673 |
% \begin{macrocode} |
| 674 |
\newcommand{\QED}{\hfill\(\square\)} |
| 675 |
% \end{macrocode} |
| 676 |
% \end{macro} |
| 677 |
% \begin{macrocode} |
| 678 |
\newtheoremstyle{it}{3pt}{3pt}{}{}{\itshape}{:}{.5em}{} |
| 679 |
\theoremstyle{it} |
| 680 |
% \end{macrocode} |
| 681 |
% \begin{macrocode} |
| 682 |
\makeatother |
| 683 |
% \end{macrocode} |
| 684 |
% |
| 685 |
% \Finale |
| 686 |
% |
| 687 |
\endinput |