summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/exercisebank/exercisebank-doc.tex
blob: b4f3a1970eed5295018d6e1c340338807ca8395a (plain)
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
%% exercisebank v0.1.0b55 - 2018/04/08
%% The LaTeX package exercisebank - version v0.1.0 (2018/04/08) build 55
%% #PACKAGE.sty
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2018 by Andreas Storvik Strauman
%% -------------------------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008/05/04 or later.
%% This work has the LPPL maintenance status `author-maintained'.
%% This work consists of all files listed in README.txt
\documentclass{article}
\usepackage[all]{tcolorbox}
\usepackage{needspace}
\usepackage{tabularx}
\makeatletter
\lstdefinestyle{mydocumentation}{style=tcbdocumentation,
  classoffset=0,
  texcsstyle=*\color{blue},
  moretexcs={arrayrulecolor,draw,includegraphics,ifthenelse,isodd,lipsum,path,pgfkeysalso},
  classoffset=1,
  moretexcs={% core
    makeset,phead,buildset,select,exclude,Trigger,At,translateExBank,exercisebanksetup,exerciseFile
  },
  texcsstyle=*\color{Definition}\bfseries,
  classoffset=0,% restore default
  }
\newtcolorbox{marker}[1][]{enhanced,
    before skip=2mm,after skip=3mm,
    boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm,
    colback=yellow!50,
    colframe=yellow!20!black,
    sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
    underlay={%
      \path[fill=tcbcol@back!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
      \path[draw=tcbcol@frame,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
      \path[fill=yellow!50!black,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries !} ([xshift=4mm]interior.north west);
      },
    drop fuzzy shadow,#1}
 \title{Exercise bank - Manual\\{\normalsize v0.1.0}}
 \makeatother
\let\dac\docAuxCommand
\long\def\keyDef#1#2#3#4{\begin{docKey}{#1}{=\meta{#2}}{\meta{default}=#3}#4\end{docKey}}
\tcbset{documentation listing style=mydocumentation}
% Magenta HREF style
\let\oldhref\href
\gdef\href#1#2{{\color{magenta}\oldhref{#1}{#2}}}
% Give section some space
\let\oldsection\section
\gdef\section{\needspace{0.3\paperheight}\oldsection}
\let\oldsubsection\subsection
\gdef\subsection{\needspace{0.2\paperheight}\oldsubsection}


\setlength{\parindent}{0pt}
\title{{exercisebank - manual\\ v0.1.0{\\[-0.5em]\footnotesize(build 55)}}}
\author{Andreas Strauman}
\begin{document}
\maketitle
 
If you found any bugs or want new functionality, to contribute, view the commented source, get latest version of this package or get in touch with me, you can do all of that at \url{https://github.com/Strauman/exerciseBank/}. If you have questions of functionality, kindly direct them to the community\\ \url{http://tex.stackexchange.com}. The author is active on this site regularly.

\tableofcontents
\clearpage
\section{Motivation}
Exercises are saved as separate files containing part problems. These files can be used to make sets, and you can cherry-pick or exclude certain part problems as you see fit. This makes it easier to maintain and keep your exercises flexible as the syllabus changes.

\section{Flow/Moderate start}
I suspect that working with this package will break you current flow. So let's go throught it.

Most likely you would want to put all your exercises in a folder. To set the default folder, use \refCom{exercisebanksetup}.
In these examples we use \texttt{exercises/}.
\begin{dispListing*}{title=exercises/myexercise.tex}
\begin{intro}
  This introduces our problem
\end{intro}
\begin{problem}
  This is a partproblem 1,
  and will be hidden (just wait, you'll see)
\end{problem}
\begin{problem}
  This is a partproblem 2.
  This will not be hidden, but become part problem a!
\end{problem}
\end{dispListing*}
Let's build all of them first. In the main file, (the one where you include this package):
\begin{dispListing*}{title=main.tex}
  \documentclass{article}
  \usepackage{exercisebank}
  \exercisebanksetup{exercise directory=exercises}
  \makeset{myExerciseSet}{myexercise}
  \begin{document}
    \buildset{myExerciseSet}
  \end{document}
\end{dispListing*}
This builds the entire set, and adds Problem header and partproblem counters ( (1a) and (1b) ) by default.
\subsection{Select}
Now, let's build only the second problem.
\begin{dispListing*}{title=main.tex}
  \documentclass{article}
  \usepackage{exercisebank}
  \exercisebanksetup{exercise directory=exercises}
  \makeset{myExerciseSet}{\select{myexercise}{2}}
  \begin{document}
    \buildset{myExerciseSet}
  \end{document}
\end{dispListing*}
This should only build the intro and the one exercise you \refCom*{select}ed!

Now, say you want to hide the intro. Well all you have to do in this case is
make the package treat the intro as a problem in regards to what is \refCom*{select}ed.
Just add the optional argument \oarg{intro} to \dac{make}. That is switch
\begin{dispListing}
\makeset{myExerciseSet}{\select{myexercise}{2}}
\end{dispListing}
with
\begin{dispListing}
\makeset[intro]{myExerciseSet}{\select{myexercise}{3}}
\end{dispListing}
Notice that there are 3 `partproblems' now since we have to count the intro!

