summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/probsoln
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-01-14 23:23:39 +0000
committerKarl Berry <karl@freefriends.org>2012-01-14 23:23:39 +0000
commit99b7aeefd4f1e318e9ae379423a09f6ad116b468 (patch)
tree05e72540a09a2a9f842aa7914f80730f1b5d3787 /Master/texmf-dist/tex/latex/probsoln
parent1398422d52caaf61193a5e8c21d1d2db8d41145f (diff)
probsoln 3.02 (14jan12)
git-svn-id: svn://tug.org/texlive/trunk@25106 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/probsoln')
-rw-r--r--Master/texmf-dist/tex/latex/probsoln/probsoln.sty144
1 files changed, 132 insertions, 12 deletions
diff --git a/Master/texmf-dist/tex/latex/probsoln/probsoln.sty b/Master/texmf-dist/tex/latex/probsoln/probsoln.sty
index 365b1075773..8144c5e1c22 100644
--- a/Master/texmf-dist/tex/latex/probsoln/probsoln.sty
+++ b/Master/texmf-dist/tex/latex/probsoln/probsoln.sty
@@ -21,7 +21,7 @@
%%
%% The Current Maintainer of this work is Nicola Talbot.
%%
-%% This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, sample6.tex, sample7.tex, prob-1stprncp.tex, prob-args.tex, prob-easy.tex, prob-easy2.tex, prob-implicit.tex, prob-mchoice.tex, prob-mixed.tex, prob-newdata.tex, prob-nosoln.tex, prob-probspaces.tex, prob-probspaces2.tex, prob-tabmchoice.tex.
+%% This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, sample6.tex, sample7.tex, sample8.tex, prob-1stprncp.tex, prob-args.tex, prob-easy.tex, prob-easy2.tex, prob-implicit.tex, prob-mchoice.tex, prob-mixed.tex, prob-newdata.tex, prob-nosoln.tex, prob-probspaces.tex, prob-probspaces2.tex, prob-tabmchoice.tex, prob-verb.tex.
%%
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -47,7 +47,7 @@
%% Display the problems
%% You may need to change \theenumi back here
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{probsoln}[2011/08/22 v3.01 (NLCT)]
+\ProvidesPackage{probsoln}[2011/12/10 v3.02 (NLCT)]
\RequirePackage{ifthen}
\RequirePackage{amsmath}
\newif\ifshowanswers
@@ -67,6 +67,11 @@
\DeclareOption{final}{%
\renewcommand*{\prob@showdraftlabel}[2]{}}
\ProcessOptions
+\RequirePackage{xkeyval}
+\define@boolkey{probsoln}[@prob@]{fragile}[true]{}
+\newcommand*{\ProbSolnFragileExt}{vrb}
+\newcommand*{\ProbSolnFragileFile}{\jobname}
+\newwrite\probsoln@write
\newcommand*{\prob@db@default}{}
\newcommand*{\prob@databases}{default}
\newcommand*{\prob@db@default@solutions}{}
@@ -191,6 +196,11 @@ Please specify (e.g. \csname @prob@getargs@eg@\romannumeral#1\endcsname):}%
\edef\process@envbody{\the\@envbody\@nx\end{\@currenvir}}%
\@envbody\@emptytoks \def\begin@stack{b}%
\begingroup
+ \if@prob@fragile
+ \obeylines\obeyspaces
+ \@makeother\#
+ \@makeother\%
+ \fi
\@xp\let\csname\@currenvir\endcsname\long@collect@@body
\edef\process@envbody{\@xp\@nx\csname\@currenvir\endcsname}%
\process@envbody
@@ -216,26 +226,112 @@ Please specify (e.g. \csname @prob@getargs@eg@\romannumeral#1\endcsname):}%
\long\def\long@push@begins#1\begin#2{%
\ifx\end#2\else b\@xp\long@push@begins\fi
}
+{\obeylines
+ \gdef\@char@M{^^M}%
+}
+\@onelevel@sanitize\@char@M
+\def\@beg@env@string{\begin}
+\@onelevel@sanitize\@beg@env@string
+\def\@end@env@string{\end}
+\@onelevel@sanitize\@end@env@string
+\edef\def@replace@markers{%
+ \noexpand\def\noexpand\do@replace@charM##1\@char@M##2\noexpand\end@replace@marker{%
+ \noexpand\expandafter\noexpand\toks@\noexpand\expandafter{\noexpand\replace@text}%
+ \noexpand\ifx\noexpand\relax##2\noexpand\relax
+ \noexpand\edef\noexpand\replace@text{\noexpand\the\noexpand\toks@##1}%
+ \noexpand\let\noexpand\do@replacenext\noexpand\replace@mark@noop
+ \noexpand\else
+ \noexpand\edef\noexpand\replace@text{\noexpand\the\noexpand\toks@##1^^J}%
+ \noexpand\let\noexpand\do@replacenext\noexpand\do@replace@charM
+ \noexpand\fi
+ \noexpand\do@replacenext##2\noexpand\end@replace@marker
+ }%
+ \noexpand\def\noexpand\doreplace@begverb##1\@beg@env@string##2\noexpand\end@replace@marker{%
+ \noexpand\expandafter\noexpand\toks@\noexpand\expandafter{\noexpand\replace@text}%
+ \noexpand\ifx\noexpand\relax##2\noexpand\relax
+ \noexpand\edef\noexpand\replace@text{\noexpand\the\noexpand\toks@##1}%
+ \noexpand\let\noexpand\do@replacenext\noexpand\replace@mark@noop
+ \noexpand\else
+ \noexpand\edef\noexpand\replace@text{\noexpand\the\noexpand\toks@
+ ##1\expandafter\@gobble\string\\begin}%
+ \noexpand\let\noexpand\do@replacenext\noexpand\doreplace@begverb
+ \noexpand\fi
+ \noexpand\do@replacenext##2\noexpand\end@replace@marker
+ }%
+ \noexpand\def\noexpand\doreplace@endverb##1\@end@env@string##2\noexpand\end@replace@marker{%
+ \noexpand\expandafter\noexpand\toks@\noexpand\expandafter{\noexpand\replace@text}%
+ \noexpand\ifx\noexpand\relax##2\noexpand\relax
+ \noexpand\edef\noexpand\replace@text{\noexpand\the\noexpand\toks@##1}%
+ \noexpand\let\noexpand\do@replacenext\noexpand\replace@mark@noop
+ \noexpand\else
+ \noexpand\edef\noexpand\replace@text{\noexpand\the\noexpand\toks@
+ ##1\expandafter\@gobble\string\\end}%
+ \noexpand\let\noexpand\do@replacenext\noexpand\doreplace@endverb
+ \noexpand\fi
+ \noexpand\do@replacenext##2\noexpand\end@replace@marker
+ }%
+ \noexpand\def\noexpand\replace@markers##1{%
+ \noexpand\def\noexpand\replace@text{}%
+ \noexpand\expandafter\noexpand\do@replace@charM##1\@char@M\relax\noexpand\end@replace@marker
+ \noexpand\let##1\noexpand\replace@text
+ \noexpand\def\noexpand\replace@text{}%
+ \noexpand\expandafter\noexpand\doreplace@begverb##1\@beg@env@string\relax\noexpand\end@replace@marker
+ \noexpand\let##1\noexpand\replace@text
+ \noexpand\def\noexpand\replace@text{}%
+ \noexpand\expandafter\noexpand\doreplace@endverb##1\@end@env@string\relax\noexpand\end@replace@marker
+ \noexpand\let##1\noexpand\replace@text
+ }
+}
+\def\replace@mark@noop#1\end@replace@marker{}
+\def@replace@markers
\newenvironment{defproblem}[1][0]{%
\edef\@prob@currentargN{\number0#1}%
\@defproblem@beginenv
}{}
-
\newcommand*{\@defproblem@beginenv}[2][]{%
\def\@prob@currentdefaultargs{#1}%
\def\@prob@currentlabel{#2}%
+ \@defproblem@beginenv@
+}
+\newcommand*{\@defproblem@beginenv@}[1][]{%
+ \setkeys{probsoln}{#1}%
\long@collect@body\prob@do@defproblem
}
\newcommand{\prob@do@newproblem}[1]{%
- \prob@newproblem\@prob@currentargN\prob@currentdb
- \@prob@currentlabel{#1}{\@prob@currentdefaultargs}}
+ \if@prob@fragile
+ \probsoln@process@fragile{#1}%
+ \protected@edef\do@def@new@problem{%
+ \noexpand\prob@newproblem
+ {\@prob@currentargN}%
+ {\prob@currentdb}%
+ {\@prob@currentlabel}%
+ {%
+ \noexpand\probsoln@write@tmp{\@prob@tmp@problem}%
+ \noexpand\probsoln@read@tmp
+ }%
+ {\@prob@currentdefaultargs}%
+ }%
+ \else
+ \toks@{#1}%
+ \protected@edef\do@def@new@problem{%
+ \noexpand\prob@newproblem
+ {\@prob@currentargN}%
+ {\prob@currentdb}%
+ {\@prob@currentlabel}%
+ {\the\toks@}%
+ {\@prob@currentdefaultargs}%
+ }%
+ \fi
+ \do@def@new@problem
+}
\let\prob@do@defproblem=\prob@do@newproblem
-\newenvironment{onlysolution}{%
+\newenvironment{onlysolution}[1][]{%
+ \setkeys{probsoln}{#1}%
\long@collect@body\do@onlysolution
}{}
\newcommand{\do@onlysolution}[1]{%
\ifshowanswers
- #1%
+ \probsoln@do@body{#1}%
\fi
\@ifundefined{@prob@currentlabel}
{}%
@@ -270,14 +366,38 @@ Please specify (e.g. \csname @prob@getargs@eg@\romannumeral#1\endcsname):}%
#3%
\fi
}
-\newenvironment{onlyproblem}{%
+\newenvironment{onlyproblem}[1][]{%
+ \setkeys{probsoln}{#1}%
\long@collect@body\do@onlyproblem
}{}
\newcommand{\do@onlyproblem}[1]{%
-\ifshowanswers
-\else
- #1%
-\fi}
+ \ifshowanswers
+ \else
+ \probsoln@do@body{#1}%
+ \fi
+}
+\newcommand{\probsoln@do@body}[1]{%
+ \if@prob@fragile
+ \probsoln@process@fragile{#1}%
+ \probsoln@write@tmp{\@prob@tmp@problem}%
+ \probsoln@read@tmp
+ \else
+ #1%
+ \fi
+}
+\newcommand{\probsoln@process@fragile}[1]{%
+ \def\@prob@tmp@problem{#1}%
+ \@onelevel@sanitize\@prob@tmp@problem
+ \replace@markers\@prob@tmp@problem
+}
+\newcommand{\probsoln@write@tmp}[1]{%
+ \immediate\openout\probsoln@write=\ProbSolnFragileFile.\ProbSolnFragileExt
+ \immediate\write\probsoln@write{#1}%
+ \immediate\closeout\probsoln@write
+}
+\newcommand{\probsoln@read@tmp}{%
+ \input{\ProbSolnFragileFile.\ProbSolnFragileExt}%
+}
\newcommand{\useproblem}[2][default]{%
\def\@prob@currentlabel{#2}%
\def\prob@currentdb{#1}%