Fix nonce typo
[exsheet.git] / exsheet.cls
1 % Stefan Huber, 2010-02
2 % Stefan Huber, 2019-09-23
3 % Stefan Huber, 2020-06-23
4 % Stefan Huber, 2021-06-21
5
6 \NeedsTeXFormat{LaTeX2e}
7 \ProvidesClass{exsheet}
8
9
10 \DeclareOption{10pt}{\PassOptionsToClass{\CurrentOption}{article}}
11 \DeclareOption{12pt}{\PassOptionsToClass{\CurrentOption}{article}}
12
13 \DeclareOption{german}{\def \exsheetgerman{}}
14 \DeclareOption{ngerman}{\def \exsheetgerman{}}
15 \DeclareOption{austrian}{\def \exsheetgerman{}}
16 \DeclareOption{naustrian}{\def \exsheetgerman{}}
17 \DeclareOption{showanswers}{\def \exsheetshowanswers{}}
18
19
20 \PassOptionsToClass{a4paper,notitlepage,twoside}{article}
21 \ProcessOptions\relax
22
23 %-------------------- This is based on the article class ----------------
24
25 \LoadClass{article}
26 \RequirePackage{xifthen,geometry,fancyhdr,enumitem,comment}
27
28
29 %------------------ Defining the most common environments ---------------
30
31 \@ifundefined{exsheetgerman}{
32 \newcommand{\theexercise}{Exercise}
33 \newcommand{\thepoint}{Point}
34 \newcommand{\thepoints}{Points}
35 \newcommand{\thestudnumber}{Number}
36 \newcommand{\theanswer}{Answer}
37 }{%
38 \newcommand{\theexercise}{Aufgabe}
39 \newcommand{\thepoint}{Punkt}
40 \newcommand{\thepoints}{Punkte}
41 \newcommand{\thestudnumber}{Personenkennzeichen}
42 \newcommand{\theanswer}{Antwort}
43 }
44
45 %Check whether we should show the answers
46 \@ifundefined{exsheetshowanswers}{
47 \excludecomment{answer}
48 }{
49 \newenvironment{answer}{\vspace*{0.5em}\textit{\theanswer:} \hspace*{0.5em} }{}
50 }
51
52 \newcounter{excounter}
53 \setcounter{excounter}{1}
54 \newenvironment{exercise}[1][]{%
55 \vspace*{2em}%
56 \textbf{\theexercise~\arabic{excounter}}:
57 \ifthenelse{\isempty{#1}}{}{%
58 \ifnum#1=1%
59 \hfill[#1 \thepoint]%
60 \else%
61 \hfill[#1 \thepoints]%
62 \fi%
63 }%
64 \newline}
65 {\addtocounter{excounter}{1}}
66
67
68 \def\@semester{}
69 \newcommand{\semester}[1]{\def\@semester{#1}}
70
71 \def\@lva{}
72 \newcommand{\lva}[1]{\def\@lva{#1}}
73
74 \def\@auth{}
75 \renewcommand{\author}[1]{\def\@auth{#1}\def\@author{#1}}
76
77 \def\@institute{\ }
78 \newcommand{\institute}[1]{\def\@institute{#1}}
79
80 \newcommand{\studentinfo}{%
81 {
82 Name: \underline{\hspace{6cm}}
83 \hfill
84 \thestudnumber: \underline{\hspace{4cm}}
85 \vspace*{2em}
86 }
87 }
88
89
90
91
92 %------------------ Basic layout ----------------------------------------
93
94 \geometry{verbose,a4paper,width=16cm,height=23cm}
95
96 \fancypagestyle{exsheet}
97 {
98 \fancyhf{}%
99 \fancyhead[LO,LE]{%
100 \begin{minipage}{70mm}
101 \@lva\\
102 \@semester
103 \vspace{1mm}
104 \end{minipage}
105 }
106 \fancyhead[RO,RE]{%
107 \begin{minipage}{70mm}
108 \raggedleft
109 \@institute\\
110 \@auth
111 \vspace{1mm}
112 \end{minipage}
113 }
114 }
115
116 \setlength{\headheight}{2.5em}
117 \renewcommand{\headrulewidth}{1pt}
118
119 \setlength{\parindent}{0em}
120
121
122 %------------------ Common command ---------------------------------------
123
124 \let\oldmaketitle\maketitle
125
126 \renewcommand{\@maketitle}{%
127 \noindent
128 \begin{center}
129 {\LARGE\bf\@title}\\
130 \vspace{1em}\@date
131 \end{center}
132
133 \vspace{4em}
134 }
135
136 \renewcommand{\maketitle}{%
137 \oldmaketitle
138 \thispagestyle{exsheet}
139 \pagestyle{exsheet}
140 }
141
142
143 \renewcommand\abstract{\it\noindent}
144
145 %------------------ Defining specific commands environments ---------------
146
147 \newenvironment{choices}{%
148 \begin{itemize}[label=$\square$, labelsep=2ex]
149 }{\end{itemize}}
150