\subsection{Exclude}
But what if you have an exercise with 12 partproblems, and you only want to exclude the 7th partproblem? Well, then \dac{Exclude} is here to rescue the day for you.
\begin{dispListing}
  \makeset{myExerciseSet}{\exclude{soManyExercises}{7}}
\end{dispListing}
Here it's important to note that the [intro] argument would not make the intros disappear. If we wanted to only exclude the intro from our previous example file \texttt{exercises/myexercise.tex} we would do
\begin{dispListing}
\makeset[intro]{myExerciseSet}{\exclude{myexercise}{1}}
\end{dispListing}
So we're excluding the partproblem 1. But that's the intro when we send the [intro] optional argument
\subsection{Multiple}
In \dac{makeset} you can just separate exercises with commas! Here is an example:

Let's say you have two files with exercises. One located in \texttt{exercises/circuits/RLC.tex} and one in \texttt{exercises/ohm/ohmsGeneralLaw.tex}, and you want to include partproblem 1 through 5 from \texttt{RLC.tex} and all of the exercises from \texttt{ohmsGeneralLaw.tex}.

\begin{dispListing}
\makeset{\select{circuits/RLC}{1,...,5}, ohmsGeneralLaw}
\end{dispListing}
This will divide it up with problem headers. So that what is in the \texttt{RLC.tex}-file will be Problem 1, and \texttt{ohmsGeneralLaw.tex} Problem 2.
\subsection{Mixnmatch}
What if you want to make both of them the same exercise? Well, then you pass the [nohead] argument to \dac{makeset}:
\begin{dispListing}
\makeset[nohead]{\phead, \select{circuits/RLC}{1,...,5}, ohmsGeneralLaw}
\end{dispListing}
The \dac{phead} command makes a problem header. You can pass them as much as you want:

\begin{dispListing}
\makeset[nohead]{\phead, \select{circuits/RLC}{1,...,5},
              ohmsGeneralLaw, \phead, someOtherExercise, moreExercises}
\end{dispListing}

\subsection{Solutions}
The last thing to cover then is solutions. In your exercise files you just use the solution environment
\begin{dispListing}
\begin{solution}
Solution goes here
\end{solution}
\end{dispListing}
They are hidden by default, so you would have to use \dac{DisplaySolutions} in
your main file to display them.

\subsection{Using \dac{At}}
\subsubsection{Making your own front page for a set}
To create your own front page for each set, you'd use\\ \dac{At}\dac{StartBuildset}\brackets{\meta{FrontPageContents}}. Anyhing you send in to \dac{At}\dac{StartBuildset} will be executed before the first problem starts:
\begin{dispListing}
  \At\StartBuildset{
    \input{myFrontpage}
  }
