Debian Codegraph @

texmf-dist/doc/latex/mi-solns/docs/mi-solnsman.tex

raw
1 \documentclass{article}
2 \usepackage[fleqn]{amsmath}
3 \usepackage[
4 web={centertitlepage,designv,forcolorpaper,tight*,latextoc,pro},
5 exerquiz={nosolutions},eforms,aebxmp
6 ]{aeb_pro}
7 \let\protected\relax
8 \usepackage{mi-solns}
9 %\usepackage{eq-save}
10 %\usepackage[ImplMulti]{dljslib}
11 %\usepackage{graphicx,array,fancyvrb}
12 \usepackage{aeb_mlink}
13 %\usepackage{myriadpro}
14 %\usepackage{calibri}
15
16 \usepackage[altbullet]{lucidbry}
17
18 \def\hardspace{{\fontfamily{cmtt}\selectfont\symbol{32}}}
19 \newif\ifmiswitch \miswitchfalse
20
21 \usepackage{acroman}
22
23 \usepackage[active]{srcltx}
24
25 \urlstyle{tt}
26
27
28
29 \def\STRUT{\rule{0pt}{14pt}}
30 %\useBeginQuizButton[\CA{Begin}]
31 %\useEndQuizButton[\CA{End}]
32 \def\SOL{\textsf{SOL}}
33 \def\QSL{\textsf{QSL}}
34
35 \makeatletter
36 \def\eExmpl{\eq@fititin{\mbox{\exrtnlabelformatwp}}}
37 \newcount\hesheCnt \hesheCnt=-1
38 \def\heshe{\@ifstar{\heshei}{\global\advance\hesheCnt\@ne\heshei}}
39 \def\heshei{\ifodd\hesheCnt she\else he\fi}
40 \def\HeShe{\@ifstar{\HeShei}{\global\advance\hesheCnt\@ne\HeShei}}
41 \def\HeShei{\ifodd\hesheCnt She\else He\fi}
42 \def\hisher{\@ifstar{\hisheri}{\global\advance\hesheCnt\@ne\hisheri}}
43 \def\hisheri{\ifodd\hesheCnt her\else his\fi}
44 \def\himher{\@ifstar{\himheri}{\global\advance\hesheCnt\@ne\himheri}}
45 \def\himheri{\ifodd\hesheCnt her\else him\fi}
46 \makeatother
47
48 \DeclareDocInfo
49 {
50 university={\AcroTeX.Net},
51 title={The \textsf{mi-solns} Package},
52 author={D. P. Story},
53 email={[email protected]},
54 subject=Documentation for the mi-solns package,
55 talksite={\url{www.acrotex.net}},
56 version={0.6, 2018/12/29},
57 Keywords={LaTeX, AeB, exercises, quizzes, mark and insert solutions},
58 copyrightStatus=True,
59 copyrightNotice={Copyright (C) \the\year, D. P. Story},
60 copyrightInfoURL={http://www.acrotex.net}
61 }
62
63 \universityLayout{fontsize=Large}
64 \titleLayout{fontsize=LARGE}
65 \authorLayout{fontsize=Large}
66 \tocLayout{fontsize=Large,color=aeb}
67 \sectionLayout{indent=-62.5pt,fontsize=large,color=aeb}
68 \subsectionLayout{indent=-31.25pt,color=aeb}
69 \subsubsectionLayout{indent=0pt,color=aeb}
70 \subsubDefaultDing{\texorpdfstring{$\bullet$}{\textrm\textbullet}}
71
72 \chngDocObjectTo{\newDO}{doc}
73 \begin{docassembly}
74 var titleOfManual="The mi-solns Package";
75 var manualfilename="Manual_BG_Print_mi-solns.pdf";
76 var manualtemplate="Manual_BG_Brown.pdf"; // Blue, Green, Brown
77 var _pathToBlank="C:/Users/Public/Documents/ManualBGs/"+manualtemplate;
78 var doc;
79 var buildIt=false;
80 if ( buildIt ) {
81 console.println("Creating new " + manualfilename + " file.");
82 doc = \appopenDoc({cPath: _pathToBlank, bHidden: true});
83 var _path=this.path;
84 var pos=_path.lastIndexOf("/");
85 _path=_path.substring(0,pos)+"/"+manualfilename;
86 \docSaveAs\newDO ({ cPath: _path });
87 doc.closeDoc();
88 doc = \appopenDoc({cPath: manualfilename, oDoc:this, bHidden: true});
89 f=doc.getField("ManualTitle");
90 f.value=titleOfManual;
91 doc.flattenPages();
92 \docSaveAs\newDO({ cPath: manualfilename });
93 doc.closeDoc();
94 } else {
95 console.println("Using the current "+manualfilename+" file.");
96 }
97 var _path=this.path;
98 var pos=_path.lastIndexOf("/");
99 _path=_path.substring(0,pos)+"/"+manualfilename;
100 \addWatermarkFromFile({
101 bOnTop:false,
102 bOnPrint:false,
103 cDIPath:_path
104 });
105 \executeSave();
106 \end{docassembly}
107
108
109 \begin{document}
110
111 \maketitle
112
113 \selectColors{linkColor=black}
114 \tableofcontents
115 \selectColors{linkColor=webgreen}
116
117
118 \section{Introduction}
119
120 The name of the package is \pkg{mi-solns}, where `m' is for `mark' and `i' is
121 for `insert'. So the \pkg{mi-solns} package can mark and insert solutions
122 (created by the \pkg{exerquiz} and \pkg{eqexam} packages).
123
124 The \pkg{exerquiz}
125 (\href{https://www.ctan.org/pkg/acrotex}{ctan.org/pkg/acrotex}) and
126 \pkg{eqexam} (\href{https://www.ctan.org/pkg/eqexam}{ctan.org/pkg/eqexam})
127 packages are capable of creating questions and solutions to exercises and
128 quizzes. The purpose of this package is to present commands for marking, and
129 for inserting any marked solution---for whatever reason---into the body of
130 the document.\footnote{A solution may be inserted into anohter solution, but
131 may not be inserted into itself.} To accomplish this goal, recent versions
132 of \pkg{exerquiz} and \pkg{eqexam} are required (dated 2018/12/13 or later);
133 also required is the \pkg{shellesc} package
134 (\href{https://ctan.org/pkg/shellesc}{ctan.org/pkg/shellesc}).
135
136 While the document is being compiled, the solution files (\SOL{} and \QSL) are
137 being written to, so we cannot input them or read them. What we do is to make
138 a copy of the solution files from within the operating system, and input the
139 copy back into the body of the document when required. Consequently, it is
140 necessary to activate the feature of executing an OS script from within the
141 compiling operation. To activate the feature, the document needs to be
142 compiled with the \texttt{-{}-shell-escape} switch (for
143 \app{latex}, \app{pdflatex}, \app{lualatex}, or \app{xelatex}, depending on
144 your workflow).
145
146 \paragraph*{Description of workflow.} The procedure is simple and short: (1)
147 mark a solution for insertion (\cs{mrkForIns\darg{\ameta{name}}}), just above
148 the \env{solution} environment; and (2) insert the solution with
149 \cs{insExSoln\darg{\ameta{name}}}, \cs{insSqSoln\darg{\ameta{name}}}, or
150 \cs{insQzSoln\darg{\ameta{name}}}, depending on whether the solution came
151 from an \env{exercise}, \env{shortquiz}, or \env{quiz} environment.
152
153 \paragraph*{Demo files.} There are four demonstration files.
154 \begin{itemize}
155 \item \texttt{mi-solns-eq.tex} uses \pkg{exerquiz} to test the features
156 of \pkg{mi-solns}.
157 \item \texttt{mi-solns-eqe.tex} uses \pkg{eqexam} to test the features
158 of \pkg{mi-solns}.
159 \item \texttt{create-db.tex} part of a novel idea, it is an application for changing
160 the output file names. Compiling this file creates \texttt{poems.lst}, which is a very small database
161 of poetic quotations.
162 \item \texttt{use-db.tex} is the companion file to
163 \texttt{create-db.tex}. Once \texttt{poems.lst} is created, compile
164 \texttt{use-db.tex}, which will input \texttt{poems.lst} and
165 display the quotations.
166 \end{itemize}
167
168 \section{Copying the \texorpdfstring{\SOL\space and \QSL}{SOL and QSL} files}
169
170 Assuming you have determined how to compile using the
171 \texttt{-{}-shell-escape} switch, when you compile a \pkg{mi-solns} document,
172 the files \cs{jobname.sol} and \cs{jobname.qsl} are copied at the end of the
173 document. The destination filenames are \cs{jobname-cpy.sol} and
174 \cs{jobname-cpy.qsl} by default, but these names can be changed through the
175 commands \cs{declSOLOut} and \cs{declQSLOut}.
176 \bVerb\takeMeasure{\string\declSOLOut\darg{\ameta{sol-out}}}%
177 \setlength\aebscratch{\bxSize}%
178 \def\1{\makebox[0pt][l]{\hspace{\aebscratch}\enspace\makebox[0pt][l]{\normalfont(\cs{declSOLIn\darg{\string\jobname.sol}})}}}%
179 \def\2{\makebox[0pt][l]{\hspace{\aebscratch}\enspace\makebox[0pt][l]{\normalfont(\cs{declSOLOut\darg{\string\jobname-cpy.sol}})}}}%
180 \def\3{\makebox[0pt][l]{\hspace{\aebscratch}\enspace\makebox[0pt][l]{\normalfont(\cs{declQSLIn\darg{\string\jobname.qsl}})}}}%
181 \def\4{\makebox[0pt][l]{\hspace{\aebscratch}\enspace\makebox[0pt][l]{\normalfont(\cs{declQSLOut\darg{\string\jobname-cpy.qsl}})}}}%
182 \begin{dCmd}[commandchars=!(),commentchar=\%]{\bxSize}
183 %!1\declSOLIn{!ameta(sol-in)}
184 !2\declSOLOut{!ameta(sol-out)}
185 %!3\declQSLIn{!ameta(qsl-in)}
186 !4\declQSLOut{!ameta(qsl-out)}
187 \end{dCmd}
188 \eVerb At the end of the document, the following OS operations occur:
189 \begin{itemize}
190 \item Copy \cs{jobname.sol} to \ameta{sol-out} (\cs{jobname.sol} to \cs{jobname-cpy.sol})
191 \item Copy \cs{jobname.qsl} to \ameta{qsl-out} (\cs{jobname.qsl} to \cs{jobname-cpy.qsl})
192 \end{itemize}
193 Freely change the names of the output files according to your own whims.
194
195 \paragraph*{The copy commands.} The following two commands expand the run-time scripts for
196 copying one file to another.
197 \bVerb\takeMeasure{\string\newcommand\darg{\string\copyfileCmdEx}\darg{copy \string\jobname.sol \string\misolout}}%
198 \setlength\aebscratch{\bxSize}%
199 \begin{dCmd}[commandchars=!()]{\bxSize}
200 \newcommand{\copyfileCmdEx}{copy \jobname.sol \misolout}
201 \newcommand{\copyfileCmdQz}{copy \jobname.qsl \miqslout}
202 \end{dCmd}
203 \eVerb where \cs{misolout} and \cs{miqslout} expand to the names assigned by
204 the declarations \cs{declSOLOut} and \cs{declQSLOut}, respectively. These are
205 the definitions for \app{Windows} OS, it might be necessary to redefine these
206 commands corresponding to the OS in which you reside.
207
208 \paragraph*{Turn copying on and off.} The SOL and QSL files are automatically copied, by default;
209 however, this operation can be turned off.
210 \bVerb\takeMeasure{\string\copySolnsOn\qquad\string\copySolnsOff}%
211 \setlength\aebscratch{\bxSize}%
212 \def\1{\makebox[0pt][l]{\hspace{\aebscratch}\enspace\makebox[0pt][l]{\sffamily(preamble only)}}}%
213 \def\2{\makebox[0pt][l]{\hspace{\aebscratch}\enspace\makebox[0pt][l]{\sffamily(anywhere)}}}%
214 \begin{dCmd}[commandchars=!()]{\bxSize}
215 !1\copySolnsOn!qquad\copySolnsOff
216 !2\readSolnsOn!qquad\readSolnsOff
217 \end{dCmd}
218 \eVerb \cs{copySolnsOn} is the default, it causes the solutions to be copied
219 at the end of the document; \cs{copySolnsOff} turns off the copying. Why
220 would you do this? Well, if you have completed composing your solutions and
221 you are concentrating on the other content of the document, there is no need
222 to repeatedly copy the solution files. Perhaps turn it on for the final
223 \emph{two compiles}. Yes, you read correctly, two compiles. Since the
224 solution files are copied at the end of the document, the refreshed
225 \ameta{sol-out} and \ameta{qsl-out} files do not get read until the next
226 compile.
227
228 \cs{readSolnsOn} is initially expanded by the package, so it is the default. If you expand \cs{readSolnsOff}, the commands
229 \cs{insExSoln}, \cs{insSqSoln}, and \cs{insQzSoln} do not input their target file; instead
230 \cs{miReadOffMsg} is typeset. The default definition of this command is,
231 \begin{Verbatim}[xleftmargin=\parindent]
232 \newcommand\miReadOffMsg{(\textbf{?? read is off ??})}
233 \end{Verbatim}
234 This command may be redefined as desired.
235
236 \section{Marking a solution}
237
238 The first step is to mark a solution you wish to insert elsewhere in the document.
239 \bVerb\takeMeasure{\string\mrkForIns\darg{\ameta{name}}}%
240 \setlength\aebscratch{\bxSize}%
241 \begin{dCmd}[commandchars=!()]{\bxSize}
242 \mrkForIns{!ameta(name)}
243 \end{dCmd}
244 \eVerb The placement is just above the targeted \env{solution} environment.
245 \begin{Verbatim}[xleftmargin=\parindent,commandchars=!()]
246 !textbf(\mrkForIns{!ameta(name)})
247 \begin{solution}[!ameta(options)]
248 !quad!ameta(solution)
249 \end{solution}
250 \end{Verbatim}
251 Here, \ameta{name} is a word consisting of only ASCII characters. As the \ameta{sol-out} file is read in,
252 a simple string comparison is performed. If \pkg{mi-solns} is not displaying the solution you want to insert,
253 this could be the problem; simplify the word(s) used for the \ameta{name} argument.
254
255 %\insExSoln[\ignoreques]{dps}
256
257 Below is a simple example we'll work with throughout the rest of this documentation.
258
259 \begin{exercise}\label{ex:First}
260 \begin{cq}An intelligent question.\end{cq}
261 \mrkForIns{myIQ}
262 \begin{solution}
263 A brilliant answer to the intelligent question.
264 \ifmiswitch(D. P. Story)\fi
265 \end{solution}
266 \end{exercise}
267 The verbatim listing is,
268 \begin{Verbatim}[xleftmargin=\parindent,commandchars={!@^}]
269 \newif\ifmiswitch \miswitchfalse %!sffamily@ used in Example 4^
270 ...
271 \begin{exercise}
272 \begin{cq}An intelligent question.\end{cq}
273 !textbf@\mrkForIns{myIQ}^
274 \begin{solution}
275 A brilliant answer to the intelligent question.
276 \ifmiswitch(D. P. Story)\fi
277 \end{solution}
278 \end{exercise}
279 \end{Verbatim}
280 Continue to the next section for information on how to insert the solution
281 into the document.
282
283 \section{Inserting a solution}
284
285 The second step is to insert the solution into the document. There are three
286 commands for inserting marked content back in the document.
287 \bVerb\takeMeasure{\string\insExSoln[\ameta{inserts}]\darg{\ameta{name}}}%
288 \setlength\aebscratch{\bxSize}%
289 \setlength\aebscratch{\bxSize}%
290 \def\1{\makebox[0pt][l]{\hspace{\aebscratch}\enspace\makebox[0pt][l]{\sffamily(for \env{exercise} env.)}}}%
291 \def\2{\makebox[0pt][l]{\hspace{\aebscratch}\enspace\makebox[0pt][l]{\sffamily(for \env{shortquiz} env.)}}}%
292 \def\3{\makebox[0pt][l]{\hspace{\aebscratch}\enspace\makebox[0pt][l]{\sffamily(for \env{quiz} env.)}}}%
293 \begin{dCmd}[commandchars=!()]{\bxSize}
294 !1\insExSoln[!ameta(inserts)]{!ameta(name)}
295 !2\insSqSoln[!ameta(inserts)]{!ameta(name)}
296 !3\insQzSoln[!ameta(inserts)]{!ameta(name)}
297 \end{dCmd}
298 \eVerb where, \ameta{name} must match up with the \ameta{name} argument of a
299 \cs{mrkForIns} command somewhere in the document. For solution content to
300 appear correctly, the choice of the insertion command must match the
301 environment that has been marked. If you marked a solution to an exercise,
302 then use \cs{insExSoln} to insert that solution. This is possible error
303 point, if the \ameta{name} does not match up with the correct insertion
304 command.
305
306 The \ameta{inserts} optional parameter can be most anything that does not
307 disrupt the expansion of the \cs{ins??Soln} commands. \emph{It is placed
308 within a group.}\marginpar{\small\raggedleft\slshape\ameta{inserts} placed in
309 a group} This may be an interesting, useful, and significant feature,
310 depending on your imagination to use it. One command designed for the
311 \ameta{inserts} option for an exercise is \cs{ignoreques}. This is
312 discussed in \textbf{Example~2} below.
313
314 \paragraph*{Example~1.} Insert the solution to \textsc{\hyperref[ex:First]{Exercise~\ref*{ex:First}}}: \insExSoln{myIQ}
315 \begin{Verbatim}[xleftmargin=\parindent,commandchars=!()]
316 (!sffamily(Insert the solution to !ameta(link removed):)) !textbf(\insExSoln{myIQ})
317 \end{Verbatim}
318 The above is the verbatim listing. It's just that simple! However, the
319 question to the problem also appears! Continue this problem with
320 \textbf{Example~2}.\eExmpl
321
322 \paragraph*{Example~2.} \textsc{\hyperref[ex:First]{Exercise~\ref*{ex:First}}} has its question
323 enclosed in the \env{cq} environment. This environment passes
324 the question along with the solution. If we don't want to include the
325 question, pass a special command \cs{ignoreques} in the optional
326 \ameta{inserts} argument. The expansion of
327 \verb~``\insExSoln[\ignoreques]{myIQ}''~ is
328 ``\insExSoln[\ignoreques]{myIQ}''\eExmpl
329
330 \def\myFmt{\declCQPre{\emph{\textcolor{blue}{\cqQStr}:}\space}%
331 \declCQPost{\par\medskip\noindent\emph{\textcolor{blue}{\cqSStr}:}\space\ignorespaces}}
332
333 \paragraph*{Example~3.} Again referring to \textsc{\hyperref[ex:First]{Exercise~\ref*{ex:First}}}, the
334 \env{cq} environment (defined in \pkg{exerquiz} and \pkg{eqexam}) has certain
335 formatting controls. We can pass some formatting commands through the
336 \ameta{inserts} argument without affecting other \env{cq} environments in the
337 document. For example,
338 \par\medskip\noindent
339 \insExSoln[\myFmt]{myIQ}
340 \begin{Verbatim}[xleftmargin=\parindent,commandchars=!(),fontsize=\small]
341 \newcommand\myFmt{\declCQPre{\emph{\textcolor{blue}{\cqQStr}:}\space}%
342 \declCQPost{\par\medskip\noindent
343 \emph{\textcolor{blue}{\cqSStr}:}\space\ignorespaces}}
344 \end{Verbatim}
345 Verbatim listing:
346 {\let\leftmargini\parindent
347 \begin{quote}
348 \textsf{For example,}\texttt{\cs{par}\string\medskip\string\noindent\textbf{\string\insExSoln[\string\myFmt]\darg{myIQ}}}
349 \end{quote}}\noindent
350 Be sure not to introduce any spurious spaces.\eExmpl
351
352 \paragraph*{Example~4.} (\textbf{Conditional content}) The \ameta{solution} can have conditional content, which
353 may be controlled locally by passing the state of a Boolean switch through the \ameta{inserts} argument.
354 \begin{Verbatim}[xleftmargin=\parindent,commandchars=!(),fontsize=\small]
355 \newif\ifmiswitch \miswitchfalse
356 ...
357 (!normalfont!sffamily(This code results in ))``!textbf(\insExSoln[\ignoreques\miswitchtrue]{myIQ})''
358 \end{Verbatim}
359 This code results in ``\insExSoln[\ignoreques\miswitchtrue]{myIQ}''\eExmpl
360
361 \paragraph*{Example~5.} (\textbf{Changing \ameta{sol-out}}) There is a file \texttt{poems.lst} produced by
362 the demo file \texttt{create-db.tex}; here, we insert one of the verses by
363 changing the \ameta{sol-out} file.\medskip \bVerb
364 \begin{minipage}[t]{2in+20pt}
365 \begin{flushleft}\setlength{\baselineskip}{0pt}\setlength{\leftmargini}{15pt}
366 \textbf{The Lama} by \textbf{Ogden Nash}
367 \insExSoln[\declSOLOut{poems.lst}]{The Lama}
368 \end{flushleft}
369 \end{minipage}\hfill
370 \begin{minipage}[t]{\linewidth-2in-20pt}
371 Verbatim listing of the poem:\\[3pt]
372 {\ttfamily\small\string\insExSoln[\textbf{\string\declSOLOut\darg{poems.lst}}]\darg{The Lama}}
373 \end{minipage}\medskip
374 \eVerb Refer to demo files \texttt{create-db.tex} and \texttt{use-db.tex}.\eExmpl
375
376 \section{Building the solution sets}
377
378 We can extract the solution to a problem only if the solution file is fully
379 built. Generally, the solution sets are fully built when the solutions appear
380 at the end of the file, but that is not the only situation. The following
381 list summarizes the options for which the solution files are created in their
382 entirety.
383 \begin{itemize}
384 \item For the \pkg{exerquiz} package, any option other than \texttt{solutionsafter}.
385 This includes the following options: \texttt{nosolutions}, \texttt{noquizsolutions},
386 \texttt{vspacewithsolns}, and no solution-related option at all
387 (\verb~\usepackage{exerquiz}~). Hidden solutions are not displayed.
388 \item For the \pkg{eqexam} package, any option other than
389 \texttt{solutionsafter} and \texttt{answerkey}. This includes the
390 following options: \texttt{nosolutions},
391 \texttt{vspacewithsolns}, and no solution-related option at all
392 (\verb~\usepackage{eqexam}~). Hidden solutions are not displayed.
393 \end{itemize}
394 You can insert solutions even when the \texttt{answerkey} or
395 \texttt{solutionsafter} option is in effect. First compile with
396 \texttt{vspaceiwithsolns},\footnote{This creates fully built \ameta{sol-out}
397 and \ameta{qsl-out} files.} for example, then place \cs{copySolnsOff} in the
398 preamble and compile again with the \texttt{answerkey} or
399 \texttt{solutionsafter} option. The insertions will then appear on the next
400 compile.
401
402 \section{My retirement}
403
404 Now, I simply must get back to it. \dps
405
406 \end{document}