111 lines
2.4 KiB
TeX
111 lines
2.4 KiB
TeX
% Task environment
|
|
|
|
\newcommand\taskname{Requisite}
|
|
|
|
\newcounter{taskc}
|
|
\setcounter{taskc}{0}
|
|
\renewcommand\thetaskc{\Roman{taskc}}
|
|
|
|
\newcounter{subtaskc}[taskc]
|
|
\setcounter{subtaskc}{0}
|
|
\renewcommand\thesubtaskc{%
|
|
\thetaskc\thesubtaskc@part
|
|
}
|
|
\def\thesubtaskc@part{%
|
|
\expandafter\ifnum\value{subtaskc}>0
|
|
-\alph{subtaskc}%
|
|
\fi
|
|
}
|
|
|
|
\newlength\taskspace
|
|
|
|
\newlength\@@task@barwidth
|
|
\setlength\@@task@barwidth\textwidth
|
|
\addtolength\@@task@barwidth\marginparwidth
|
|
\addtolength\@@task@barwidth\marginparsep
|
|
\newenvironment{task}[1][]%
|
|
{%
|
|
\goodbreak
|
|
\setlength\taskspace{2ex}%
|
|
\refstepcounter{taskc}%
|
|
\vspace{-0.5\parskip}%
|
|
\leavevmode\llap{\rule{\marginparwidth}{2pt}}%
|
|
\rule{\textwidth}{2pt}%
|
|
\vspace{-0.5\baselineskip}%
|
|
\begin{@task}[#1]%
|
|
}%
|
|
{%
|
|
\end{@task}%
|
|
\vspace{-0.85\baselineskip}%
|
|
\leavevmode\llap{\rule{\marginparwidth}{1pt}}%
|
|
\rule{\textwidth}{1pt}%
|
|
\ignorespaces
|
|
}
|
|
|
|
|
|
\newenvironment{subtask}[1][]%
|
|
{%
|
|
\goodbreak
|
|
\list{}{%
|
|
\leftmargin4ex
|
|
\item\relax
|
|
}%
|
|
\setlength\taskspace{6ex}%
|
|
\refstepcounter{subtaskc}%
|
|
\begin{@task}[#1]%
|
|
}%
|
|
{%
|
|
\end{@task}%
|
|
\endlist
|
|
\ignorespaces
|
|
}
|
|
|
|
|
|
|
|
\newlength\@@subtaskcl
|
|
\newcount\@@hmin \newcount\@@hmax \newcount\@@hdiff \newcount\@@hconf
|
|
\newenvironment{@task}[1][]%
|
|
{%
|
|
\def\@@h{#1}%
|
|
\goodbreak\leavevmode\@margin@sig
|
|
\llap{%
|
|
\raisebox{-1.8\baselineskip}[0em][0em]{%
|
|
\shortstack{%
|
|
{\sc\taskname}\space\thesubtaskc
|
|
\\
|
|
\vphantom{M}%
|
|
\ifx\@@h\empty\else
|
|
{\small\@task@h#1||\,h}%
|
|
\fi%
|
|
\\
|
|
\vphantom{M}%
|
|
\ifx\@@h\empty\else
|
|
\@task@setregs#1||%
|
|
{\scriptsize \the\@@hconf\% Confidence}%
|
|
\fi%
|
|
}%
|
|
\hspace{\the\taskspace}%
|
|
% adjust width of the subtask text so that the task number lines up
|
|
\settowidth\@@subtaskcl{\thesubtaskc@part}%
|
|
\hspace{-\the\@@subtaskcl}%
|
|
}%
|
|
}%
|
|
\ignorespaces
|
|
}%
|
|
{\goodbreak\ignorespaces}
|
|
|
|
|
|
\def\@task@h#1-#2||{#1--#2}
|
|
\def\@task@setregs#1-#2||{%
|
|
\@@hmin#1\relax
|
|
\@@hmax#2\relax
|
|
% perform calculation (be sure to multiply by 100 before dividing, otherwise
|
|
% we lose everything through integer truncation); the calculation is:
|
|
% 100 - ((|N-M|/M)*100)
|
|
\@@hdiff#2\relax \advance\@@hdiff-#1\relax
|
|
\@@hconf\@@hdiff
|
|
\multiply\@@hconf by 100\relax
|
|
\divide\@@hconf by-\@@hmax
|
|
\advance\@@hconf by 100\relax
|
|
}
|