\end{dispListing}
\subsubsection{Printing the file name beneath the problem header}
Maybe you want to see what files are what problems. One way to do that is hook into the \dac{At}\dac{VeryBeginProblem} and use \refCom{exerciseFile}.This is the command that the headers call, so anything you put in there will be executed right after the headers.

\begin{dispListing}
  \At\VeryBeginProblem{
    \exerciseFile\\
  }
\end{dispListing}

Note that the \dac{At}{BeginProblem} is executed \emph{before} the headers.

That covers the basics. Enjoy
\begin{marker}
\dac{begin}\{problem\},\dac{end}\{problem\},\\
\dac{begin}\{solution\},\dac{end}\{solution\},\\
\dac{begin}\{intro\} and \dac{end}\{intro\} has to be on their own line without any spaces!
\end{marker}
 \section{Reference}
\subsection{Environments}
\begin{docEnvironment}{problem}{}
Inside the \dac{keyRef}\{exercise directory\}, you keep your exercises. Inside the exercise file you'd use a problem environment to write your partproblems. It might be a little confusing that you're using \dac{begin}\{problem\} instead of \dac{begin}\{partproblem\} when you're writing a partproblem, but it's less typing.
\end{docEnvironment}
\begin{docEnvironment}{solution}{}
 Things inside here is only visible if \refCom{DisplaySolutions} are given before \dac{begin}\{document\}
 \begin{marker}\dac{end}\{solution\} has to be on it's own line without any leading spaces!\end{marker}
\end{docEnvironment}
\begin{docCommand}{DisplaySolutions}{}
Turns on the solutions, so they are shown.
\end{docCommand}
\begin{docEnvironment}{intro}{}
Sometimes you'd want to introcude your exercises and tell a little bit about it. Maybe have a figure there also. Those things should go inside this environment. This can be treated as a problem in terms of counting. See \refCom{makeset} for more info.
\end{docEnvironment}
\subsection{Configuration and options}
You can do a lot of configurations on this package, and probably
 even more to come in later versions!
\begin{docCommand}{exercisebanksetup}{\marg{[key/values]}}
 Here is a list of the different keys and their meaning
\keyDef{part problems}{On/Off}{On}{
 This is whether or not to do part problems. E.g. 1a), 1b) etc.
 If this is turned Off, then the part problems will be treated as problems
}
\keyDef{tighten paragraphs}{True/False}{True}{
 Disabling this will prevent
 the package from attempting to prevent part problems to scatter across pages
}
\keyDef{problem header}{macro}{see below}{
 This sets the problem header. To access the translation of the problem text, use \dac{@tr}\{Problem\}, and
 the problem counter is accessed with \dac{theproblemcounter}.\\
 Defaults to\\
 \brackets{\dac{normalfont}\dac{Large}\dac{bfseries}\dac{@tr}\{Problem\}~\dac{theproblemcounter}}.
}
\keyDef{part problem header}{macro}{see below}{
 This sets the problem header. To access the current problem, use \dac{theproblemcounter}, and then the current
 part problem \dac{thepartproblemcounter}. To make it a letter, as per default use \dac{alph}\{partproblemcounter\}\\
 Default is:\\
 \dac{large}\dac{textbf}\{(\dac{theproblemcounter}\dac{alph}{partproblemcounter\})}
}
\keyDef{solution header}{string}{see below}{
\dac{large}\{\dac{textbf}{\dac{@tr}{Solution\}:}}
}
\keyDef{exercise directory}{string}{./}{
This key is used for setting the default exercise directory.
}
\begin{dispListing}
 \exercisebanksetup{exercise directory=exercises,part problems=Off,solution header={\textbf{SOL:}}}
