diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/uassign/uassign.sty |
Initial commit
Diffstat (limited to 'macros/latex/contrib/uassign/uassign.sty')
-rw-r--r-- | macros/latex/contrib/uassign/uassign.sty | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/macros/latex/contrib/uassign/uassign.sty b/macros/latex/contrib/uassign/uassign.sty new file mode 100644 index 0000000000..07befed26f --- /dev/null +++ b/macros/latex/contrib/uassign/uassign.sty @@ -0,0 +1,202 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{assign}[2015/09/23 v1.01 University assignments package] + +% Author: Nathan Esau +% +% Packages included: ifthen, hyperref, bookmark, color, enumerate, +% amsmath, fancyhdr, titlesec +% Options: notesheader, links, hideanswers, hidequestions, +% assignheader +% Environments: question, solution, example, exsolution, definition +% Commands: ientry + +%% Project Public License, as described in lppl.txt in the base +%% LaTeX distribution, either version 1.2 or (at your option) +%% any later version. + +\RequirePackage{ifthen} +\RequirePackage{hyperref} +\RequirePackage{bookmark} +\RequirePackage{color} +\RequirePackage{enumerate} +\RequirePackage{amsmath} +\RequirePackage{fancyhdr} +\RequirePackage{titlesec} +\RequirePackage{amsthm} + +\makeatletter + +% Commands +\newcommand{\ebox}[1]{% +\hfill$\qed$ +} + +\newcommand{\ientry}[1]{% +\index{#1}\textbf{#1}} + + +% Counters +\newcounter{questioncounter} +\newcounter{solutioncounter} + +% 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{assignheader}{% + \pagestyle{fancy} + \fancyhf{} + \renewcommand{\headrulewidth}{0pt} + % Define rhead, lhead in assignment + + %\usepackage[margin=1.0in,headheight=27.18335pt]{geometry} + \setlength{\headheight}{27.18335pt} + \cfoot{\thepage} +} + +\DeclareOption{notesheader}{% + +% Format header +\pagestyle{fancy} +\renewcommand{\chaptermark}[1]{\markboth{#1}{}} +\fancyhf{} +\renewcommand{\headrulewidth}{0pt} +\fancyhead[CE]{\textit{\nouppercase{\leftmark}}} +\fancyhead[CO]{\textit{\nouppercase{\rightmark}}} +\fancyhead[LE,RO]{\thepage} +\cfoot{} + +% Format chapter +\titleformat{\chapter}[display] +{\bfseries\filcenter} +{\huge\thechapter} +{1ex} +{ +\vspace{2ex}% +\LARGE} +[\vspace{0.5ex}% +{\titlerule[1.0pt]} +\vspace{10.0ex} +] +\titlespacing*{\chapter}{0pt}{-30pt}{40pt} + +% Format section +\titleformat*{\section}{\centering\large\bfseries} +\titleformat*{\subsection}{\centering\normalsize\bfseries\itshape} +} + +\DeclareOption{links}{% + +% Hyper link setup +\hypersetup{ + colorlinks, + linkcolor={blue}, + linktoc=page, + urlcolor=blue +} + +% +} + +\DeclareOption*{\PackageWarning{uassign}{Unknown ‘\CurrentOption’}} +\ProcessOptions\relax + +% For hiding question and solution environments +\newsavebox{\trashcan} + +% Question environment +\ifthenelse{\boolean{showquestions}}{% + % show the questions + \newenvironment{question}{% + % + \bigskip + \refstepcounter{questioncounter} + \vspace{-5mm} + \list{\thequestioncounter .}{% + \settowidth{\leftmargin}{10. \hskip\labelsep}% + \labelwidth\leftmargin\advance\labelwidth-\labelsep + \partopsep=0pt\bigskip + \item + \begingroup + }% + \endgroup + }{\endlist}}% +{% + % don't show the questions + \newenvironment{question}{% + \begin{lrbox}{\trashcan} + \begin{minipage}{5cm} + }% + {% + \end{minipage} + \end{lrbox}}% +} + +% Solution environment +\ifthenelse{\boolean{showanswers}}{% + % show the answers + \newenvironment{solution}[1][1.5em]{% + % + \bigskip + \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}}{% + \bigskip \item[] \textbf{Solution: } \medskip \item[]} + {\item}% + \begingroup + }% + \endgroup + }{\endlist}}% +{% + % don't show the answers + \newenvironment{solution}{% + \begin{lrbox}{\trashcan} + \begin{minipage}{5cm} + }% + {% + \end{minipage} + \end{lrbox}}% +} + +\newcounter{examplecounter} +%\numberwithin{examplecounter}{chapter} +\newcounter{exsolutioncounter} +%\numberwithin{solutioncounter}{chapter} +\newcounter{defcounter} +%\numberwithin{defcounter}{chapter} + +% Example environment +\newenvironment{example}{ +\bigskip + \refstepcounter{examplecounter} + \noindent\textbf{Example \theexamplecounter} +}{} + +% Solution environment +\newenvironment{exsolution}{ +\bigskip + \refstepcounter{exsolutioncounter} + \noindent\textbf{Solution \theexsolutioncounter} + \begingroup + \endgroup +}{} + +% Definition environment +\newenvironment{definition}{ +\bigskip + \refstepcounter{defcounter} + \noindent\textbf{Definition \thedefcounter} +}{} + +\makeatother |