summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/stex/problem/problem.sty
blob: ff617ee26d759b46bc21b02046a7bd86b45b387e (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
%%
%% This is file `problem.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% problem.dtx  (with options: `package')
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{problem}[2019/03/20 v1.3 Semantic Markup for Problems]
\newif\if@problem@mh@\@problem@mh@false
\DeclareOption{mh}{\@problem@mh@true}
\newif\ifexnotes\exnotesfalse
\DeclareOption{notes}{\exnotestrue}
\newif\ifhints\hintsfalse
\DeclareOption{hints}{\hintstrue}
\newif\ifsolutions\solutionsfalse
\DeclareOption{solutions}{\solutionstrue}
\newif\ifpts\ptsfalse
\DeclareOption{pts}{\ptstrue}
\newif\ifmin\minfalse
\DeclareOption{min}{\mintrue}
\newif\ifboxed\boxedfalse
\DeclareOption{boxed}{\boxedtrue}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{omtext}}
\ProcessOptions
\if@problem@mh@\RequirePackage{problem-mh}\fi
\RequirePackage{omtext}
\RequirePackage{comment}
\RequirePackage{mdframed}
\RequirePackage[base]{babel}
\AfterBabelLanguage{ngerman}{\input{problem-ngerman.ldf}}
\AfterBabelLanguage{arabic}{\input{problem-arabic.ldf}}
\def\prob@problem@kw{Problem}
\def\prob@solution@kw{Solution}
\srefaddidkey[prefix=prob.]{problem}
\addmetakey{problem}{pts}
\addmetakey{problem}{min}
\addmetakey*{problem}{title}
\addmetakey{problem}{refnum}
\newcounter{problem}
\newcommand\numberproblemsin[1]{\@addtoreset{problem}{#1}}
\newcommand\prob@label[1]{#1}
\newcommand\prob@number{%
\ifx\inclprob@refnum\@empty% if there is no outside refnumb
\ifx\problem@refnum\@empty\prob@label\theproblem%
\else\prob@label\problem@refnum\fi%
\else\prob@label\inclprob@refnum\fi}
\newcommand\prob@title[3]{%
\ifx\inclprob@title\@empty% if there is no outside title
\ifx\problem@title\@empty{#1}\else{#2\problem@title{#3}}\fi
\else{#2}\inclprob@title{#3}\fi}% else show the outside title
\def\prob@heading{\prob@problem@kw~\prob@number\prob@title{ }{ (}{)\strut\\}%
\sref@label@id{\prob@problem@kw~\prob@number}}
\newenvironment{problem}[1][]{\metasetkeys{problem}{#1}\sref@target%
\@in@omtexttrue% we are in a statement (for inline definitions)
\stepcounter{problem}\record@problem%
\def\current@section@level{\prob@problem@kw}%
\par\noindent\textbf\prob@heading\show@pts\show@min\rmfamily\noindent\ignorespaces}
{\smallskip}
\ifboxed\surroundwithmdframed{problem}\fi
\def\record@problem{\protected@write\@auxout{}%
{\string\@problem{\prob@number}%
{\ifx\inclprob@pts\@empty\problem@pts\else\inclprob@pts\fi}%
{\ifx\inclprob@min\@empty\problem@min\else\inclprob@min\fi}}}
\def\@problem#1#2#3{}
\srefaddidkey{soln}
\addmetakey{soln}{for}
\addmetakey{soln}{height}
\addmetakey{soln}{creators}
\addmetakey{soln}{contributors}
\addmetakey{soln}{srccite}
\newcommand\@startsolution[1][]{\metasetkeys{soln}{#1}%
\@in@omtexttrue% we are in a statement.
\ifboxed\else\hrule\fi\smallskip\noindent{\textbf\prob@solution@kw: }\begin{small}%
\def\current@section@level{\prob@solution@kw}%
\ignorespaces}
\newcommand\startsolutions{\specialcomment{solution}{\@startsolution}%
{\ifboxed\else\hrule\medskip\fi\end{small}}%
\ifboxed\surroundwithmdframed{solution}\fi}
\newcommand\stopsolutions{\excludecomment{solution}}
\ifsolutions\startsolutions\else\stopsolutions\fi
\ifexnotes
\newenvironment{exnote}[1][]%
{\par\smallskip\hrule\smallskip\noindent\textbf{Note: }\small}
{\smallskip\hrule}
\else%ifexnotes
\excludecomment{exnote}
\fi%ifexnotes
\ifhints
\newenvironment{hint}[1][]%
{\par\smallskip\hrule\smallskip\noindent\textbf{Hint: }\small}
{\smallskip\hrule}
\newenvironment{exhint}[1][]%
{\par\smallskip\hrule\smallskip\noindent\textbf{Hint: }\small}
{\smallskip\hrule}
\else%ifhints
\excludecomment{hint}
\excludecomment{exhint}
\fi%ifhints
\newenvironment{mcb}
{\begin{enumerate}}
{\end{enumerate}}
\srefaddidkey{mcc}
\addmetakey{mcc}{feedback}
\addmetakey[T]{mcc}{T}
\addmetakey[F]{mcc}{F}
\addmetakey[Yes]{mcc}{Ttext}
\addmetakey[No]{mcc}{Ftext}
\newcommand\mcc[2][]{%
\metasetkeys{mcc}{#1}%
\item #2%
\ifsolutions\\%
\ifcsstring{mcc@T}{T}{}{\mcc@Ttext}%
\ifcsstring{mcc@F}{F}{}{\mcc@Ftext}%
\ifx\mcc@feedback\@empty!\else, \mcc@feedback\fi%
\fi} %solutions
\addmetakey{inclprob}{pts}
\addmetakey{inclprob}{min}
\addmetakey*{inclprob}{title}
\addmetakey{inclprob}{refnum}
\addmetakey{inclprob}{mhrepos}
\clear@inclprob@keys%initially
\newcommand\includeproblem[2][]{\metasetkeys{inclprob}{#1}%
\input{#2}\clear@inclprob@keys}
\def\pts#1{\ifpts\marginpar{#1 pt}\fi}
\def\min#1{\ifmin\marginpar{#1 min}\fi}
\AtEndDocument{\ifpts\message{Total: \arabic{pts} points}\fi
\ifmin\message{Total: \arabic{min} minutes}\fi}
\newcounter{pts}
\def\show@pts{\ifx\inclprob@pts\@empty%
\ifx\problem@pts\@empty\else%
\ifpts\marginpar{\problem@pts pt\smallskip}\addtocounter{pts}{\problem@pts}\fi%
\fi\else% inclprob@pts nonempty
\ifpts\marginpar{\inclprob@pts pt\smallskip}\addtocounter{pts}{\inclprob@pts}\fi%
\fi}
\newcounter{min}
\def\show@min{\ifx\inclprob@min\@empty%
\ifx\problem@min\@empty\else%
\ifmin\marginpar{\problem@min min}\addtocounter{min}{\problem@min}\fi%
\fi\else%
\ifmin\marginpar{\inclprob@min min}\addtocounter{min}{\inclprob@min}\fi
\fi}
\endinput
%%
%% End of file `problem.sty'.