\end{dispListing}
\end{docCommand}
\subsection{Internationalization}
\begin{docCommand}{translateExBank}{\marg{Translation key/vals}}
This is to translate the text inside the package. As of now the available key/values are
\begin{itemize}
\item Problem
\item Solution
\end{itemize}
The Norwegian translation would then be done with
\begin{dispListing}
\translateExBank{Problem=Oppgave, Solution=Løsning}
\end{dispListing}
\end{docCommand}
\subsection{Triggers}
\begin{docCommand}{Trigger}{\marg{Any Macro}}
 See \refCom{At}\\
 Available triggers:\\
\dac{Trigger}\dac{BeginPartproblem}:\\ Triggers before a partproblem is inserted\\
\dac{Trigger}\dac{VeryBeginPartproblem}:\\ Triggers right after \dac{BeginPartproblem}. This is so that the user can do stuff before the actual headers start. The partproblem headers are invoked by \dac{At}\dac{VeryBeginPartproblem}
\dac{Trigger}\dac{InputExercise}:\\ Triggers before a file is included\\\
\dac{Trigger}\dac{BeginProblem}:\\ Triggers before a file is included, but only if problem headers are to be written (no [nohead] given)\\
\dac{Trigger}\dac{EndProblem}:\\ Triggers right after problem is included if [nohead] \dac{emph}\{not\} given\\
\dac{Trigger}\dac{BeginBuildset}:\\ Triggers right before a set has begun building (not if \dac{sprite} is used). You might want to put your set-header here\\
\dac{Trigger}\dac{EndBuildset}:\\ Triggers when a set has stopped building (not if \dac{sprite} is used)\\


\end{docCommand}
\subsection{General reference}
\begin{docCommand}{ownLineNoSpacesGotIt}{}
This is to annoy the user enough to get his attention about the requirements of the \refEnv{problem}, \refEnv{solution} and \refEnv{intro} environments.\\
\end{docCommand}
\begin{marker}DEPRECATED! use \refCom{exercisebanksetup} with \refKey{exercise directory} instead!\end{marker}
\begin{docCommand}{setExercisesDir}{\marg{directory}}
\begin{marker}\dac{setExercisesDir} is deprecated! use \refCom{exercisebanksetup} with \refKey{exercise directory} instead!\end{marker}
This is the directory, relative to the file you included the package,
where the package should be looking for exercises. Default is the same directory as your main file (the one you build).
\end{docCommand}
This package also includes some extra stuff. For example the \dac{At} and \dac{Trigger}
\begin{docCommand}{At}{\marg{AnyMacro}}
Here you can send any macro because it isn't evaluated! For example \dac{At}\dac{BeginSomething} is fine and even if \dac{BeginSomething} is not defined. Also and when using \dac{Trigger} it just ignores it if it didn't exist. It's pretty similar in function as to \dac{AtBeginDocument}.
\begin{dispListing}
 \At\BeginSomething{DoSomething}
 Which is triggered with
 \Trigger\BeginSomething, this evaluates to DoSomething
\end{dispListing}
\end{docCommand}
\begin{docCommand}{isin}{\marg{haystack}\marg{needle}\marg{True}\marg{False}}
 \meta{haystack} is a comma separated list of integers\\
 \meta{needle} is an integer\\
 Executes \meta{True} if \meta{needle} is found in \meta{haystack}
 else executes \meta{False}
