blob: 28d1c4f758ec4a920d834603be39bfa5a377c8af (
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
|
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{uassign}[2015/09/04 University assignments package]
% Author: Nathan Esau
% Date: September 6, 2015
% Version: 1.0
\RequirePackage{ifthen}
\makeatletter
% Counters
\newcounter{questioncounter}
\newcounter{solutioncounter}
% For printing "# " OR "Solution: " for answers
\newboolean{questionsandanswers}
% For hiding question environment
\newboolean{showquestions}
\setboolean{showquestions}{true}
% For hiding solution environment
\newboolean{showanswers}
\setboolean{showanswers}{true}
\DeclareOption{hideanswers}{\setboolean{showanswers}{false}}
\DeclareOption{hidequestions}{\setboolean{showquestions}{false}}
\DeclareOption*{\PackageWarning{assn}{Unknown ‘\CurrentOption’}}
\ProcessOptions\relax
% For hiding
\newsavebox{\trashcan}
% Question environment
\ifthenelse{\boolean{showquestions}}{%
% show the questions
\newenvironment{question}{%
%
\medskip
\refstepcounter{questioncounter}
\vspace{-5mm}
\list{\thequestioncounter .}{%
\settowidth{\leftmargin}{10. \hskip\labelsep}%
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\partopsep=0pt\bigskip
\item
}}{\endlist}}%
{%
% don't show the questions
\newenvironment{question}{%
\begin{lrbox}{\trashcan}}%
{\end{lrbox}}%
\question Hello
\endgroup
}
% Solution environment
\ifthenelse{\boolean{showanswers}}{%
% show the answers
\newenvironment{solution}[1][1.5em]{%
%
\medskip
\refstepcounter{solutioncounter}
\vspace{-5mm}
\list{\ifthenelse{\boolean{showquestions}}{}{\thesolutioncounter .}}{%
\settowidth{\leftmargin}{10. \hskip\labelsep}%
\labelwidth\leftmargin\advance\labelwidth-\labelsep
\partopsep=0pt\bigskip
\ifthenelse{\boolean{showquestions}}{%
\medskip \item[] \qquad \ \textbf{Solution: } \vspace{-3mm} \item[]}
{\item}%
}}{\endlist}}%
{%
% don't show the answers
\newenvironment{solution}{%
\begin{lrbox}{\trashcan}}%
{\end{lrbox}}%
}
\makeatother
|