1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
%%
%% This is file `cesenaexam.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% cesenaexam.dtx (with options: `package,classpackage')
%% ----------------------------------------------------------------
%% cesenaexam --- class file to typeset exams
%% E-mail: alexpacini90@gmail.com
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% Contributions to this repository as pull requests are welcome!
%% ----------------------------------------------------------------
%%
%% This LaTeX document class has been designed to typeset exams.
%% To make the .cls from the .dtx one, just run
%% ```make```.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cesenaexam}[2017/08/03 - v0.2 Cesena Exam]
\def\cesenaexamversion{0.2}
%% Custom options
\RequirePackage{etoolbox}
%% I decided to use the etoolbox ifbool because the if else fi
%% has issues with docstrip and needs a dirty hack
%% tex.stackexchange.com/questions/162762
%% No version option
\newbool{exam@version}\booltrue{exam@version}
%% Box the blocks option
\newbool{exam@boxed}\boolfalse{exam@boxed}
%% Times font option
\newbool{exam@times}\boolfalse{exam@times}
%% Loading graphicx before tikz removes a
%% strange issue with the \graphicspath
\RequirePackage[pdftex]{graphicx}
%% Tikz and circuitikz
\RequirePackage{tikz}
\RequirePackage[betterproportions]{circuitikz}
\usetikzlibrary{arrows.meta,arrows,intersections,%
positioning,fit,calc,through,babel}
\usetikzlibrary{decorations.pathmorphing,backgrounds}
%% Some settings for Tikz
\tikzset{switcharc/.style={draw, thick, >=stealth},
every picture/.append style={tight background,%
baseline={([yshift=-1em] current bounding box.north)}}}
%% Redefine the section to have bigger font and to be
%% delimited between two lines
\RequirePackage{titlesec}
\newcommand{\sectionfont}{\Large}
\renewcommand\thesection{\bfseries \arabic{section}}
\titleformat{\section}
{\titlerule
\vspace{0.5ex}%
\sectionfont}
{\thesection}{1em}
{\sectionfont \bfseries}[\titlerule]
%% Redefine the enumerate item to be bold
\renewcommand\labelenumi{\bfseries\theenumi.}
%% Options for the titlebox processed from the
%% maketitle optional arguments
\pgfkeys{
/mytitlebox/.is family, /mytitlebox,
textboxheight/.default = 0.6cm,
whiteboxheight/.default = 1cm,
textboxheight/.store in = \minheighttext@title,
whiteboxheight/.store in = \minwhiteboxheight@title,
textboxone/.default = {\relax},
textboxtwo/.default = {\relax},
textboxthree/.default = {\relax},
textboxfour/.default = {\relax},
textboxone/.store in = \textboxone@title,
textboxtwo/.store in = \textboxtwo@title,
textboxthree/.store in = \textboxthree@title,
textboxfour/.store in = \textboxfour@title,
%% Executing them to assign the default value
%% (Tikz manual 82.3.2 or tex.stackexchange.com/questions/85754)
textboxheight, whiteboxheight, textboxone,
textboxtwo, textboxthree, textboxfour,
}
%% Define examsection and examsection*
\def\examsection{\@ifstar\@examsection\@@examsection}
\def\@examsection#1#2{\section*{#1 \textmd{(\textit{#2})}}\noindent}
\def\@@examsection#1#2{\section{#1 \textmd{(\textit{#2})}}\noindent}
%% Definition of empty tick box
\newcommand{\boxempty}{$ \square \;$}
%% Definition of empty tick box
\newcommand{\boxcheck}{$ \blacksquare \;$}
%% Assigns to ex@parts what is passed to the function examparts{}.
%% Works similarly similarly to author{}
\def\examparts#1{\def\ex@parts{#1}}
%% Redefine maketitle
%% Just for a future starred version
\def\maketitle{\@ifstar\make@@title\make@title}%
%% Define the unstarred version maketitle (make@title)
\newcommand\make@title[6][]{%
\pgfkeys{/mytitlebox, #1}%
\make@@@title{#2}{#3}{#4}{#5}{#6}}%
%% Define the common command
\def\make@@@title#1#2#3#4#5{%
\ifbool{exam@boxed}{%
\tikzset{every picture/.append style={framed},%
background rectangle/.style={draw=red}}}{}%
\begin{center}%
\begin{tikzpicture}%
\pgfmathsetmacro{\boxlen}{(\textwidth-1.6cm)/4}%
\pgfmathsetmacro{\lastboxlen}{\textwidth - 4*\boxlen - 1mm}%
\node (surname) [draw, align=center, minimum width=\boxlen,%
minimum height = \minheighttext@title] at (0,0) {\bf #1};%
\node (surname box) [draw, anchor=north, minimum width=\boxlen,%
minimum height = \minwhiteboxheight@title] at%
($(surname.south)+(0,\pgflinewidth)$) {\textboxone@title};%
\node (name) [draw, align=center, right=0 and -\pgflinewidth of surname,%
minimum width=\boxlen, minimum height = \minheighttext@title] {\bf #2};%
\node (name box) [draw, anchor=north, minimum width=\boxlen,%
minimum height = \minwhiteboxheight@title] at%
($(name.south)+(0,\pgflinewidth)$) {\textboxtwo@title};%
\node (id) [draw, align=center, right=0 and -\pgflinewidth of name,%
minimum width=\boxlen, minimum height = \minheighttext@title] {\bf #3};%
\node (id box) [draw, anchor=north, minimum width=\boxlen,%
minimum height = \minwhiteboxheight@title] at%
($(id.south)+(0,\pgflinewidth)$) {\textboxthree@title};%
\node (signature) [draw, align=center, right=0 and -\pgflinewidth of id,%
minimum width=\boxlen, minimum height = \minheighttext@title] {\bf #4};%
\node (signature box) [draw, anchor=north, minimum width=\boxlen,%
minimum height = \minwhiteboxheight@title] at%
($(signature.south)+(0,\pgflinewidth)$) {\textboxfour@title};%
%%
\pgfmathsetmacro{\minheighttypebox}{\minheighttext@title +%
\minwhiteboxheight@title}%
\node (examtype) [draw, align=center, anchor=north west,%
minimum width=\lastboxlen, minimum height = \minheighttypebox] at%
($(signature.north east)+(-\pgflinewidth,0)$) {\Huge \bfseries #5};%
\node (checkboxes) [align=left, anchor=north west] at%
(surname box.south west) {\ex@parts};%
\end{tikzpicture}%
\end{center}%
}
%% Macro for two blocks centre aligned
\def\examtwoblocks#1#2#3#4{%
\noindent%
\begin{minipage}[c]{#1}\flushleft#3\end{minipage}%
\hfill%
\begin{minipage}[c]{#2}#4\end{minipage}
\par\vspace{5mm}\noindent%
}
\def\examtwoblocks@box#1#2#3#4{%
\noindent%
\tikzset{every picture/.append style={framed},
background rectangle/.style={draw=red}}%
\let\bak@fboxsep\fboxsep%
\def\fboxsep{0pt}%
\fbox{\begin{minipage}[c]{#1}\flushleft#3\end{minipage}}%
\hfill%
\fbox{\begin{minipage}[c]{#2}#4\end{minipage}}%
\let\fboxsep\bak@fboxsep%
\par\vspace{5mm}\noindent%
}
\ifbool{exam@boxed}{%
\renewcommand{\examtwoblocks}{\examtwoblocks@box}}{}
%% Macro for two blocks top aligned
\def\examtwoblockstop#1#2#3#4{%
\noindent%
\begin{minipage}[t]{#1}\flushleft#3\end{minipage}%
\hfill%
\begin{minipage}[t]{#2}\flushright#4\end{minipage}%
}
\def\examtwoblockstop@box#1#2#3#4{%
\noindent%
\tikzset{every picture/.append style={framed},
background rectangle/.style={draw=red}}%
\let\bak@fboxsep\fboxsep%
\def\fboxsep{0pt}%
\fbox{\begin{minipage}[t]{#1}\flushleft#3\end{minipage}}%
\hfill%
\fbox{\begin{minipage}[t]{#2}\flushright#4\end{minipage}}%
\let\fboxsep\bak@fboxsep%
}
\ifbool{exam@boxed}{%
\renewcommand{\examtwoblockstop}{\examtwoblockstop@box}}{}
%% Macro for one block top aligned
\def\examoneblocktop#1#2{%
\noindent%
\begin{minipage}[t]{#1}\flushleft#2\end{minipage}}%
\def\examoneblocktop@box#1#2{%
\noindent%
\tikzset{every picture/.append style={framed},
background rectangle/.style={draw=red}}%
\let\bak@fboxsep\fboxsep%
\def\fboxsep{0pt}%
\fbox{\begin{minipage}[t]{#1}\flushleft#2\end{minipage}}%
\let\fboxsep\bak@fboxsep%
}
\ifbool{exam@boxed}{%
\renewcommand{\examoneblocktop}{\examoneblocktop@box}}{}
%%
%% Copyright (C) 2017 by Alex Pacini <alexpacini90@gmail.com>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License (LPPL), either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in the file:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% This work is "maintained" (as per LPPL maintenance status) by
%% Alex Pacini.
%%
%% This work consists of the file cesenaexam.dtx
%% and the derived files cesenaexam.ins,
%% cesenaexam.pdf and
%% cesenaexam.cls.
%%
%%
%% End of file `cesenaexam.sty'.
|