\end{docCommand}
\begin{docCommand}{exerciseFile}{}
This is a `read-only' macro that contains the name of the current exerciseFile
\end{docCommand}
\subsection{Making sets}
\begin{docCommand}{makeset}{\oarg{intro,nohead}\marg{filable}}
 This command is the one you use to make a set! Later you use \dac{buildset} to build the sets you make. The \meta{filable} argument is either the name of the file relative to the \dac{setExercisesDir}-path (default is nothing, so it's in the root path), or you could use the \dac{select} or \dac{exclude} to  respectively cherry pick or exclude exercises. (See their docs).\\
 \oarg{intro} this counts the intro environment as a part problem, so that you can \dac{select} or \dac{exclude} the intro\\
 \oarg{nohead} prevents the builder from adding a problem header. This is handy if you want to create an exercise that is composed of multiple parts. You can use the \dac{phead} to insert the problem header where you want it
\begin{dispListing}
 \makeset[nohead]\{\phead, \select{myexercise}{1,2,3}}
\end{dispListing}
\end{docCommand}
\begin{docCommand}{about}{\marg{text}}
This contains information about an exercise set. It is intended to be on the top of an
exercise, explaining short what the exercise is about. It's only visible when using \dac{sprite}
\end{docCommand}
\begin{docCommand}{sprite}{\oarg{PiP}}
 This is a way to visualize all exercises. It takes one optional argument which is how many pages
 inside one page. Defaults to 4
 \begin{marker}If \dac{sprite} is used, it should be the only command in \dac{begin}\{document\}\dac{end}\{document\}\end{marker}
\end{docCommand}
\begin{docCommand}{exclude}{\marg{exerciseFileName}\marg{Comma separated numbers}}
As you can see in the intro section of the documentation, this is for excluding partproblems
To be used in \refCom{makeset}
\end{docCommand}
\begin{docCommand}{select}{\marg{exerciseFileName}\marg{Comma separated numbers}}
As you can see in the intro section of the documentation, this is for cherry picking partproblems
To be used in \refCom{makeset}
\end{docCommand}
\begin{docCommand}{setName}{}
This variable prints out the name of your set that you sent to \dac{buildset}.
The following example prints "Exercise set number 1" and "Exercise set number 2" on the top of each set
\begin{dispListing}
\At\StartBuildset{
 Exercise set number \setName
}
 %... \makesets here ...%
\begin{document}
 \buildset{1}{myexercise}
 \buildset{2}{myexercise}
\end{document}
\end{dispListing}
\end{docCommand}
\begin{docCommand}{pplabel}{\marg{label}}
Labels a partproblem. You can reference to it later using \dac{ppref}\{\meta{label\}}
\end{docCommand}
\begin{docCommand}{ppref}{\marg{label}}
Reference a partproblem created by \dac{pplabel}\{\meta{label\}}. This prints e.g. 1c)
\end{docCommand}
\begin{docCommand}{ppref}{\marg{label}}
 Reference a partproblem created by \dac{pplabel}\{\meta{label\}}. This prints e.g. 1
\end{docCommand}
\subsection{Counters}
\docCounter{problemcounter}-counter holds the current problem number and
\docCounter{partproblemcounter}-counter holds the current partproblem \emph{number}.

\section{Changelog}
%!TEX root = exercisebank-doc.tex
\begin{tabularx}{\textwidth}{llX}
  Version&Date&Change\\
  v0.0.2b11&2018/04/02&Updated documentation syntax.\\
  v0.0.3b38&2018/04/03&\nobreak\begin{itemize}
    \item Updated triggers doc
    \item added trigger \dac{VeryBeginPartproblem}
  \end{itemize}\\
  v0.0.3b40&2018/04/03&\begin{itemize}
    \item Added examples that uses the \dac{At} command.
      Making front page and other snacks
  \end{itemize}\\
  v0.0.4b44&2018/04/03&\begin{itemize}
    \item Changed design of part problems. (Looks much better now!)
  \end{itemize}\\
  v0.0.5b46&2018/04/03&\begin{itemize}
    \item Fixed partproblems and solutions to fit on pages using \dac{filbreak}.
  \end{itemize}\\
  v0.1.0&2018/04/08&\begin{itemize}
    \item \begin{marker}Backward incompability from v0.0.5:Removed default exercise directory! \end{marker} Use \dac{exercisebanksetup}\brackets{exercise directory=exercises} if you used the package before 2018/04/08!
    \item Fixed title of documentation to match actual package.
    \item Fixed weird paragraph styling when displaying solutions
    \item Added a few package options. More to come!
  \end{itemize}\\
\end{tabularx}
 \end{document}