diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/probsoln/probsoln.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/probsoln/probsoln.dtx | 561 |
1 files changed, 84 insertions, 477 deletions
diff --git a/Master/texmf-dist/source/latex/probsoln/probsoln.dtx b/Master/texmf-dist/source/latex/probsoln/probsoln.dtx index 0912f634e65..d555fc87f5e 100644 --- a/Master/texmf-dist/source/latex/probsoln/probsoln.dtx +++ b/Master/texmf-dist/source/latex/probsoln/probsoln.dtx @@ -1,13 +1,12 @@ %\iffalse -% probsoln.dtx generated using makedtx version 0.9b (c) Nicola Talbot +% probsoln.dtx generated using makedtx version 0.91b (c) Nicola Talbot % Command line args: % -src "(.+)\.(sty)=>\1.\2" -% -src "(.*\.tex)\Z=>\1" % -doc "manual.tex" % -author "Nicola Talbot" % -dir "source" % probsoln -% Created on 2006/3/2 11:26 +% Created on 2007/7/18 20:23 %\fi %\iffalse %<*package> @@ -30,7 +29,7 @@ %\fi % \iffalse % Doc-Source file to use with LaTeX2e -% Copyright (C) 2006 Nicola Talbot, all rights reserved. +% Copyright (C) 2007 Nicola Talbot, all rights reserved. % \fi % \iffalse %<*driver> @@ -69,9 +68,9 @@ %\fi % % -% \title{probsoln.sty v2.02: \LaTeXe\ Package to help create problem sheets} +% \title{probsoln.sty v2.03: \LaTeXe\ Package to help create problem sheets} % \author{Nicola L.C. Talbot} -% \date{2nd March 2006} +% \date{20th June 2006} % \maketitle % \tableofcontents % @@ -107,7 +106,12 @@ %\cmddef{newproblem}\verb|[|\meta{nargs}\verb/]{/\meta{label}\verb!}{!\meta{problem}\verb+}{+\meta{solution}\verb=}=\\[10pt] %A new problem is defined using the command %\cmdname{newproblem}. This does not print anything, -%but merely stores the problem. The argument \meta{label} is +%but merely stores the problem. As from version 2.03, there is also +%a starred version of this command for problems without a solution +%(for example, essay style questions):\\[10pt] +%\DescribeMacro{\newproblem*} +%\cmddef{newproblem*}\verb|[|\meta{nargs}\verb/]{/\meta{label}\verb!}{!\meta{problem}\verb+}+\\[10pt] +%The argument \meta{label} is %a unique string that is assigned to this problem so that it %can be used later. The argument \meta{problem} is normal %\LaTeX\ code that should be used to typeset the problem. @@ -128,6 +132,11 @@ % \end{displaymath} % } %\end{verbatim} +%The following is an essay question, so doesn't come with a solution: +%\begin{verbatim} +%\newproblem*{inheritance}{Describe what is meant by the term +%\emph{inheritance} in object-oriented programming. Use examples.} +%\end{verbatim} % %The optional argument \meta{nargs} specifies the number of %parameters this problem will take. By default this value is @@ -188,7 +197,8 @@ %\section{Creating a Database} % %To generate a database, simply create a \texttt{.tex} file -%where all the problems are defined using \cmdlink{newproblem}, +%where all the problems are defined using \cmdlink{newproblem} or +%\cmdlink{newproblem*}, %and either \cmdname{input} it at the start of your document if %you want to use specific problems (see Section~\ref{sec:useprob}), or pass it to %\cmdname{selectrandomly} (see Section~\ref{sec:selran}). This package @@ -382,14 +392,16 @@ % %The solution is placed inside the \DescribeEnv{solution}\env{solution} %environment. By default this environment simply does -%\verb|\paragraph{\solutionname:}| at the start, where +%\verb|\par\noindent\textbf{\solutionname:} | at the start, where %\DescribeMacro{\solutionname}\cmddef{solutionname} %has the value: Solution. See the file \texttt{sample3.tex}, which %comes with this package, for an illustration of how to %customise the way in which the randomly selected problems are %displayed. This sample file randomly selects multiple choice %problems stored in the file \texttt{tabmchoice.tex}, and displays them -%in a longtable \env{environment}. +%in a longtable \env{environment}. As from version 2.03, the package +%will not define this environment if another package or class file has +%already defined it. % %\DescribeMacro{showanswers} %The boolean variable \texttt{showanswers} is defined to be @@ -436,7 +448,7 @@ %otherwise it will appear as: %\begin{description} %\item Which of the following is the derivative of -%$x\sin(x)$?(Circle the correct answer.) +%$x\sin(x)$? (Circle the correct answer.) %\begin{description} %\item[A] $\sin(x)$\item[B] $x\cos(x)$\item[\textcircled{C}] $\sin(x) + x\cos(x)$ (product rule)\end{description} %\end{description} @@ -542,14 +554,16 @@ %\StopEventually{\PrintIndex} % %\section{The Code} +%\iffalse % \begin{macrocode} %<*probsoln.sty> % \end{macrocode} +%\fi % At the start of the package, specify that the \LaTeXe\ format is % required. And specify the package provided. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{probsoln}[2006/03/02 v2.02 Problems and their Solutions Package (NLCT)] +\ProvidesPackage{probsoln}[2006/06/20 v2.03 Problems and their Solutions Package (NLCT)] \RequirePackage{ifthen} % \end{macrocode} % Define newif to determine whether or not to show the answers. @@ -572,10 +586,15 @@ \newif\iffirstpass \newif\ifselected % \end{macrocode} -% Define the command that creates a new problem +% Define the command that creates a new problem. As from version +% 2.03 this command now has a starred version for problems without +% solutions. % \begin{macrocode} -\newcommand{\solutionname}{Solution} -\newcommand{\newproblem}[4][0]{% +\newcommand{\newproblem}{\@ifstar\@snewproblem\@newproblem} +% \end{macrocode} +% The unstarred version. +% \begin{macrocode} +\newcommand{\@newproblem}[4][0]{% \ifselectrandom \iffirstpass % on the first pass, just store the label, and increment \@probN @@ -596,7 +615,7 @@ \read-1to\@tmp \expandafter\xdef\csname @prob@#2@arg\endcsname{\@tmp}% \expandafter\global\expandafter\newcommand\csname @prob@#2\endcsname[#1]{% -#3 \ifshowanswers\solution #4\fi}% +#3 \ifshowanswers\begin{solution}#4\end{solution}\fi}% \fi }{% \PackageError{probsoln}{Label #2 already used}% @@ -615,6 +634,46 @@ \fi } % \end{macrocode} +% The starred version (new to version 2.03). Note that there is one +% less argument, because the problem doesn't have a solution. +% \begin{macrocode} +\newcommand{\@snewproblem}[3][0]{% +\ifselectrandom +\iffirstpass +% on the first pass, just store the label, and increment \@probN +\global\advance\@probN by 1 +\expandafter\gdef\csname @problabel\romannumeral\@probN\endcsname{#2}% +\else +% check to see if this problem has been selected +\checkselected{#2}% +\ifselected +\@ifundefined{@prob@#2}{% +\ifnum#1=0 +% this problem has no arguments +\expandafter\gdef\csname @prob@#2\endcsname{#3}% +\expandafter\gdef\csname @prob@#2@arg\endcsname{\relax}% +\else +\message{Problem #2 requires #1 argument(s), please specify (e.g. {5}{3}):}% +\read-1to\@tmp +\expandafter\xdef\csname @prob@#2@arg\endcsname{\@tmp}% +\expandafter\global\expandafter\newcommand\csname @prob@#2\endcsname[#1]{#3}% +\fi +}{% +\PackageError{probsoln}{Label #2 already used}% +{Each problem must have a unique label identifier}% +}% +\fi +\fi +\else +\@ifundefined{@prob@#2}{% +\expandafter\global\expandafter\newcommand\csname @prob@#2\endcsname[#1]{#3}% +}{% +\PackageError{probsoln}{Label #2 already used}% +{Each problem must have a unique label identifier}% +} +\fi +} +% \end{macrocode} % Define the command that uses a problem % \begin{macrocode} \newcommand{\useproblem}[1]{% @@ -740,6 +799,9 @@ problems.}% } % \end{macrocode} % What to do at start and end of each randomly selected item: +% (I may turn this into a normal environment at a later date. At the +% moment, I have kept \verb|\PSNitem| for compatibility with earlier +% versions.) % \begin{macrocode} \newcommand{\PSNitem}{\item} \@ifundefined{endPSNitem}{\def\endPSNitem{}}{% @@ -747,7 +809,10 @@ problems.}% % \end{macrocode} % How to display each solution % \begin{macrocode} -\newenvironment{solution}{\paragraph{\solutionname:}}{} +\providecommand{\solutionname}{Solution} +\@ifundefined{solution}{% +\newenvironment{solution}{\par\noindent\textbf{\solutionname:} }{}}{% +} % \end{macrocode} % Check to see if label has been selected % \begin{macrocode} @@ -820,468 +885,10 @@ are only \number\@ps@forrand item(s) in the list}% \fi }} % \end{macrocode} +%\iffalse % \begin{macrocode} %</probsoln.sty> % \end{macrocode} -% \begin{macrocode} -%<*1stprncp.tex> -% \end{macrocode} -% These all involve differentiating from 1st principles - -\newproblem{dfp:xcube}{% -Differentiate $f(x) = x^3$ with respect to $x$ by first principles.}{% -\begin{eqnarray*} -\frac{dy}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{f(x+\Delta x) - f(x)}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)^3-x^3}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)(x^2+2x\Delta x+(\Delta x)^2)-x^3}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{x^3+3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3-x^3}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}3x^2+3x\Delta x + (\Delta x)^2\\ - & = & 3x^2 -\end{eqnarray*}} - -\newproblem{dfp:Ioverxsq}{% -Differentiate $\displaystyle f(x) = \frac{1}{x^2}$ with respect to $x$ by first principles.}{% -\begin{eqnarray*} -\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{\frac{1}{(x+\Delta x)^2}-\frac{1}{x^2}}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{\frac{x^2-(x+\Delta x)^2}{x^2(x+\Delta x)^2}}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{x^2-(x^2+2x\Delta x+(\Delta x)^2)}{x^2\Delta x(x+\Delta x)^2}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{-2x\Delta x-(\Delta x)^2}{x^2\Delta x(x+\Delta x)^2}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{-2x-\Delta x}{x^2(x+\Delta x)^2}\\ - & = & \frac{-2x}{x^2x^2}\\ - & = & -\frac{2}{x^3} -\end{eqnarray*}} - -\newproblem{dfp:sqrtx}{% -Differentiate from first principles $f(x) = \surd x$}{% -\begin{eqnarray*} -\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{\sqrt{x+\Delta x}-\surd x}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{(\sqrt{x+\Delta x}-\surd x)(\sqrt{x+\delta x}+\surd x)}{\Delta x(\sqrt{x+\Delta x}+\surd x)}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{x+\Delta x - x}{\Delta x(\sqrt{x+\Delta x}+\surd x)}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{\Delta x}{\Delta x(\sqrt{x+\Delta x}+\Delta x)}\\ - & = & \lim_{\Delta x\rightarrow 0}\frac{1}{\sqrt{x+\Delta x}+\surd x}\\ - & = & \frac{1}{2\surd x} -\end{eqnarray*}} - -\newproblem{dfp:cons}{% -Differentiate from first principles $f(x) = c$ where $c$ is a constant.}{% -\begin{eqnarray*} -\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{c-c}{\Delta x}\\ - & = & \lim_{\Delta x\rightarrow 0}0\\ - & = & 0 -\end{eqnarray*}} - -\newproblem{dfp:cosx}{% -Given -\begin{eqnarray*} -\lim_{x \rightarrow 0} \frac{\cos x - 1}{x} & = & 0\\ -\lim_{x \rightarrow 0} \frac{\sin x}{x} & = & 1 -\end{eqnarray*} -differentiate from first principles $f(x) = \cos x$.}{% -\begin{eqnarray*} -\frac{df}{dx} & = & \lim_{\Delta x \rightarrow 0}\frac{f(x + \Delta x) - f(x)}{\Delta x}\\ - & = & \lim_{\Delta x \rightarrow 0} \frac{\cos(x + \Delta x) - \cos(x)}{\Delta x}\\ - & = & \lim_{\Delta x \rightarrow 0} \frac{\cos x\cos\Delta x - \sin x\sin\Delta x - \cos x}{\Delta x}\\ - & = & \lim_{\Delta x \rightarrow 0} \frac{\cos x(\cos\Delta x - 1) - \sin x\sin\Delta x}{\Delta x}\\ - & = & \cos x\lim_{\Delta x \rightarrow 0}\frac{\cos\Delta x - 1}{\Delta x} - - \sin x\lim_{\Delta x \rightarrow 0}\frac{\sin\Delta x}{\Delta x}\\ - & = & -1 \qquad\mbox{(using given results)} -\end{eqnarray*}} -% \begin{macrocode} -%</1stprncp.tex> -% \end{macrocode} -% \begin{macrocode} -%<*args.tex> -% \end{macrocode} -% These problems require arguments - -% Arguments: #1->a_2, #2->a_1 and #3->a_0 -% (Arguments must be integers) -\newcount\ctr -\newproblem[3]{diff:quad}{% -\(f(x) = -\ifnum#1=0 -\else -\ifnum#1=1\else#1\fi x^2 -\fi -\ifnum#2=0 -\else -\ifnum#2>0 \ifnum#1=0 \else + \fi \fi -\ifnum#2=1\else#2\fi x -\fi -\ifnum#3=0 -\else -\ifnum#3>0 \ifnum#2=0 \ifnum#1=0 \else + \fi \else + \fi\fi -#3 -\fi\) -}{% -\(f'(x) = -\ifnum#1=0 -\else -\ctr=2 -\multiply\ctr by #1 -\the\ctr x -\fi -\ifnum#2=0 -\else -\ifnum#2>0 \ifnum#1=0 \else + \fi \fi -#2 -\fi -% print 0 if both #1 and #2 are 0 -\ifnum#1=0 \ifnum#2=0 0 \fi\fi -\) -} - -\newproblem[1]{diff:sin}{% -\(f(x) = \sin(#1x)\) -}{% -\(f'(x) = #1\cos(#1x)\) -} - -% \begin{macrocode} -%</args.tex> -% \end{macrocode} -% \begin{macrocode} -%<*easy.tex> -% \end{macrocode} -% These are all easy differentiation problems - -\newproblem{diffeasy:gpowh}{% -\(f(x) = g(x)^{h(x)}.\)}{% -\begin{eqnarray*} -f(x) & = & e^{\ln g(x)^{h(x)}}\\ - & = & e^{h(x)\ln g(x)}\\ -f'(x) & = & e^{h(x)\ln g(x)}(h'(x)\ln g(x) + h(x)\frac{g'(x)}{g(x)})\\ - & = & g(x)^{h(x)}(h'(x)\ln g(x) + \frac{h(x)g'(x)}{g(x)}) -\end{eqnarray*}} - -\newproblem{diffeasy:arcsin}{% -\(y = \arcsin(x)\)}{% -\[\sin(y) = x\] -diff. w.r.t. $x$: -\begin{eqnarray*} -\cos y \frac{dy}{dx} & = & 1\\ -\frac{dy}{dx} & = & \frac{1}{\cos y}\\ - & = & \frac{1}{\sqrt{1 - \sin^2y}}\\ - & = & \frac{1}{\sqrt{1-x^2}}. -\end{eqnarray*}} - -\newproblem{diffeasy:arccos}{% -$y = \arccos x$.}{% -\(\cos y = x\) -diff. w.r.t. $x$: -\begin{eqnarray*} --\sin y \frac{dy}{dx} & = & 1\\ -\frac{dy}{dx} & = & \frac{-1}{\sin y}\\ - & = & \frac{-1}{\sqrt{1-\cos^2y}}\\ - & = & \frac{-1}{\sqrt{1-x^2}} -\end{eqnarray*}} - -\newproblem{diffeasy:tan}{% -\(y = \tan x\)}{% -\begin{eqnarray*} -y & = & \tan x\\ - & = & \frac{\sin x}{\cos x}\\ -\frac{dy}{dx} & = & \frac{\cos x}{\cos x} + \sin x\times\frac{-1}{\cos^2x}\times -\sin x\\ - & = & 1 + \tan^2x\\ - & = & \sec^2x. -\end{eqnarray*}} - -\newproblem{diffeasy:arctan}{% -\(y = \arctan x = \tan^{-1}x\)}{% -\[\tan y = x\] -diff w.r.t. $x$: -\begin{eqnarray*} -\sec^2y\frac{dy}{dx} & = & 1\\ -\frac{dy}{dx} & = & \frac{1}{\sec^2y}\\ - & = & \frac{1}{1+\tan^2y}\\ - & = & \frac{1}{1+x^2} -\end{eqnarray*}} - -\newproblem{diffeasy:cot}{% -\(y = (\tan x)^{-1} = \cot x\)}{% -\begin{eqnarray*} -\frac{dy}{dx} & = & -(\tan x)^{-2}\sec^2x\\ - & = & -\frac{\cos^2x}{\sin^2x}\cdot\frac{1}{\cos^2x}\\ - & = & \frac{-1}{\sin^2x}\\ - & = & -\csc^2x. -\end{eqnarray*}} - -\newproblem{diffeasy:cosxsqsinx}{% -$y = \cos(x^2)\sin x$.}{% -\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]} - -\newproblem{diffeasy:xlnx}{% -$y = (x+1)\ln(x+1)$.}{% -\begin{eqnarray*} -\frac{dy}{dx} & = & \ln(x+1) + \frac{x+1}{x+1}\\ - & = & 1 + \ln(x+1). -\end{eqnarray*}} - -\newproblem{diffeasy:glng}{% -$f(x) = g(x)\ln(g(x))$.}{% -\begin{eqnarray*} -f'(x) & = & g'(x)\ln(g(x)) + \frac{g(x)}{g(x)}g'(x)\\ - & = & g'(x)(1+\ln(g(x))). -\end{eqnarray*}} - -\newproblem{diffeasy:sinx/x}{% -$y = \frac{\sin x}{x}$.}{% -\[\frac{dy}{dx} = \frac{\cos x}{x} - \frac{\sin x}{x^2}\]} - -% \begin{macrocode} -%</easy.tex> -% \end{macrocode} -% \begin{macrocode} -%<*implicit.tex> -% \end{macrocode} -% These are all implicit differentiation problems - -\newproblem{imd:circ}{% -Find the gradient of the unit circle ($x^2 + y^2 = 1$).}{% -Differentiating with respect to $x$ gives: -\begin{eqnarray*} -2x + 2y\frac{dy}{dx} & = & 0\\ -\frac{dy}{dx} & = & \frac{-2x}{2y}\\ - & = & \frac{-x}{\sqrt{1-x^2}}. -\end{eqnarray*}} - -\newproblem{imd:ysq:xcuov2mx}{% -Find $\frac{dy}{dx}$, given -\begin{displaymath} -y^2 = \frac{x^3}{2-x} -\end{displaymath}}{% -Differentiating both sides w.r.t.\ $x$: -\begin{eqnarray*} -2y\frac{dy}{dx} & = & \frac{(2-x)3x^2 - x^3(-1)}{(2-x)^2}\\ - & = & \frac{3x^2(2-x) + x^3}{(2-x)^2}\\ - & = & \frac{6x^2 - 3x^3 + x^3}{(2-x)^2}\\ - & = & \frac{6x^2-2x^3}{(2-x)^2}\\ - & = & 2x^2\frac{3-x}{(2-x)^2} -\end{eqnarray*} -Therefore -\begin{displaymath} -y\frac{dy}{dx} = x^2\frac{3-x}{(2-x)^2} -\end{displaymath}} - -\newproblem{imd:exy:IIxay}{% -Differentiate w.r.t.\ $x$: -\begin{displaymath} -e^{xy} = 2x + y -\end{displaymath}}{% -Differentiating both sides w.r.t.\ $x$: -\begin{eqnarray*} -e^{xy}(1y + x\frac{dy}{dx}) & = & 2 + \frac{dy}{dx}\\ -xe^{xy}\frac{dy}{dx} - \frac{dy}{dx} & = & 2 - ye^{xy} \\ -\frac{dy}{dx}(xe^{xy}-1) & = & 2 - ye^{xy}\\ -\frac{dy}{dx} & = & \frac{2-ye^{xy}}{xe^{xy}-1} -\end{eqnarray*}} -% \begin{macrocode} -%</implicit.tex> -% \end{macrocode} -% \begin{macrocode} -%<*mchoice.tex> -% \end{macrocode} -\newproblem{mc:prod}{% -Which of the following is the derivative of $x\sin(x)$? -(Circle the correct answer.) -\ifthenelse{\boolean{showanswers}}{}% -{\begin{description} -\item[A] $\sin(x)$ -\item[B] $x\cos(x)$ -\item[C] $\sin(x) + x\cos(x)$ -\end{description} -}}{% -\begin{description} -\item[A] $\sin(x)$ -\item[B] $x\cos(x)$ -\item[\textcircled{C}] $\sin(x) + x\cos(x)$ (product rule). -\end{description} -} - -\newproblem{mc:quot}{% -Which of the following is the derivative of $\frac{\sin(x)}{x}$? -(Circle the correct answer.) -\ifthenelse{\boolean{showanswers}}{}% -{\begin{description} -\item[A] $\sin(x)$ -\item[B] $\cos(x)$ -\item[C] $\frac{\cos(x)x-\sin(x)}{x^2}$ -\end{description} -}}{% -\begin{description} -\item[A] $\sin(x)$ -\item[B] $\cos(x)$ -\item[\textcircled{C}] $\frac{\cos(x)x-\sin(x)}{x^2}$ -(quotient rule) -\end{description} -} -% \begin{macrocode} -%</mchoice.tex> -% \end{macrocode} -% \begin{macrocode} -%<*sample.tex> -% \end{macrocode} -\documentclass[a4paper]{article} - -\usepackage{probsoln} -%uncomment the following line to display the answers -\showanswers - -% The following will generate a different set of -% problems in subsequent years -\PSNrandseed{\year} - -\begin{document} -\title{Sample Problem Sheet} -\author{Nicola Talbot} -\maketitle - -\begin{enumerate} -% Differentiation from first principles -\selectrandomly{1stprncp}{1} - -\item Differentiate the following functions: -\begin{enumerate} -\selectrandomly{easy}{5} -\end{enumerate} - -% Implicit differentiation -\selectrandomly{implicit}{2} - -% Multiple choice question -\selectrandomly{mchoice}{1} -\end{enumerate} -\end{document} -% \begin{macrocode} -%</sample.tex> -% \end{macrocode} -% \begin{macrocode} -%<*sample2.tex> -% \end{macrocode} -\documentclass[a4paper]{article} - -\usepackage{probsoln} -%uncomment the following line to display the answers -\showanswers - -% The following will generate a different set of -% problems in subsequent years -%\PSNrandseed{\year} - -% The following will generate a different set of -% problems on every run (where each run is at -% least a minute apart from the previous one) -\PSNrandseed{\time} - -\begin{document} -\title{Sample Problem Sheet} -\author{Nicola Talbot} -\maketitle - -\begin{enumerate} - -\newcounter{numproblems} -% store a random number from 1 to 3 in the counter numproblems -\random{numproblems}{1}{3} - -% selects 1,2 or 3 problems from 1 of the given files: -\doforrandN{1}{\file}{1stprncp,implicit}{\selectrandomly{\file}{\value{numproblems}}} - -\item Differentiate the following functions: -\input{args}% load database -\begin{enumerate} -\newcounter{A} -\newcounter{B} -\newcounter{C} -\random{A}{-4}{5} -\random{B}{-3}{3} -\random{C}{-1}{10} -\item \useproblem{diff:quad}{\arabic{A}}{\arabic{B}}{\arabic{C}} - -\random{A}{-5}{5} -% make sure its not 0 -\whiledo{\value{A}=0}{\random{A}{-5}{5}} -\item \useproblem{diff:sin}{\arabic{A}} -\end{enumerate} -\end{enumerate} -\end{document} -% \begin{macrocode} -%</sample2.tex> -% \end{macrocode} -% \begin{macrocode} -%<*sample3.tex> -% \end{macrocode} -\documentclass[a4paper]{article} - -\usepackage{longtable} -\usepackage{probsoln} - -%\showanswers - -\newcounter{problem} -\renewcommand{\PSNitem}{\refstepcounter{problem}% -\theproblem. } -\renewcommand{\endPSNitem}{\\} - -\renewenvironment{solution}{}{} - -\newcommand{\selected}{\fbox{$\times$}} -\newcommand{\notselected}{\fbox{\phantom{$\times$}}} - -\begin{document} -\begin{longtable}{lrrrl} -\bfseries Question & \bfseries A & \bfseries B & -\bfseries C & \ifshowanswers \bfseries Reason\fi\\ -\selectrandomly{tabmchoice}{2} -\end{longtable} -\end{document} -% \begin{macrocode} -%</sample3.tex> -% \end{macrocode} -% \begin{macrocode} -%<*sample4.tex> -% \end{macrocode} -\documentclass[a4paper]{article} - -\usepackage{probsoln} - -% Sample file illustrating use of \selectallproblems -% All problems defined in specified file will be used -% in order of definition - -\showanswers - -\begin{document} -Differentiate the following functions: -\begin{enumerate} -\selectallproblems{easy} -\end{enumerate} -\end{document} -% \begin{macrocode} -%</sample4.tex> -% \end{macrocode} -% \begin{macrocode} -%<*tabmchoice.tex> -% \end{macrocode} -% These problems are designed to be placed in a -% tabular environment -% -\newproblem{tab:1}{% -What is $(3+2)\times5$? & -25 \ifshowanswers\selected\else\notselected\fi & -13 \notselected & -10 \notselected & -}{Brackets come first}% -% -\newproblem{tab:2}{% -What is $-1+2\times3$? & -3 \notselected & --7 \notselected & -5 \ifshowanswers\selected\else\notselected\fi & -}{Multiplication comes first}% -% \begin{macrocode} -%</tabmchoice.tex> -% \end{macrocode} +%\fi %\Finale \endinput |