\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