diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/stex/problem/problem.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/stex/problem/problem.sty | 130 |
1 files changed, 70 insertions, 60 deletions
diff --git a/Master/texmf-dist/tex/latex/stex/problem/problem.sty b/Master/texmf-dist/tex/latex/stex/problem/problem.sty index 220ad52bb29..46319929165 100644 --- a/Master/texmf-dist/tex/latex/stex/problem/problem.sty +++ b/Master/texmf-dist/tex/latex/stex/problem/problem.sty @@ -7,93 +7,103 @@ %% problem.dtx (with options: `package') %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\ProvidesPackage{problem}[2012/01/28 v0.9c Semantic Markup for Problems] -\DeclareOption{showmeta}{\PassOptionsToPackage{\CurrentOption}{metakeys}} -\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} -\newif\ifextract\extractfalse\DeclareOption{extract}{\extracttrue} +\ProvidesPackage{problem}[2016/04/06 v1.2 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 -\RequirePackage{keyval}[1997/11/10] -\RequirePackage{xcomment} -\RequirePackage{sref} +\if@problem@mh@\RequirePackage{problem-mh}\fi +\RequirePackage{omtext} +\RequirePackage{comment} +\RequirePackage{mdframed} +\RequirePackage[base]{babel} +\AfterBabelLanguage{ngerman}{\input{problem-ngerman.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} -\newsavebox{\probbox} -\newcounter{problem}[section] -\def\prob@number{\ifx\inclprob@refnum\@empty -\ifx\problem@refnum\@empty\thesection.\theproblem\else\problem@refnum\fi -\inclprob@refnum\fi} -\def\prob@heading{Problem \prob@number% -\ifx\sref@id\@empty\else{\sref@label@id{Problem \thesection.\theproblem}}\fi% +\newcounter{problem} +\newcommand\numberproblemsin[1]{\@addtoreset{problem}{#1}} +\newcommand\prob@label[1]{#1} +\def\prob@number{\ifx\inclprob@refnum\@empty% +\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{:\quad}\else{\quad(\problem@title)\hfill\\}\fi -\else\quad(\inclprob@title)\hfill\\\fi}% else show the outside title -\ifboxed +\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% -\stepcounter{problem}\show@pts\show@min\record@problem% -\begin{lrbox}{\probbox}\begin{minipage}{.9\textwidth}\ignorespaces} -{\end{minipage}\end{lrbox} -\setbox0=\hbox{\begin{minipage}{.9\textwidth}% -\noindent\textbf\prob@heading\rm% -\end{minipage}} -\smallskip\noindent\fbox{\vbox{\box0\vspace*{.2em}\usebox\probbox}}\smallskip} -\else -\newenvironment{problem}[1][]{\metasetkeys{problem}{#1}\sref@target% -\stepcounter{problem}\show@pts\show@min\record@problem% -\par\noindent\textbf\prob@heading\rm\ignorespaces} +\@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\rm\noindent\ignorespaces} {\smallskip} -\fi%boxed +\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{} -\define@key{soln}{id}{\def\soln@id{#1}} -\define@key{soln}{for}{\def\soln@for{#1}} -\define@key{soln}{height}{\def\soln@height{#1}} -\ifsolutions -\newenvironment{solution}[1][]% -{\hrule\smallskip{\bf Solution: }\begin{small}}% -{\hrule\end{small}} -\else\newxcomment[]{solution}\fi +\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\noindent\hrule\smallskip{\bf Note: }\small} +{\par\smallskip\hrule\smallskip\noindent\textbf{Note: }\small} {\smallskip\hrule} \else%ifexnotes -\newxcomment[]{exnote} +\excludecomment{exnote} \fi%ifexnotes \ifhints \newenvironment{hint}[1][]% -{\par\noindent\hrule\smallskip{\bf Hint: }\small} +{\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 -\newxcomment[]{hint} +\excludecomment{hint} +\excludecomment{exhint} \fi%ifhints -\ifextract -\newwrite\problem@file -\immediate\openout\problem@file=\jobname-problems.tex -\AtEndDocument{\closeout\problem@file} -\fi \addmetakey{inclprob}{pts} \addmetakey{inclprob}{min} \addmetakey*{inclprob}{title} \addmetakey{inclprob}{refnum} -\clear@inclprob@keys -\newcommand{\includeproblem}[2][]{% -\bgroup\metasetkeys{inclprob}{#1}\input{#2}\ifsolutions\newpage\fi\egroup -\ifextract\def\@test{#1} -\def\prob@num{\ifx\inclprob@refnum\@empty\thesection.\theproblem\else\inclprob@refnum\fi} -\def\inclprob@keys{#1\ifx\@test\@empty\else,\fi refnum=\prob@num} -\protected@write\problem@file{}{\string\includeproblem[\inclprob@keys]{#2}} -\fi} +\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 @@ -102,7 +112,7 @@ \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% +\fi\else% inclprob@pts nonempty \ifpts\marginpar{\inclprob@pts pt\smallskip}\addtocounter{pts}{\inclprob@pts}\fi% \fi} \newcounter{min} |