145 lines
3.2 KiB
Plaintext
145 lines
3.2 KiB
Plaintext
|
%%
|
||
|
%% problemset package:
|
||
|
%% macros for problem sets
|
||
|
%%
|
||
|
|
||
|
%% TeX format
|
||
|
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
|
||
|
|
||
|
%% package name
|
||
|
\ProvidesPackage{problemset}[2022/01/25]
|
||
|
|
||
|
\newif\ifproblemineq
|
||
|
\newif\ifquestionineq
|
||
|
|
||
|
\DeclareOption{problem_in_eq}{\problemineqtrue}
|
||
|
\DeclareOption{no_problem_in_eq}{\problemineqfalse}
|
||
|
\DeclareOption{question_in_eq}{\questionineqtrue}
|
||
|
\DeclareOption{no_question_in_eq}{\questionineqfalse}
|
||
|
|
||
|
\def\problemset@defaultoptions{
|
||
|
\ExecuteOptions{problem_in_eq, no_question_in_eq}
|
||
|
\ProcessOptions
|
||
|
}
|
||
|
|
||
|
%% the problem command handles automatic problem numbering, as well as per-problem equation numbering
|
||
|
|
||
|
% problem counter
|
||
|
\newcounter{problemcount}
|
||
|
|
||
|
% problem@temp is set to true when there is an optional argument
|
||
|
\newif\ifproblem@temp
|
||
|
\def\problem{%
|
||
|
% check whether there is an optional argument (if there is none, add on empty '[]')
|
||
|
\@ifnextchar [{\problem@temptrue\@problemx}{\problem@tempfalse\@problemx[]}%
|
||
|
}
|
||
|
% command with optional argument
|
||
|
\def\@problemx[#1]{%
|
||
|
% reset question counter
|
||
|
\setcounter{questioncount}{0}
|
||
|
% if optional argument, set problem num to argument
|
||
|
\ifproblem@temp%
|
||
|
\edef\problemnum{#1}%
|
||
|
% otherwise, count
|
||
|
\else%
|
||
|
\stepcounter{problemcount}%
|
||
|
\edef\problemnum{\theproblemcount}%
|
||
|
\fi%
|
||
|
% if ian class
|
||
|
\ifianclass%
|
||
|
% define tag for label
|
||
|
\hrefanchor%
|
||
|
\xdef\tag{E\problemnum}%
|
||
|
%
|
||
|
% add header to equation numbers (for ian class)
|
||
|
\ifproblemineq%
|
||
|
\def\eqprefix{E\problemnum.}%
|
||
|
% reset equation number
|
||
|
\setcounter{seqcount}{0}%
|
||
|
\fi%
|
||
|
\fi%
|
||
|
% header
|
||
|
\problemformat{E\problemnum}%
|
||
|
}
|
||
|
|
||
|
% problem formatting (override to customize)
|
||
|
\def\problemformat#1{{\bf #1}. }
|
||
|
|
||
|
|
||
|
%% question is to problem as subsection is to section
|
||
|
|
||
|
% question counter
|
||
|
\newcounter{questioncount}
|
||
|
|
||
|
% question@temp is set to true when there is an optional argument
|
||
|
\newif\ifquestion@temp
|
||
|
\def\question{%
|
||
|
% check whether there is an optional argument (if there is none, add on empty '[]')
|
||
|
\@ifnextchar [{\question@temptrue\@questionx}{\question@tempfalse\@questionx[]}%
|
||
|
}
|
||
|
% command with optional argument
|
||
|
\def\@questionx[#1]{%
|
||
|
% if optional argument, set problem num to argument
|
||
|
\ifquestion@temp%
|
||
|
\edef\questionnum{#1}%
|
||
|
% otherwise, count
|
||
|
\else%
|
||
|
\stepcounter{questioncount}%
|
||
|
\edef\questionnum{\alph{questioncount}}%
|
||
|
\fi%
|
||
|
% header
|
||
|
\questionformat{\questionnum}%
|
||
|
% if ian class
|
||
|
\ifianclass%
|
||
|
% define tag for label
|
||
|
\hrefanchor%
|
||
|
\xdef\tag{\questionnum}%
|
||
|
%
|
||
|
% add header to equation numbers (for ian class)
|
||
|
\ifquestionineq%
|
||
|
\def\eqprefix{\questionnum.}%
|
||
|
% reset equation number
|
||
|
\setcounter{seqcount}{0}%
|
||
|
\fi%
|
||
|
\fi%
|
||
|
}
|
||
|
|
||
|
% question formatting (override to customize)
|
||
|
\def\questionformat#1{{\bf(#1)} }
|
||
|
|
||
|
\def\solution#1{
|
||
|
\makelink{sol:#1}{\thepage}
|
||
|
{\bf Solution\-~\ref{ex:#1}}\par\penalty10000\smallskip\penalty10000
|
||
|
\def\eqprefix{S\textref{ex:#1}.}
|
||
|
\resetpointcounter
|
||
|
\setcounter{seqcount}{0}
|
||
|
}
|
||
|
|
||
|
%\newif\ifsolution
|
||
|
%% display solutions
|
||
|
%\long\def\solution#1{
|
||
|
% \ifsolution
|
||
|
% \bigskip
|
||
|
% \leftskip20pt
|
||
|
% \rightskip20pt
|
||
|
% {\bf Solution}: #1
|
||
|
% \par
|
||
|
% \leftskip0pt
|
||
|
% \rightskip0pt
|
||
|
% \bigskip
|
||
|
% \fi
|
||
|
%}
|
||
|
|
||
|
|
||
|
% rubric
|
||
|
\newif\ifrubric
|
||
|
\long\def\rubric#1{
|
||
|
\ifrubric
|
||
|
({\it #1})
|
||
|
\fi
|
||
|
}
|
||
|
|
||
|
%% end
|
||
|
\problemset@defaultoptions
|
||
|
\endinput
|