| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2025 by Walter Daems <[email protected]> |
| 4 |
% |
| 5 |
% This work may be distributed and/or modified under the conditions of |
| 6 |
% the LaTeX Project Public License, either version 1.3 of this license |
| 7 |
% or (at your option) any later version. The latest version of this |
| 8 |
% license is in: |
| 9 |
% |
| 10 |
% http://www.latex-project.org/lppl.txt |
| 11 |
% |
| 12 |
% and version 1.3 or later is part of all distributions of LaTeX version |
| 13 |
% 2005/12/01 or later. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status `maintained'. |
| 16 |
% |
| 17 |
% The Current Maintainer of this work is Walter Daems. |
| 18 |
% |
| 19 |
% This work consists of the files exsol.dtx and exsol.ins and the derived |
| 20 |
% files: |
| 21 |
% - exsol.sty |
| 22 |
% - example.tex |
| 23 |
% - example-solutionbook.tex |
| 24 |
% - example-formulacollection.tex |
| 25 |
% - example-local.tex |
| 26 |
% \fi |
| 27 |
% |
| 28 |
% \iffalse |
| 29 |
% |
| 30 |
%<package|driver>\NeedsTeXFormat{LaTeX2e} |
| 31 |
%<driver>\ProvidesFile{exsol.dtx} |
| 32 |
%<package>\ProvidesPackage{exsol} |
| 33 |
%<package|driver> [2025/02/14 v1.7 ExSol - Exercises and Solutions package (DMW)] |
| 34 |
%<*driver> |
| 35 |
\documentclass[10pt,a4paper]{ltxdoc} |
| 36 |
\usepackage[english]{babel} |
| 37 |
\usepackage[exercisesfontsize=small]{exsol} |
| 38 |
\usepackage{booktabs} |
| 39 |
\usepackage{metalogo} |
| 40 |
\EnableCrossrefs |
| 41 |
\CodelineIndex |
| 42 |
\RecordChanges |
| 43 |
\usepackage{makeidx} |
| 44 |
\usepackage{alltt} |
| 45 |
\IfFileExists{tocbibind.sty}{\usepackage{tocbibind}}{} |
| 46 |
\IfFileExists{hyperref.sty}{\usepackage[bookmarksopen]{hyperref}}{} |
| 47 |
\EnableCrossrefs |
| 48 |
\CodelineIndex |
| 49 |
\RecordChanges |
| 50 |
\newcommand{\exsol}{\textsc{ExSol}} |
| 51 |
\StopEventually{\PrintChanges\PrintIndex} |
| 52 |
\def\fileversion{1.7} |
| 53 |
\def\filedate{2025/02/14} |
| 54 |
\begin{document} |
| 55 |
\DocInput{exsol.dtx} |
| 56 |
\end{document} |
| 57 |
%</driver> |
| 58 |
% \fi |
| 59 |
% |
| 60 |
% \CheckSum{0} |
| 61 |
% |
| 62 |
% \CharacterTable |
| 63 |
% {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 |
| 64 |
% Lower-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 |
| 65 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 66 |
% Exclamation \! Double quote \" Hash (number) \# |
| 67 |
% Dollar \$ Percent \% Ampersand \& |
| 68 |
% Acute accent \' Left paren \( Right paren \) |
| 69 |
% Asterisk \* Plus \+ Comma \, |
| 70 |
% Minus \- Point \. Solidus \/ |
| 71 |
% Colon \: Semicolon \; Less than \< |
| 72 |
% Equals \= Greater than \> Question mark \? |
| 73 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 74 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 75 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 76 |
% Right brace \} Tilde \~} |
| 77 |
% |
| 78 |
% |
| 79 |
% \changes{v0.1}{2012/01/05}{\@ Initial version} |
| 80 |
% \changes{v0.2}{2012/01/06}{\@ Minor bug fixes based on first use by |
| 81 |
% Paul Levrie} |
| 82 |
% \changes{v0.3}{2012/01/07}{\@ Minor bug fixes based on second use by |
| 83 |
% Paul} |
| 84 |
% \changes{v0.4}{2012/01/09}{\@ Allowed for non-list formatting of |
| 85 |
% exercises (as default)} |
| 86 |
% \changes{v0.5}{2012/01/15}{\@ Added option to also send exercises to |
| 87 |
% solutions file} |
| 88 |
% \changes{v0.6}{2013/05/12}{\@ Prepared for CTAN publication} |
| 89 |
% \changes{v0.7}{2014/07/14}{\@ Fixed UTF8 compatibility issues} |
| 90 |
% \changes{v0.8}{2014/07/15}{\@ Fixed missing babel tag and running out |
| 91 |
% of write handles} |
| 92 |
% \changes{v0.9}{2014/07/28}{\@ Changed default behavior |
| 93 |
% w.r.t. minipage-wrapping of exercises} |
| 94 |
% \changes{v0.91}{2014/08/31}{\@ Corrected minipage dependence, made } |
| 95 |
% \changes{v1.0}{2015/09/16}{\@ First stable release} |
| 96 |
% \changes{v1.1}{2015/12/30}{\@ Bugfix release} |
| 97 |
% \changes{v1.2}{2016/05/05}{\@ Implemented multicolumn option for |
| 98 |
% exercises, introduced new options (local, nolabels), separate |
| 99 |
% counter for exerciseseries (only for use local mode), introduced |
| 100 |
% local mode} |
| 101 |
% \changes{v1.3}{2016/08/09}{\@ Correction of spacings and counters} |
| 102 |
% \changes{v1.4}{2018/10/23}{\@ Allowed for adding exerciseseries label in |
| 103 |
% solutionseries using option 'usesolutionserieslabels'} |
| 104 |
% \changes{v1.5}{2019/01/02}{\@ Added inline and external mode} |
| 105 |
% \changes{v1.6}{2024/01/07}{\@ Added check to see if babel was |
| 106 |
% loaded, and issue appropriate error} |
| 107 |
% \changes{v1.7}{2025/02/14}{\@ Ensured compatibility with spelatex package} |
| 108 |
% |
| 109 |
% \DoNotIndex{\newcommand,\newenvironment} |
| 110 |
% \setlength{\parindent}{0em} |
| 111 |
% \addtolength{\parskip}{0.5\baselineskip} |
| 112 |
% |
| 113 |
% \title{The \exsol{} package\thanks{This document |
| 114 |
% corresponds to exsol~\fileversion, dated \filedate.}} |
| 115 |
% \author{Walter Daems (\texttt{[email protected]})} |
| 116 |
% \date{} |
| 117 |
% |
| 118 |
% \maketitle |
| 119 |
% |
| 120 |
% \section{Introduction} |
| 121 |
% %%%%%%%%%%%%%%%%%%%%%% |
| 122 |
% |
| 123 |
% \subsection{Package goal} |
| 124 |
% The package \exsol{} provides macros to allow |
| 125 |
% embedding exercises and solutions in the \LaTeX{} source of an |
| 126 |
% instructional text (e.g., a book or a course text) while keeping the |
| 127 |
% exercises and the solutions seperately in the typeset result. |
| 128 |
% |
| 129 |
% In \emph{global mode} (the default), this corresponds to generating |
| 130 |
% the following separate documents: |
| 131 |
% \begin{itemize} |
| 132 |
% \item your original text that only contains the exercises, and |
| 133 |
% \item a solution book that only contains the solutions to the |
| 134 |
% exercises (a package option exists to also copy the exercises |
| 135 |
% themselves to the solution book). |
| 136 |
% \end{itemize} |
| 137 |
% The former is generated when running \LaTeX{} on your document. This |
| 138 |
% run writes the solutions to a secondary file that can be included |
| 139 |
% into a simple document harness, such that when running \LaTeX{} on |
| 140 |
% the latter, you can generate a nice solution book. |
| 141 |
% |
| 142 |
% In \emph{external mode} both the exercises and the solutions are |
| 143 |
% written to secondary files that can be included in a simple document |
| 144 |
% harness, such that when running \LaTeX{} on these, you can generate |
| 145 |
% an exercise as well as a solution book. |
| 146 |
% |
| 147 |
% In \emph{local mode} (invoked by specifying the package option 'local'), |
| 148 |
% this corresponds to inserting the saved solutions in the current |
| 149 |
% document at a later stage in the text. |
| 150 |
% |
| 151 |
% In \emph{inline mode} (invoked by specifying the package option |
| 152 |
% 'inline'), the solutions are inserted 'on the spot'. |
| 153 |
% |
| 154 |
% This has been conveniently summarized in the table below: |
| 155 |
% \begin{center} |
| 156 |
% \begin{tabular}{ccc} |
| 157 |
% \toprule |
| 158 |
% \bf mode & \bf exercises & \bf solutions\\ |
| 159 |
% \midrule |
| 160 |
% global & on the spot & in separate document\\ |
| 161 |
% external & in separate document & in separate document\\ |
| 162 |
% local & on the spot & later in the same document\\ |
| 163 |
% inline & on the spot & on the spot \\ |
| 164 |
% \bottomrule |
| 165 |
% \end{tabular} |
| 166 |
% \end{center} |
| 167 |
% \subsection{Why use \exsol{}?} |
| 168 |
% \begin{itemize} |
| 169 |
% \item It allows to keep the \LaTeX{} source of your exercises and their |
| 170 |
% solutions together in a single file, next to each other. Away with |
| 171 |
% the nightmare to keep your solutions in sync with the exercises! |
| 172 |
% \item It separates exercises and solutions, allowing you |
| 173 |
% \begin{itemize} |
| 174 |
% \item to only release the solution book to the instructors of the |
| 175 |
% course (using global mode); |
| 176 |
% \item to encourage students to first try solving the exercises |
| 177 |
% without peeking into the list of solutions (or the solution book). |
| 178 |
% \end{itemize} |
| 179 |
% \end{itemize} |
| 180 |
% |
| 181 |
% \subsection{Credits} |
| 182 |
% The code of the \exsol{} package was taken almost literally |
| 183 |
% from \textsf{fancyvrb} \cite{fancyvrb}. Therefore, all credits go to |
| 184 |
% the authors/maintainers of \textsf{fancyvrb}. |
| 185 |
% |
| 186 |
% Thanks to Paul Levrie, Pieter Pareit, Pekka Pere, Benjamin |
| 187 |
% Grinstein and Philippe Marti for signaling problems and making |
| 188 |
% suggestions for the improvement of the package and the |
| 189 |
% documentation. |
| 190 |
% |
| 191 |
% \subsection{Note} |
| 192 |
% As of version 1.2, the package also contains facilities for |
| 193 |
% generating a formula collection. The only limitation is that |
| 194 |
% exercises and solutions cannot be part of the formula collection. |
| 195 |
% Though this is a restriction, it is not a severe one in my |
| 196 |
% opinion. Formula collections should be as concise as they can be. |
| 197 |
% |
| 198 |
% Though generating formula collections goes beyond exercises and |
| 199 |
% solutions, I chose not to change the package's name |
| 200 |
% \exsol{}. Einstein's name was also not changed into Relativistic |
| 201 |
% Einstein when he got to understand the theory of relativity. |
| 202 |
% |
| 203 |
% \section{Installation} |
| 204 |
% %%%%%%%%%%%%%%%%%%%%%%%% |
| 205 |
% Either you are a package manager and then you'll know how to |
| 206 |
% prepare an installation package for \exsol{}. |
| 207 |
% |
| 208 |
% Either you are a normal user and then you have two options. First, |
| 209 |
% check if there is a package that your favorite \LaTeX{} |
| 210 |
% distributor has prepared for you. Second, grab the TDS package |
| 211 |
% from CTAN \cite{CTAN} (|exsol.tds.zip|) and unzip it |
| 212 |
% somewhere in your own TDS tree, regenerate your filename database |
| 213 |
% and off you go. |
| 214 |
% In any case, make sure that \LaTeX{} finds the |exsol.sty| |
| 215 |
% file. |
| 216 |
% |
| 217 |
% The \exsol{} package uses some auxiliary packages: |
| 218 |
% \textsf{fancyvrb}, |
| 219 |
% \textsf{ifthen}, \textsf{kvoptions} and, optionally, |
| 220 |
% \textsf{babel}. Fetch them from CTAN \cite{CTAN} if your \TeX{} |
| 221 |
% distributor does not provide them. |
| 222 |
% |
| 223 |
% \section{Usage} |
| 224 |
% %%%%%%%%%%%%%%%%% |
| 225 |
% |
| 226 |
% \subsection{Preparing your document source} |
| 227 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 228 |
% |
| 229 |
% \subsubsection{Loading the package} |
| 230 |
% The macro package exsol can be loaded with: |
| 231 |
% \begin{verbatim} |
| 232 |
% \usepackage{babel} |
| 233 |
% \usepackage{exsol} |
| 234 |
% \end{verbatim} |
| 235 |
% |
| 236 |
% Note before we start that you need to load the babel package before |
| 237 |
% you load the exsol package! This is to allow you to load the |
| 238 |
% appropriate languages for your text. |
| 239 |
% |
| 240 |
% OK, now let's get started. |
| 241 |
% |
| 242 |
% Your first choice to make is where you want your solutions to |
| 243 |
% appear. The primary objective of the exsol package was 'global |
| 244 |
% mode', i.e. separating your solutions from the exercises, |
| 245 |
% gathering the solutions in a separate book. |
| 246 |
% To this end, don't specify the package option '|[local]|', or |
| 247 |
% specify '|[local=false]|'. |
| 248 |
% |
| 249 |
% A second mode of operation is 'local mode'. This allows grouping |
| 250 |
% your exercises in series and including them later in your text. |
| 251 |
% Gathering exercises in (numbered) series and 'loading' them locally |
| 252 |
% in your text, allows for simplifying the |
| 253 |
% individual exercise numbers (omitting their prefix containing, |
| 254 |
% chapter number, section number, subsection number a.s.o.). |
| 255 |
% |
| 256 |
% A third mode of operation is 'inline mode', in which the |
| 257 |
% solution is inserted in the main text 'on the spot'. You can trigger |
| 258 |
% this, by specifying the package option 'inline'. |
| 259 |
% |
| 260 |
% \subsubsection{Global mode - flat grouping exercises} |
| 261 |
% Adding exercises together with their solutions in your document is |
| 262 |
% easy. Just embed them in a |
| 263 |
% |exercise| and a corresponding |solution| environment. |
| 264 |
% Optionally, you may embed several of them in a |exercises| |
| 265 |
% environment to make them stand out in your text. |
| 266 |
% |
| 267 |
% \begin{verbatim} |
| 268 |
% \begin{exercises}[columns=2] |
| 269 |
% |
| 270 |
% \begin{exercise} |
| 271 |
% Calculate $y = 5 + 7$ |
| 272 |
% \end{exercises} |
| 273 |
% \begin{solution} |
| 274 |
% $y = 12$ |
| 275 |
% \end{solution} |
| 276 |
% |
| 277 |
% \begin{exercise} |
| 278 |
% Calculate $y = 7 - 12$ |
| 279 |
% \end{exercises} |
| 280 |
% \begin{solution} |
| 281 |
% $y = -5$ |
| 282 |
% \end{solution} |
| 283 |
% |
| 284 |
% \end{exercises} |
| 285 |
% \end{verbatim} |
| 286 |
% |
| 287 |
% The optional argument of the exercises environment allows specifying |
| 288 |
% the typesetting in multiple columns. |
| 289 |
% |
| 290 |
% On how to generate a solution book, take a look at the examples in |
| 291 |
% section~\ref{examplesglobal}. |
| 292 |
% |
| 293 |
% \subsubsection{Local mode - grouping of exercises in series} |
| 294 |
% One might also consider to keep the solutions in the same text, in |
| 295 |
% local mode. In this case, we advise to gather the exercises in |
| 296 |
% series (e.g. according to their degree of difficulty). This can be |
| 297 |
% done by using the |exerciseseries| environment instead of the |
| 298 |
% |exercises| environment. |
| 299 |
% This environment takes and also takes a mandatory label argument. |
| 300 |
% In addition it takes two optional arguments: |
| 301 |
% \begin{itemize} |
| 302 |
% \item |columns| to specify the amount of clumns |
| 303 |
% \item |exsubrule| to specify the creation of a horizontal rule below |
| 304 |
% the exercise series. |
| 305 |
% \item |solsubrule| to specify the creation of a horizontal rule below |
| 306 |
% the solution series. |
| 307 |
% \item |subrule| to specify the creation of a horizontal rule below |
| 308 |
% the exercise and the solution series. |
| 309 |
% \end{itemize} |
| 310 |
% |
| 311 |
% |
| 312 |
% \begin{verbatim} |
| 313 |
% \begin{exerciseseries}[columns=2,subrule=\hrule]{Easy exercises} |
| 314 |
% |
| 315 |
% \begin{exercise} |
| 316 |
% Calculate $y = 5 + 7$ |
| 317 |
% \end{exercise} |
| 318 |
% \begin{solution} |
| 319 |
% $y = 12$ |
| 320 |
% \end{solution} |
| 321 |
% |
| 322 |
% \begin{exercise} |
| 323 |
% Calculate $y = 7 - 12$ |
| 324 |
% \end{exercise} |
| 325 |
% \begin{solution} |
| 326 |
% $y = -5$ |
| 327 |
% \end{solution} |
| 328 |
% |
| 329 |
% \end{exerciseseries} |
| 330 |
% |
| 331 |
% \begin{exerciseseries}{Difficult exercises} |
| 332 |
% |
| 333 |
% \begin{exercise} |
| 334 |
% Calculate $y = 5 \cdot 7$ |
| 335 |
% \end{exercise} |
| 336 |
% \begin{solution} |
| 337 |
% $y = 35$ |
| 338 |
% \end{solution} |
| 339 |
% |
| 340 |
% \begin{exercise} |
| 341 |
% Calculate $y = 8 / 4$ |
| 342 |
% \end{exercise} |
| 343 |
% \begin{solution} |
| 344 |
% $y = 2$ |
| 345 |
% \end{solution} |
| 346 |
% |
| 347 |
% \end{exerciseseries} |
| 348 |
% \end{verbatim} |
| 349 |
% |
| 350 |
% As an alternative, you can specify the 'inine' option to include |
| 351 |
% the solutions on the spot where you specified them. |
| 352 |
% |
| 353 |
% \subsection{Examples} |
| 354 |
% |
| 355 |
% \subsubsection{Global mode} |
| 356 |
% \label{examplesglobal} |
| 357 |
% Below, you can find an example of a file that contains a number of |
| 358 |
% exercises and solutions, with the goal to generate a separate |
| 359 |
% solution book. Note that referencing exercises works just as you |
| 360 |
% would expect it. |
| 361 |
% |
| 362 |
% \begin{Verbatim}[fontsize=\footnotesize] |
| 363 |
%<*example> |
| 364 |
\documentclass[a4paper,10pt]{article} |
| 365 |
|
| 366 |
\usepackage{a4wide} |
| 367 |
\usepackage[english]{babel} |
| 368 |
\usepackage[copyexercisesinsolutions]{exsol} |
| 369 |
|
| 370 |
\title{Gobal example, from the \textsf{ExSol} package} |
| 371 |
\author{Walter Daems} |
| 372 |
\setlength{\parindent}{0em} |
| 373 |
\begin{document} |
| 374 |
\maketitle |
| 375 |
|
| 376 |
\section{Introduction} |
| 377 |
|
| 378 |
In this text we explain how to solve second-order polynomial |
| 379 |
equations. |
| 380 |
|
| 381 |
\section{Solving second-order polynomial equations} |
| 382 |
|
| 383 |
\begin{informulacollectiononly} |
| 384 |
\section*{Solving second-order polynomial equations} |
| 385 |
\end{informulacollectiononly} |
| 386 |
\begin{informulacollection} |
| 387 |
The roots of the following equation |
| 388 |
\begin{equation} |
| 389 |
a x^2 + bx + c = 0 |
| 390 |
\end{equation} |
| 391 |
can be determined as: |
| 392 |
\begin{equation} |
| 393 |
x_{1,2} = \frac{-b \pm \sqrt{b^2 - 4 a c}}{2 a} |
| 394 |
\end{equation} |
| 395 |
\end{informulacollection} |
| 396 |
|
| 397 |
To make sure you master calculating the roots of second-order |
| 398 |
equation, please solve exercise \ref{ex:1}. |
| 399 |
|
| 400 |
|
| 401 |
\begin{exercises}[columns = 2] |
| 402 |
|
| 403 |
\begin{exercise} |
| 404 |
\label{ex:1} |
| 405 |
Solve the following equation for $x \in C$, with $C$ the set of |
| 406 |
complex numbers: |
| 407 |
\begin{equation} |
| 408 |
5 x^2 -3 x = 5 |
| 409 |
\end{equation} |
| 410 |
\end{exercise} |
| 411 |
\begin{solution} |
| 412 |
Let's start by rearranging the equation, a bit: |
| 413 |
\begin{eqnarray} |
| 414 |
5.7 x^2 - 3.1 x &=& 5.3\\ |
| 415 |
5.7 x^2 - 3.1 x -5.3 &=& 0 |
| 416 |
\end{eqnarray} |
| 417 |
The equation is now in the standard form: |
| 418 |
\begin{equation} |
| 419 |
a x^2 + b x + c = 0 |
| 420 |
\end{equation} |
| 421 |
For quadratic equations in the standard form, we know that two |
| 422 |
solutions exist: |
| 423 |
\begin{equation} |
| 424 |
x_{1,2} = \frac{ -b \pm \sqrt{d}}{2a} |
| 425 |
\end{equation} |
| 426 |
with |
| 427 |
\begin{equation} |
| 428 |
d = b^2 - 4 a c |
| 429 |
\end{equation} |
| 430 |
If we apply this to our case, we obtain: |
| 431 |
\begin{equation} |
| 432 |
d = (-3.1)^2 - 4 \cdot 5.7 \cdot (-5.3) = 130.45 |
| 433 |
\end{equation} |
| 434 |
and |
| 435 |
\begin{eqnarray} |
| 436 |
x_1 &=& \frac{3.1 + \sqrt{130.45}}{11.4} = 1.27\\ |
| 437 |
x_2 &=& \frac{3.1 - \sqrt{130.45}}{11.4} = -0.73 |
| 438 |
\end{eqnarray} |
| 439 |
The proposed values $x = x_1, x_2$ are solutions to the given equation. |
| 440 |
\end{solution} |
| 441 |
\begin{exercise} |
| 442 |
\label{ex:2} |
| 443 |
Consider a 2-dimensional vector space equipped with a Euclidean |
| 444 |
distance function. Given a right-angled triangle, with the sides |
| 445 |
$A$ and $B$ adjacent to the right angle having lengths, $3$ and |
| 446 |
$4$, calculate the length of the hypotenuse, labeled $C$. |
| 447 |
\end{exercise} |
| 448 |
\begin{solution} |
| 449 |
This calls for application of Pythagoras' theorem, which |
| 450 |
tells us: |
| 451 |
\begin{equation} |
| 452 |
\left\|A\right\|^2 + \left\|B\right\|^2 = \left\|C\right\|^2 |
| 453 |
\end{equation} |
| 454 |
and therefore: |
| 455 |
\begin{eqnarray} |
| 456 |
\left\|C\right\| |
| 457 |
&=& \sqrt{\left\|A\right\|^2 + \left\|B\right\|^2}\\ |
| 458 |
&=& \sqrt{3^2 + 4^2}\\ |
| 459 |
&=& \sqrt{25} = 5 |
| 460 |
\end{eqnarray} |
| 461 |
Therefore, the length of the hypotenuse equals $5$. |
| 462 |
\end{solution} |
| 463 |
\end{exercises} |
| 464 |
|
| 465 |
And now, we can come to the conclusion. |
| 466 |
\section{Conclusion} |
| 467 |
Solving second-order polynomial equations is very easy. |
| 468 |
\end{document} |
| 469 |
%</example> |
| 470 |
%\end{Verbatim} |
| 471 |
% |
| 472 |
% The result in the original document, can be seen in the file |
| 473 |
% |example.pdf|. As you can see, the formulacollection entry and the |
| 474 |
% exercise appear. There's no trace of the solution. |
| 475 |
% |
| 476 |
% The solution can be recovered by including the |example.sol.tex| |
| 477 |
% file in an appropriate harness. This is explained in |
| 478 |
% section~\ref{harnesses}. |
| 479 |
% |
| 480 |
% \subsubsection{external mode} |
| 481 |
% \label{examplesexternal} |
| 482 |
% Below, you can find an example of a file that contains a number of |
| 483 |
% exercises and solutions, with the goal to generate a separate |
| 484 |
% exercise and solution book. |
| 485 |
% |
| 486 |
% \begin{Verbatim}[fontsize=\footnotesize] |
| 487 |
%<*example-external> |
| 488 |
\documentclass[a4paper,10pt]{article} |
| 489 |
|
| 490 |
\usepackage{a4wide} |
| 491 |
\usepackage[english]{babel} |
| 492 |
\usepackage[external]{exsol} |
| 493 |
|
| 494 |
\title{External example, from the \textsf{ExSol} package} |
| 495 |
\author{Walter Daems} |
| 496 |
\setlength{\parindent}{0em} |
| 497 |
\begin{document} |
| 498 |
\maketitle |
| 499 |
|
| 500 |
\section{Introduction} |
| 501 |
|
| 502 |
In this text we explain how to solve second-order polynomial |
| 503 |
equations. |
| 504 |
|
| 505 |
\section{Solving second-order polynomial equations} |
| 506 |
|
| 507 |
\begin{informulacollectiononly} |
| 508 |
\section*{Solving second-order polynomial equations} |
| 509 |
\end{informulacollectiononly} |
| 510 |
\begin{informulacollection} |
| 511 |
The roots of the following equation |
| 512 |
\begin{equation} |
| 513 |
a x^2 + bx + c = 0 |
| 514 |
\end{equation} |
| 515 |
can be determined as: |
| 516 |
\begin{equation} |
| 517 |
x_{1,2} = \frac{-b \pm \sqrt{b^2 - 4 a c}}{2 a} |
| 518 |
\end{equation} |
| 519 |
\end{informulacollection} |
| 520 |
|
| 521 |
\begin{exercises}[columns = 2] |
| 522 |
|
| 523 |
\begin{exercise} |
| 524 |
Solve the following equation for $x \in C$, with $C$ the set of |
| 525 |
complex numbers: |
| 526 |
\begin{equation} |
| 527 |
5 x^2 -3 x = 5 |
| 528 |
\end{equation} |
| 529 |
\end{exercise} |
| 530 |
\begin{solution} |
| 531 |
Let's start by rearranging the equation, a bit: |
| 532 |
\begin{eqnarray} |
| 533 |
5.7 x^2 - 3.1 x &=& 5.3\\ |
| 534 |
5.7 x^2 - 3.1 x -5.3 &=& 0 |
| 535 |
\end{eqnarray} |
| 536 |
The equation is now in the standard form: |
| 537 |
\begin{equation} |
| 538 |
a x^2 + b x + c = 0 |
| 539 |
\end{equation} |
| 540 |
For quadratic equations in the standard form, we know that two |
| 541 |
solutions exist: |
| 542 |
\begin{equation} |
| 543 |
x_{1,2} = \frac{ -b \pm \sqrt{d}}{2a} |
| 544 |
\end{equation} |
| 545 |
with |
| 546 |
\begin{equation} |
| 547 |
d = b^2 - 4 a c |
| 548 |
\end{equation} |
| 549 |
If we apply this to our case, we obtain: |
| 550 |
\begin{equation} |
| 551 |
d = (-3.1)^2 - 4 \cdot 5.7 \cdot (-5.3) = 130.45 |
| 552 |
\end{equation} |
| 553 |
and |
| 554 |
\begin{eqnarray} |
| 555 |
x_1 &=& \frac{3.1 + \sqrt{130.45}}{11.4} = 1.27\\ |
| 556 |
x_2 &=& \frac{3.1 - \sqrt{130.45}}{11.4} = -0.73 |
| 557 |
\end{eqnarray} |
| 558 |
The proposed values $x = x_1, x_2$ are solutions to the given equation. |
| 559 |
\end{solution} |
| 560 |
\begin{exercise} |
| 561 |
Consider a 2-dimensional vector space equipped with a Euclidean |
| 562 |
distance function. Given a right-angled triangle, with the sides |
| 563 |
$A$ and $B$ adjacent to the right angle having lengths, $3$ and |
| 564 |
$4$, calculate the length of the hypotenuse, labeled $C$. |
| 565 |
\end{exercise} |
| 566 |
\begin{solution} |
| 567 |
This calls for application of Pythagoras' theorem, which |
| 568 |
tells us: |
| 569 |
\begin{equation} |
| 570 |
\left\|A\right\|^2 + \left\|B\right\|^2 = \left\|C\right\|^2 |
| 571 |
\end{equation} |
| 572 |
and therefore: |
| 573 |
\begin{eqnarray} |
| 574 |
\left\|C\right\| |
| 575 |
&=& \sqrt{\left\|A\right\|^2 + \left\|B\right\|^2}\\ |
| 576 |
&=& \sqrt{3^2 + 4^2}\\ |
| 577 |
&=& \sqrt{25} = 5 |
| 578 |
\end{eqnarray} |
| 579 |
Therefore, the length of the hypotenuse equals $5$. |
| 580 |
\end{solution} |
| 581 |
\end{exercises} |
| 582 |
And now, we can come to conclusion. |
| 583 |
|
| 584 |
\section{Conclusion} |
| 585 |
Solving second-order polynomial equations is very easy. |
| 586 |
\end{document} |
| 587 |
%</example-external> |
| 588 |
%\end{Verbatim} |
| 589 |
% |
| 590 |
% The result in the original document, can be seen in the file |
| 591 |
% |example-external.pdf|. As you can see, only the formulacollection |
| 592 |
% entry appears. There's no trace of the exercises or the solutions. |
| 593 |
% |
| 594 |
% \subsubsection{Harnesses} |
| 595 |
% \label{harnesses} |
| 596 |
% |
| 597 |
% When running \LaTeX{} on your document in global or external mode |
| 598 |
% (e.g., the file example-external.tex as part of the exsol package, |
| 599 |
% as a side effect files with the |
| 600 |
% extension |.sol.tex|, |.exc.tex| and/or |.fc.tex| have been written |
| 601 |
% to disk (in our case, the files |example-external.sol.tex|, |
| 602 |
% |example-external.exc.tex| and |example-external.fc.tex|), |
| 603 |
% containing all exercises, solutions and entries for the formula |
| 604 |
% collection in sequence. |
| 605 |
% |
| 606 |
% Generating an exercises/solution book is as simple as including the |
| 607 |
% exercise/solution file into a simple \LaTeX{} harness, that allows |
| 608 |
% you giving it a proper title page and to add other bells and whistles. |
| 609 |
% As an example, you can find a harness for a solution book below. |
| 610 |
% |
| 611 |
% \begin{Verbatim}[fontsize=\footnotesize] |
| 612 |
%<*examplesol> |
| 613 |
\documentclass[a4paper,10pt]{article} |
| 614 |
|
| 615 |
\usepackage{a4wide} |
| 616 |
\usepackage[english]{babel} |
| 617 |
\usepackage{exsol} |
| 618 |
|
| 619 |
\setlength{\parindent}{0em} |
| 620 |
|
| 621 |
\title{Solutions to the exercises, specified in the example of the |
| 622 |
\textsf{ExSol} package} |
| 623 |
\author{Walter Daems} |
| 624 |
|
| 625 |
\begin{document} |
| 626 |
|
| 627 |
\maketitle |
| 628 |
|
| 629 |
\input{example.sol.tex} |
| 630 |
|
| 631 |
\end{document} |
| 632 |
%</examplesol> |
| 633 |
% \end{Verbatim} |
| 634 |
% |
| 635 |
% Similar harnesses can be used for the exercise book and the formula |
| 636 |
% collection. |
| 637 |
% |
| 638 |
% \begin{Verbatim}[fontsize=\footnotesize] |
| 639 |
%<*examplefor> |
| 640 |
\documentclass[a4paper,10pt]{article} |
| 641 |
|
| 642 |
\usepackage{a4wide} |
| 643 |
\usepackage[english]{babel} |
| 644 |
\usepackage{exsol} |
| 645 |
|
| 646 |
\setlength{\parindent}{0em} |
| 647 |
|
| 648 |
\title{Formula collection, specified in the example of the |
| 649 |
\textsf{ExSol} package} |
| 650 |
\author{Walter Daems} |
| 651 |
|
| 652 |
\begin{document} |
| 653 |
|
| 654 |
\maketitle |
| 655 |
|
| 656 |
\input{example.fc.tex} |
| 657 |
|
| 658 |
\end{document} |
| 659 |
%</examplefor> |
| 660 |
% \end{Verbatim} |
| 661 |
% |
| 662 |
% \begin{Verbatim}[fontsize=\footnotesize] |
| 663 |
%<*exampleexc> |
| 664 |
\documentclass[a4paper,10pt]{article} |
| 665 |
|
| 666 |
\usepackage{a4wide} |
| 667 |
\usepackage[english]{babel} |
| 668 |
\usepackage{exsol} |
| 669 |
|
| 670 |
\setlength{\parindent}{0em} |
| 671 |
|
| 672 |
\title{Exercise book, specified in the example-external of the |
| 673 |
\textsf{ExSol} package} |
| 674 |
\author{Walter Daems} |
| 675 |
|
| 676 |
\begin{document} |
| 677 |
|
| 678 |
\maketitle |
| 679 |
|
| 680 |
\input{example-external.exc.tex} |
| 681 |
|
| 682 |
\end{document} |
| 683 |
%</exampleexc> |
| 684 |
% \end{Verbatim} |
| 685 |
% |
| 686 |
% |
| 687 |
% \subsubsection{Local mode} |
| 688 |
% |
| 689 |
% Below, you can find an example of a file that contains a number of |
| 690 |
% exercises and solutions, with the goal to include them later in the |
| 691 |
% same document. |
| 692 |
% This is done by issuing the |loadSolutions| macro at the very end of |
| 693 |
% the file. This macro can be called multiple times and will gobble up |
| 694 |
% and include all solutions so far. As a consequence the solutions |
| 695 |
% file is emptied and can be filled again by specifying new |
| 696 |
% exercise/solution pairs. |
| 697 |
% |
| 698 |
% |
| 699 |
% \begin{Verbatim}[fontsize=\footnotesize] |
| 700 |
%<*example-local> |
| 701 |
\documentclass[a4paper,10pt]{article} |
| 702 |
|
| 703 |
\usepackage{a4wide} |
| 704 |
\usepackage[german]{babel} |
| 705 |
\usepackage[local,nolabels,exerciseaslist,usesolutionserieslabels]{exsol} |
| 706 |
\usepackage{enumitem} |
| 707 |
|
| 708 |
\setlength{\exsolexercisetopbottomsep}{0pt plus 0pt minus 1pt} |
| 709 |
\setlength{\exsolexerciseleftmargin}{2em} |
| 710 |
\setlength{\exsolexerciserightmargin}{1em} |
| 711 |
\setlength{\exsolexerciseparindent}{0em} |
| 712 |
\setlength{\exsolexerciselabelsep}{1ex} |
| 713 |
\setlength{\exsolexerciselabelwidth}{30pt} |
| 714 |
\setlength{\exsolexerciseitemindent}{0pt} |
| 715 |
\setlength{\exsolexerciseparsep}{\parskip} |
| 716 |
|
| 717 |
\title{Local example, from the \textsf{ExSol} package} |
| 718 |
\author{Philippe Marti} |
| 719 |
\setlength{\parindent}{0em} |
| 720 |
\begin{document} |
| 721 |
\maketitle |
| 722 |
|
| 723 |
\section{\exercisesname} |
| 724 |
|
| 725 |
\begin{exerciseseries}[columns=2,solsubrule=\hrule]{Gleichungen $|$ Gleichungssysteme} |
| 726 |
|
| 727 |
\begin{exercise} |
| 728 |
Die Summe zweier Zahlen ist 17 und ihre Differenz 7. Bestimme die |
| 729 |
beiden Zahlen! |
| 730 |
\end{exercise} |
| 731 |
\begin{solution} |
| 732 |
5 und 12 |
| 733 |
\end{solution} |
| 734 |
|
| 735 |
\begin{exercise} |
| 736 |
Die Differenz einer Zahl und dem Dreifachen einer zweiten Zahl ist |
| 737 |
14. Bestimme die beiden Zahlen, falls die zweite Zahl ein Zehntel |
| 738 |
der ersten ist. |
| 739 |
\end{exercise} |
| 740 |
\begin{solution} |
| 741 |
20 und 2 |
| 742 |
\end{solution} |
| 743 |
|
| 744 |
\end{exerciseseries} |
| 745 |
|
| 746 |
\begin{exerciseseries}[columns=2]{Geraden} |
| 747 |
\begin{exercise} |
| 748 |
Berechne den Schnittpunkt von \mbox{$y=3x+1$} und \mbox{$y=3x-7$}. |
| 749 |
\end{exercise} |
| 750 |
\begin{solution} |
| 751 |
Es gibt keinen Schnittpunkt |
| 752 |
\end{solution} |
| 753 |
|
| 754 |
\begin{exercise} |
| 755 |
Die Familie Meier fordert Offerten f\"ur eine Heizungsreparatur |
| 756 |
ein. Firma A berechnet f\"ur die Fahrtkosten Fr. 42.- und f\"ur |
| 757 |
jede Arbeitsstunde 76.-. Bei der Firma B sind die Fahrtkosten |
| 758 |
Fr. 35.- und jede Arbeitsstunde wird mit Fr. 80.- berechnet. |
| 759 |
\begin{enumerate}[label=\alph*)] |
| 760 |
\item Welche Kosten entstehen f\"ur beide Firmen, wenn ein Monteur |
| 761 |
3.5 Stunden |
| 762 |
f\"ur die Arbeit benötigt? Welche Firma ist in diesem Fall |
| 763 |
kostengünstiger? |
| 764 |
|
| 765 |
\item Wie lauten die Gleichungen derjenigen zwei linearen |
| 766 |
Funktionen, die jeder Arbeitszeit $x$ (in Stunden) die |
| 767 |
entstehenden Kosten $y$ (in Franken) zuordnet? |
| 768 |
|
| 769 |
\item Berechne, bei welcher Arbeitszeit die Kosten bei beiden |
| 770 |
Firmen gleich sind. |
| 771 |
\end{enumerate} |
| 772 |
\end{exercise} |
| 773 |
\begin{solution} |
| 774 |
\begin{enumerate}[label=\alph*)] |
| 775 |
\item Firma A: 308.- $|$ Firma B: 315.- |
| 776 |
\item A: $y=76x+42$ $|$ B: $y=80x+35$ |
| 777 |
\item Bei $1\frac{3}{4}$ Stunden |
| 778 |
\end{enumerate} |
| 779 |
\end{solution} |
| 780 |
\end{exerciseseries} |
| 781 |
|
| 782 |
\section{\solutionsname} |
| 783 |
\loadSolutions |
| 784 |
|
| 785 |
\end{document} |
| 786 |
%</example-local> |
| 787 |
% \end{Verbatim} |
| 788 |
% |
| 789 |
% |
| 790 |
% \subsubsection{Inline mode} |
| 791 |
% |
| 792 |
% Below, you can find an example of a file that contains a number of |
| 793 |
% exercises and solutions, with the goal to include the solutions on |
| 794 |
% the spot. |
| 795 |
% |
| 796 |
% |
| 797 |
% \begin{Verbatim}[fontsize=\footnotesize] |
| 798 |
%<*example-inline> |
| 799 |
\documentclass[11pt,a4paper]{article} |
| 800 |
|
| 801 |
\usepackage[german]{babel} |
| 802 |
\usepackage[inline,usesolutionserieslabels]{exsol} |
| 803 |
\usepackage{enumitem} |
| 804 |
|
| 805 |
\setlength{\exsolexercisetopbottomsep}{0pt plus 0pt minus 1pt} |
| 806 |
\setlength{\exsolexerciseleftmargin}{2em} |
| 807 |
\setlength{\exsolexerciserightmargin}{1em} |
| 808 |
\setlength{\exsolexerciseparindent}{0em} |
| 809 |
\setlength{\exsolexerciselabelsep}{1ex} |
| 810 |
\setlength{\exsolexerciselabelwidth}{30pt} |
| 811 |
\setlength{\exsolexerciseitemindent}{0pt} |
| 812 |
\setlength{\exsolexerciseparsep}{\parskip} |
| 813 |
|
| 814 |
\title{Local inline example, from the \textsf{ExSol} package} |
| 815 |
\author{Philippe Marti} |
| 816 |
\setlength{\parindent}{0em} |
| 817 |
\begin{document} |
| 818 |
\maketitle |
| 819 |
|
| 820 |
\section{Gleichungssysteme und Geraden} |
| 821 |
|
| 822 |
Ein bisschen Theorie\ldots |
| 823 |
|
| 824 |
\begin{exerciseseries}[solsubrule=\hrule]{Gleichungssysteme} |
| 825 |
\begin{exercise} |
| 826 |
Die Summe zweier Zahlen ist 17 und ihre Differenz 7. Bestimme die |
| 827 |
beiden Zahlen! |
| 828 |
\end{exercise} |
| 829 |
\begin{solution} |
| 830 |
5 und 12 |
| 831 |
\end{solution} |
| 832 |
|
| 833 |
\begin{exercise} |
| 834 |
Die Differenz einer Zahl und dem Dreifachen einer zweiten Zahl ist |
| 835 |
14. Bestimme die beiden Zahlen, falls die zweite Zahl ein Zehntel |
| 836 |
der ersten ist. |
| 837 |
\end{exercise} |
| 838 |
\begin{solution} |
| 839 |
20 und 2 |
| 840 |
\end{solution} |
| 841 |
\end{exerciseseries} |
| 842 |
~\\ |
| 843 |
Etwas mehr Theorie\ldots |
| 844 |
|
| 845 |
\begin{exerciseseries}{Geraden} |
| 846 |
\begin{exercise} |
| 847 |
Berechne den Schnittpunkt von \mbox{$y=3x+1$} und \mbox{$y=3x-7$}. |
| 848 |
\end{exercise} |
| 849 |
\begin{solution} |
| 850 |
Es gibt keinen Schnittpunkt |
| 851 |
\end{solution} |
| 852 |
|
| 853 |
\begin{exercise} |
| 854 |
Die Familie Meier fordert Offerten f\"ur eine Heizungsreparatur |
| 855 |
ein. Firma A berechnet f\"ur die Fahrtkosten Fr. 42.- und f\"ur |
| 856 |
jede Arbeitsstunde 76.-. Bei der Firma B sind die Fahrtkosten |
| 857 |
Fr. 35.- und jede Arbeitsstunde wird mit Fr. 80.- berechnet. |
| 858 |
\begin{enumerate}[label=\alph*)] |
| 859 |
\item Welche Kosten entstehen f\"ur beide Firmen, wenn ein Monteur |
| 860 |
3.5 Stunden |
| 861 |
f\"ur die Arbeit benötigt? Welche Firma ist in diesem Fall |
| 862 |
kostengünstiger? |
| 863 |
|
| 864 |
\item Wie lauten die Gleichungen derjenigen zwei linearen |
| 865 |
Funktionen, die jeder Arbeitszeit $x$ (in Stunden) die |
| 866 |
entstehenden Kosten $y$ (in Franken) zuordnet? |
| 867 |
|
| 868 |
\item Berechne, bei welcher Arbeitszeit die Kosten bei beiden |
| 869 |
Firmen gleich sind. |
| 870 |
\end{enumerate} |
| 871 |
\end{exercise} |
| 872 |
\begin{solution} |
| 873 |
\begin{enumerate}[label=\alph*)] |
| 874 |
\item Firma A: 308.- $|$ Firma B: 315.- |
| 875 |
\item A: $y=76x+42$ $|$ B: $y=80x+35$ |
| 876 |
\item Bei $1\frac{3}{4}$ Stunden |
| 877 |
\end{enumerate} |
| 878 |
\end{solution} |
| 879 |
\end{exerciseseries} |
| 880 |
|
| 881 |
\end{document} |
| 882 |
%</example-inline> |
| 883 |
% \end{Verbatim} |
| 884 |
% |
| 885 |
% |
| 886 |
% \subsection{Fiddling with the spacing} |
| 887 |
% |
| 888 |
% The default spacing provided by the \textsf{ExSol} package should be |
| 889 |
% fine for most users. However, if you like to tweak, below you can |
| 890 |
% find the controls. |
| 891 |
% |
| 892 |
% As the formula collection generation is intended to interfere as |
| 893 |
% little as possible with the flow of the main document, you will |
| 894 |
% notice that it is impossible to control the extra spacing, as no |
| 895 |
% extra spacing should originate from using the |
| 896 |
% |informulacollection| environment. |
| 897 |
% |
| 898 |
% \subsubsection{Spacing before and after the \texttt{exercises} environment} |
| 899 |
% |
| 900 |
% The lengths below control the spacing of the |exercises| environment: |
| 901 |
% \begin{itemize} |
| 902 |
% \item |exsolexerciseaboveskip|: rubber length controlling the |
| 903 |
% vertical space after the top marker line of the environment |
| 904 |
% \item |exsolexercisebelowskip|: rubber length controlling the |
| 905 |
% vertical space before the bottom marker line of the environment |
| 906 |
% \end{itemize} |
| 907 |
% |
| 908 |
% You can simply specify them like: |
| 909 |
% \begin{verbatim} |
| 910 |
% \setlength{\exsolexercisesaboveskip}{1ex plus 1pt minus 1pt} |
| 911 |
% \setlength{\exsolexercisesbelowskip}{1ex plus 1pt minus 1pt} |
| 912 |
% \end{verbatim} |
| 913 |
% The spacings specified here are the package defaults. |
| 914 |
% |
| 915 |
% \subsubsection{Spacing of the individual exercises} |
| 916 |
% Caution: the spacing can only be tuned, when one invokes the |
| 917 |
% |exerciseaslist| package option! |
| 918 |
% |
| 919 |
% Then lengths below control the spacing of the |exercise| environment: |
| 920 |
% \begin{itemize} |
| 921 |
% \item |exercisetopbottomsep|: rubber length controlling the vertical |
| 922 |
% space before and after individual exercises |
| 923 |
% \item |exerciseleftmargin|: length controlling the horizontal |
| 924 |
% space between the surrounding environment's left margin (most |
| 925 |
% often the page margin) and the left edge of the exercise |
| 926 |
% environment |
| 927 |
% \item |exerciseleftmargin|: length controlling the horizontal |
| 928 |
% space between the surrounding environment's right margin (most |
| 929 |
% often the page margin) and the right edge of the exercise |
| 930 |
% environment |
| 931 |
% \item |exerciseitemindent|: length controlling the first-line |
| 932 |
% indentation of the first paragraph in the exercise environment |
| 933 |
% (actually, the label is set w.r.t. this position, that we will |
| 934 |
% conveniently call position 'x') |
| 935 |
% \item |exerciseparindent|: length controlling the first-line |
| 936 |
% indentation of the other paragraphs in the exercise environment. |
| 937 |
% \item |exerciselabelsep|: length controlling the distance between |
| 938 |
% the label and position 'x' |
| 939 |
% \item |exerciselabelwidth|: minimal width of the (internally |
| 940 |
% right-alligned) box to use for the exercises label; if the box is |
| 941 |
% not sufficiently big, position 'x' is shifted to the right |
| 942 |
% \item |exerciseparsep|: internal paragraph separation (vertically) |
| 943 |
% \end{itemize} |
| 944 |
% |
| 945 |
% You can simply specify them like: |
| 946 |
% \begin{verbatim} |
| 947 |
% \setlength{\exsolexercisetopbottomsep}{0pt plus 0pt minus 1pt} |
| 948 |
% \setlength{\exsolexerciseleftmargin}{1em} |
| 949 |
% \setlength{\exsolexerciserightmargin}{1em} |
| 950 |
% \setlength{\exsolexerciseparindent}{0em} |
| 951 |
% \setlength{\exsolexerciselabelsep}{0.5em} |
| 952 |
% \setlength{\exsolexerciselabelwidth}{0pt} |
| 953 |
% \setlength{\exsolexerciseitemindent}{0pt} |
| 954 |
% \setlength{\exsolexerciseparsep}{\parskip} |
| 955 |
% \end{verbatim} |
| 956 |
% The spacings specified here are the package defaults. |
| 957 |
% |
| 958 |
% \subsection{Tips and tricks} |
| 959 |
% |
| 960 |
% If you want to include the solutions all at the |
| 961 |
% end of the current document in global mode, you need to explicitly |
| 962 |
% close the solution stream before including it: |
| 963 |
% \begin{verbatim} |
| 964 |
% \closeout\solutionstream\input{\jobname.sol.tex} |
| 965 |
% \end{verbatim} |
| 966 |
% |
| 967 |
% If you want to avoid exercises being split by a page boundary, then |
| 968 |
% provide the package option 'minipage'. This causes the exercises to |
| 969 |
% be wrapped in a minipage environment. |
| 970 |
% |
| 971 |
% \clearpage |
| 972 |
% |
| 973 |
% \section{Implementation} |
| 974 |
% %%%%%%%%%%%%%%%%%%%%%%% |
| 975 |
% \begin{macrocode} |
| 976 |
%<*package> |
| 977 |
% \end{macrocode} |
| 978 |
% |
| 979 |
% \subsection{Auxiliary packages} |
| 980 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 981 |
% The package uses some auxiliary packages: |
| 982 |
% \begin{macrocode} |
| 983 |
\RequirePackage{ifmtarg} |
| 984 |
\RequirePackage{fancyvrb} |
| 985 |
\RequirePackage{ifthen} |
| 986 |
\RequirePackage{kvoptions} |
| 987 |
\RequirePackage{multicol} |
| 988 |
\RequirePackage{varwidth} |
| 989 |
\@ifpackageloaded{babel}{\typeout{Good: you loaded babel first!}}{\PackageError{exsol}{You forgot to load the |
| 990 |
babel package before exsol}{}} |
| 991 |
% \end{macrocode} |
| 992 |
% |
| 993 |
% \subsection{Package options} |
| 994 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 995 |
% The package offers some options: |
| 996 |
% |
| 997 |
% \changes{v1.2}{2016/05/05}{Added option local} |
| 998 |
% \begin{macro}{local} |
| 999 |
% This boolean option (true, false) allows setting the mode of the |
| 1000 |
% package into local, i.e. that the numbering of the exercises is not |
| 1001 |
% related to the position in the document, but uses it's own local |
| 1002 |
% counter in combination with a exerciseseries counter. |
| 1003 |
% \begin{macrocode} |
| 1004 |
\DeclareBoolOption[false]{local} |
| 1005 |
% \end{macrocode} |
| 1006 |
% \end{macro} |
| 1007 |
% |
| 1008 |
% \changes{v1.5}{2019/01/02}{Added option external} |
| 1009 |
% \begin{macro}{external} |
| 1010 |
% This boolean option (true, false) allows setting the mode of the |
| 1011 |
% package into external, i.e. that the both exercises and solutions |
| 1012 |
% will be written to separate files. |
| 1013 |
% \begin{macrocode} |
| 1014 |
\DeclareBoolOption[false]{external} |
| 1015 |
% \end{macrocode} |
| 1016 |
% \end{macro} |
| 1017 |
% |
| 1018 |
% \changes{v1.5}{2019/01/02}{Added option inline} |
| 1019 |
% \begin{macro}{inline} |
| 1020 |
% This boolean option (true, false) allows setting the mode of the |
| 1021 |
% package into inline, i.e. that the solutions will be included 'on |
| 1022 |
% the spot'. |
| 1023 |
% \begin{macrocode} |
| 1024 |
\DeclareBoolOption[false]{inline} |
| 1025 |
% \end{macrocode} |
| 1026 |
% \end{macro} |
| 1027 |
% |
| 1028 |
% \changes{v1.2}{2016/05/05}{Added option nolabels} |
| 1029 |
% \begin{macro}{nolabels} |
| 1030 |
% This boolean option (true, false) allows suppressing the 'Exercise' |
| 1031 |
% and 'Solution' label that normally appear before the exercise and |
| 1032 |
% solution number. |
| 1033 |
% \begin{macrocode} |
| 1034 |
\DeclareBoolOption[false]{nolabels} |
| 1035 |
% \end{macrocode} |
| 1036 |
% \end{macro} |
| 1037 |
% |
| 1038 |
% \changes{v0.2}{2012/01/06}{Added option exercisesfont} |
| 1039 |
% \changes{v0.4}{2012/01/09}{Changed name of option to |
| 1040 |
% exercisesfontsize} |
| 1041 |
% |
| 1042 |
% \begin{macro}{exercisesfontsize} |
| 1043 |
% This option allows setting the font of the |exercises| |
| 1044 |
% environment. You may chopse one of tiny, scriptsize, footnotesize, |
| 1045 |
% small, normalsize, large, etc.\\ |
| 1046 |
% E.g., |[exercisesfontsize=small]|. |
| 1047 |
% \begin{macrocode} |
| 1048 |
\DeclareStringOption[normalsize]{exercisesfontsize} |
| 1049 |
% \end{macrocode} |
| 1050 |
% \end{macro} |
| 1051 |
% |
| 1052 |
% \changes{v0.4}{2012/01/06}{Added option exercisesinlist} |
| 1053 |
% \changes{v0.5}{2012/01/09}{Changed option exercisesinlist to exerciseaslist} |
| 1054 |
% |
| 1055 |
% \begin{macro}{exerciseaslist} |
| 1056 |
% This boolean option (true, false) allows setting the typesetting of |
| 1057 |
% the |exercises| in a list environment. This causes the |
| 1058 |
% exercises to be typeset in a more compact fashion, with indented |
| 1059 |
% left and right margin. |
| 1060 |
% \begin{macrocode} |
| 1061 |
\DeclareBoolOption[false]{exerciseaslist} |
| 1062 |
% \end{macrocode} |
| 1063 |
% \end{macro} |
| 1064 |
% |
| 1065 |
% \changes{v0.5}{2012/01/09}{Added option copyexercisesinsolutions} |
| 1066 |
% \begin{macro}{copyexercisesinsolutions} |
| 1067 |
% This boolean option (true, false) allows copying the exercises in |
| 1068 |
% the solutions file, to allow for making a complete stand-alone |
| 1069 |
% exercises bundle. |
| 1070 |
% \begin{macrocode} |
| 1071 |
\DeclareBoolOption[false]{copyexercisesinsolutions} |
| 1072 |
% \end{macrocode} |
| 1073 |
% \end{macro} |
| 1074 |
% |
| 1075 |
% \changes{v0.9}{2014/07/28}{. Changed default behavior |
| 1076 |
% w.r.t. minipage-wraping of exercises} |
| 1077 |
% \begin{macro}{minipage} |
| 1078 |
% This boolean option (true, false) causes the exercises to be |
| 1079 |
% wrapped in minipages. This avoids them getting split by a page |
| 1080 |
% boundary. |
| 1081 |
% \begin{macrocode} |
| 1082 |
\DeclareBoolOption[false]{minipage} |
| 1083 |
% \end{macrocode} |
| 1084 |
% \end{macro} |
| 1085 |
% |
| 1086 |
% \changes{v1.4}{2018/10/23}{. added 'usesolutionserieslabels' option} |
| 1087 |
% \begin{macro}{usesolutionserieslabels} |
| 1088 |
% This boolean options (true,false) causes the exerciseseries label |
| 1089 |
% to be reused when inserting the corresponding solutionseries. |
| 1090 |
% \begin{macrocode} |
| 1091 |
\DeclareBoolOption[false]{usesolutionserieslabels} |
| 1092 |
% \end{macrocode} |
| 1093 |
% \end{macro} |
| 1094 |
% |
| 1095 |
% The options are processed using: |
| 1096 |
% \begin{macrocode} |
| 1097 |
\ProcessKeyvalOptions* |
| 1098 |
% \end{macrocode} |
| 1099 |
% |
| 1100 |
% The options are subsequently handled |
| 1101 |
% \begin{macrocode} |
| 1102 |
\newcommand{\exercisesfontsize}{\csname \exsol@exercisesfontsize\endcsname} |
| 1103 |
% \end{macrocode} |
| 1104 |
% |
| 1105 |
% |
| 1106 |
% \subsection{Customization of lengths} |
| 1107 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1108 |
% The commands below allow customizing many lengths that control the |
| 1109 |
% typesetting of the exercises. |
| 1110 |
% |
| 1111 |
% \changes{v0.91}{2014/08/31}{added user-accessible lengths} |
| 1112 |
% First some lengths to control the spacing before and after |exercises|. |
| 1113 |
% \begin{macrocode} |
| 1114 |
\newlength{\exsolexercisesaboveskip} |
| 1115 |
\setlength{\exsolexercisesaboveskip}{0ex plus 1pt minus 1pt} |
| 1116 |
\addtolength{\exsolexercisesaboveskip}{-2\baselineskip} |
| 1117 |
\newlength{\exsolexercisesbelowskip} |
| 1118 |
\setlength{\exsolexercisesbelowskip}{0ex plus 1pt minus 1pt} |
| 1119 |
\addtolength{\exsolexercisesbelowskip}{\baselineskip} |
| 1120 |
% \end{macrocode} |
| 1121 |
% |
| 1122 |
% Then some lengths to control the spacing for a single |
| 1123 |
% exercise. These lengths only work when the |exerciseaslist| package |
| 1124 |
% option has been specified. Sensible defaults have been set. |
| 1125 |
% \begin{macrocode} |
| 1126 |
\newlength{\exsolexercisetopbottomsep} |
| 1127 |
\setlength{\exsolexercisetopbottomsep}{0pt plus 0pt minus 1pt} |
| 1128 |
\newlength{\exsolexerciseleftmargin} |
| 1129 |
\setlength{\exsolexerciseleftmargin}{1em} |
| 1130 |
\newlength{\exsolexerciserightmargin} |
| 1131 |
\setlength{\exsolexerciserightmargin}{1em} |
| 1132 |
\newlength{\exsolexerciseparindent} |
| 1133 |
\setlength{\exsolexerciseparindent}{0em} |
| 1134 |
\newlength{\exsolexerciselabelsep} |
| 1135 |
\setlength{\exsolexerciselabelsep}{0.5em} |
| 1136 |
\newlength{\exsolexerciselabelwidth} |
| 1137 |
\setlength{\exsolexerciselabelwidth}{0pt} |
| 1138 |
\newlength{\exsolexerciseitemindent} |
| 1139 |
\setlength{\exsolexerciseitemindent}{0pt} |
| 1140 |
\newlength{\exsolexerciseparsep} |
| 1141 |
\setlength{\exsolexerciseparsep}{\parskip} |
| 1142 |
% \end{macrocode} |
| 1143 |
% |
| 1144 |
% |
| 1145 |
% \subsection{Con- and destruction of the auxiliary streams} |
| 1146 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1147 |
% At the beginning of your document, we start by opening a stream to a |
| 1148 |
% file that will be used to write the solutions to. At the end of your |
| 1149 |
% document, the package closes the stream. |
| 1150 |
% \changes{v0.8}{2014/07/15}{moved newwrite of exercise stream to this |
| 1151 |
% spot to avoid consuming all handles} |
| 1152 |
% \begin{macrocode} |
| 1153 |
\AtBeginDocument{ |
| 1154 |
\typeout{Writing solutions to solution file \jobname.sol.tex} |
| 1155 |
\newwrite\solutionstream |
| 1156 |
\immediate\openout\solutionstream=\jobname.sol.tex |
| 1157 |
\ifexsol@external |
| 1158 |
\typeout{Writing exercises to exercise file \jobname.exc.tex} |
| 1159 |
\newwrite\exercisestream |
| 1160 |
\immediate\openout\exercisestream=\jobname.exc.tex |
| 1161 |
\else |
| 1162 |
\typeout{Using intermediate exercise file \jobname.exc.tex} |
| 1163 |
\newwrite\exercisestream |
| 1164 |
\fi |
| 1165 |
\typeout{Writing formulae to formula collection file \jobname.fc.tex} |
| 1166 |
\newwrite\formulacollectionstream |
| 1167 |
\immediate\openout\formulacollectionstream=\jobname.fc.tex |
| 1168 |
\typeout{Using intermediate formula file \jobname.for.tex} |
| 1169 |
\newwrite\formulastream |
| 1170 |
} |
| 1171 |
\AtEndDocument{ |
| 1172 |
\immediate\closeout\formulacollectionstream |
| 1173 |
\immediate\closeout\solutionstream |
| 1174 |
} |
| 1175 |
% \end{macrocode} |
| 1176 |
% |
| 1177 |
% |
| 1178 |
% In local mode we also want to close the solutionstream, read it and |
| 1179 |
% open it again: |
| 1180 |
% \begin{macrocode} |
| 1181 |
\newcommand\loadSolutions{ |
| 1182 |
\immediate\closeout\solutionstream |
| 1183 |
\input{\jobname.sol.tex} |
| 1184 |
% \immediate\openout\solutionstream=\jobname.sol.tex |
| 1185 |
} |
| 1186 |
% \end{macrocode} |
| 1187 |
% |
| 1188 |
% \subsection{Series counter} |
| 1189 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1190 |
% By providing an exerciseseries counter, proper numbering of the |
| 1191 |
% exercise series is provided. Note that separate series, render the |
| 1192 |
% numbering of the exercises from document-global, to series-local, |
| 1193 |
% therefore hindering the concordance of solutions to exercises. |
| 1194 |
% |
| 1195 |
% \changes{v1.2}{2016/05/05}{Added series counter} |
| 1196 |
% \begin{macrocode} |
| 1197 |
\newcounter{exerciseseries}[subsubsection] |
| 1198 |
\setcounter{exerciseseries}{0} |
| 1199 |
\renewcommand{\theexerciseseries}{\arabic{exerciseseries}} |
| 1200 |
% \end{macrocode} |
| 1201 |
% |
| 1202 |
% |
| 1203 |
% \subsection{Exercise counter} |
| 1204 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1205 |
% By providing an exercise counter, proper numbering of the exercises |
| 1206 |
% is provided to allow for good cross referencing of the solutions to |
| 1207 |
% the exercises. |
| 1208 |
% \changes{v0.2}{2012/01/06}{Removed dash in counter when in document |
| 1209 |
% without sectioning commands} |
| 1210 |
% \begin{macrocode} |
| 1211 |
\newcounter{exercise}[exerciseseries] |
| 1212 |
\setcounter{exercise}{0} |
| 1213 |
\renewcommand{\theexercise}{% |
| 1214 |
\ifexsol@local |
| 1215 |
\arabic{exerciseseries}.\arabic{exercise}% |
| 1216 |
\else |
| 1217 |
\@ifundefined{c@chapter}{}{\if0\arabic{chapter}\else\arabic{chapter}.\fi}% |
| 1218 |
\if0\arabic{section}\else\arabic{section}\fi% |
| 1219 |
\if0\arabic{subsection}\else.\arabic{subsection}\fi% |
| 1220 |
\if0\arabic{subsubsection}\else.\arabic{subsubsection}\fi% |
| 1221 |
\if0\arabic{exercise}\else% |
| 1222 |
\@ifundefined{c@chapter}% |
| 1223 |
{\if0\arabic{section}\else-\fi}% |
| 1224 |
{-}% |
| 1225 |
\arabic{exercise}% |
| 1226 |
\fi |
| 1227 |
\fi |
| 1228 |
} |
| 1229 |
% \end{macrocode} |
| 1230 |
% |
| 1231 |
% |
| 1232 |
% \subsection{Detokenization in order to cope with utf8} |
| 1233 |
% |
| 1234 |
% Combining old-school \LaTeX{} (before \XeTeX{} and \LuaTeX{}) and |
| 1235 |
% UTF-8 is a pain. |
| 1236 |
% Detokenization has been suggested by Geoffrey Poore to solve issues |
| 1237 |
% with UTF-8 characters messing up the |fancyvrb| internals. |
| 1238 |
% \changes{v0.7}{2014/07/14}{Added detokenized writing} |
| 1239 |
% \changes{v1.0}{2014/09/13}{Added detokenized writing of formula and |
| 1240 |
% formula collection stream} |
| 1241 |
% \begin{macrocode} |
| 1242 |
\newcommand{\GPES@write@detok}[1]{% |
| 1243 |
\immediate\write\exercisestream{\detokenize{#1}}}% |
| 1244 |
\newcommand{\GPSS@write@detok}[1]{% |
| 1245 |
\immediate\write\solutionstream{\detokenize{#1}}}% |
| 1246 |
\newcommand{\GPESS@write@detok}[1]{% |
| 1247 |
\GPES@write@detok{#1}% |
| 1248 |
\GPSS@write@detok{#1}}% |
| 1249 |
\newcommand{\GPFORCOL@write@detok}[1]{% |
| 1250 |
\immediate\write\formulacollectionstream{\detokenize{#1}}% |
| 1251 |
\immediate\write\formulastream{\detokenize{#1}}}% |
| 1252 |
\newcommand{\GPFORCOLONLY@write@detok}[1]{% |
| 1253 |
\immediate\write\formulacollectionstream{\detokenize{#1}}}% |
| 1254 |
% \end{macrocode} |
| 1255 |
% |
| 1256 |
% |
| 1257 |
% \section{The user environments} |
| 1258 |
% |
| 1259 |
% \begin{macro}{exercise} |
| 1260 |
% The |exercise| environment is used to typeset your |
| 1261 |
% exercises, provide them with a nice label and allow for copying |
| 1262 |
% the exercise to the solutions file (if the package option |
| 1263 |
% |copyexercisesinsolution|) is set. The label can be |
| 1264 |
% set by redefining the \cs{exercisename} macro, or by relying on |
| 1265 |
% the \textsf{Babel} provisions. The code is almost litteraly |
| 1266 |
% taken from the \textsf{fancyvrb} package. |
| 1267 |
% \begin{macrocode} |
| 1268 |
\def\exercise{\FV@Environment{}{exercise}} |
| 1269 |
\def\FVB@exercise{% |
| 1270 |
\refstepcounter{exercise}% |
| 1271 |
\ifexsol@external\else |
| 1272 |
\immediate\openout\exercisestream=\jobname.exc.tex |
| 1273 |
\fi |
| 1274 |
\ifexsol@local |
| 1275 |
% \immediate\write\solutionstream{} |
| 1276 |
\else |
| 1277 |
% \immediate\write\solutionstream{\string\vspace*\string{2ex\string}% |
| 1278 |
% \string\quad\string\newline} |
| 1279 |
\fi |
| 1280 |
\ifexsol@copyexercisesinsolutions |
| 1281 |
\immediate\write\solutionstream{\string\begin{exsol@exercise}{\theexercise}} |
| 1282 |
\fi |
| 1283 |
\immediate\write\exercisestream{\string\begin{exsol@exercise}{\theexercise}} |
| 1284 |
\@bsphack |
| 1285 |
\begingroup |
| 1286 |
\FV@UseKeyValues |
| 1287 |
\FV@DefineWhiteSpace |
| 1288 |
\def\FV@Space{\space}% |
| 1289 |
\FV@DefineTabOut |
| 1290 |
\ifexsol@copyexercisesinsolutions |
| 1291 |
\let\FV@ProcessLine\GPESS@write@detok % |
| 1292 |
\else |
| 1293 |
\let\FV@ProcessLine\GPES@write@detok % |
| 1294 |
\fi |
| 1295 |
\relax |
| 1296 |
\let\FV@FontScanPrep\relax |
| 1297 |
\let\@noligs\relax |
| 1298 |
\FV@Scan |
| 1299 |
} |
| 1300 |
\def\FVE@exercise{ |
| 1301 |
\endgroup\@esphack |
| 1302 |
\immediate\write\exercisestream{\string\end{exsol@exercise}} |
| 1303 |
\ifexsol@copyexercisesinsolutions |
| 1304 |
\immediate\write\solutionstream{\string\end{exsol@exercise}} |
| 1305 |
\fi |
| 1306 |
\ifexsol@external\else |
| 1307 |
\immediate\closeout\exercisestream |
| 1308 |
\input{\jobname.exc.tex} |
| 1309 |
\fi |
| 1310 |
} |
| 1311 |
\DefineVerbatimEnvironment{exercise}{exercise}{} |
| 1312 |
% \end{macrocode} |
| 1313 |
% \end{macro} |
| 1314 |
% |
| 1315 |
% \begin{macro}{exsol@exercise} |
| 1316 |
% The |exsol@exercise| environment is an internal macro used |
| 1317 |
% to typeset your exercises and provide them with a nice label and |
| 1318 |
% number. Do not use it directly. Use the proper environment |
| 1319 |
% |exercise| instead. |
| 1320 |
% \changes{v0.2}{2012/01/06}{Attempted to fix MiKTeX formatting problems} |
| 1321 |
% \changes{v0.3}{2012/01/08}{Fixed labelsep to avoid cluttered |
| 1322 |
% itemize environments} |
| 1323 |
% \changes{v0.4}{2012/01/06}{Added option exercisesinlist such that |
| 1324 |
% default results in non list formatting of exercise} |
| 1325 |
% \changes{v0.5}{2012/01/09}{Changed implementation to allow for |
| 1326 |
% copying the exercises to the solutions file.} |
| 1327 |
% \changes{v1.3}{2017/01/08}{Corrected formatting error in case of |
| 1328 |
% options exerciseaslist} |
| 1329 |
% \begin{macrocode} |
| 1330 |
\newenvironment{exsol@exercise}[1] |
| 1331 |
{% |
| 1332 |
\ifthenelse{\boolean{exsol@minipage}}{\begin{minipage}[t]{\textwidth}}{}% |
| 1333 |
\ifthenelse{\boolean{exsol@exerciseaslist}} |
| 1334 |
{ |
| 1335 |
\begin{list}% |
| 1336 |
{} |
| 1337 |
{% |
| 1338 |
\setlength{\topsep}{\exsolexercisetopbottomsep}% |
| 1339 |
\setlength{\leftmargin}{\exsolexerciseleftmargin}% |
| 1340 |
\setlength{\rightmargin}{\exsolexerciserightmargin}% |
| 1341 |
\setlength{\listparindent}{\exsolexerciseparindent}% |
| 1342 |
\setlength{\itemindent}{\exsolexerciseitemindent}% |
| 1343 |
\setlength{\parsep}{\exsolexerciseparsep} |
| 1344 |
\setlength{\labelsep}{\exsolexerciselabelsep} |
| 1345 |
\setlength{\labelwidth}{\exsolexerciselabelwidth}} |
| 1346 |
\item[\ifexsol@nolabels~#1:\else\exercisename{}~#1:\fi]% |
| 1347 |
} |
| 1348 |
{\ifexsol@nolabels #1:\else% |
| 1349 |
\subparagraph{\exercisename{}~#1:}\fi} |
| 1350 |
} |
| 1351 |
{% |
| 1352 |
\ifthenelse{\boolean{exsol@exerciseaslist}}% |
| 1353 |
{\end{list}}{}% |
| 1354 |
\ifthenelse{\boolean{exsol@minipage}}{\end{minipage}}{\par}% |
| 1355 |
} |
| 1356 |
% \end{macrocode} |
| 1357 |
% \end{macro} |
| 1358 |
% |
| 1359 |
% |
| 1360 |
% \begin{macro}{solution} |
| 1361 |
% The |solution| environment is used to typeset your solutions |
| 1362 |
% and provide them with a nice label and number that corresponds to |
| 1363 |
% the exercise that preceeded this solution. Theno label can be |
| 1364 |
% set by redefining the \cs{solutionname} macro, or by relying on |
| 1365 |
% the \textsf{Babel} provisions. The code is almost litteraly |
| 1366 |
% taken from the \textsf{fancyvrb} package. |
| 1367 |
% \begin{macrocode} |
| 1368 |
\def\solution{\FV@Environment{}{solution}} |
| 1369 |
\def\FVB@solution{% |
| 1370 |
% \typeout{Writing solution to \jobname.sol.tex} |
| 1371 |
% WDSC |
| 1372 |
\ifexsol@copyexercisesinsolutions |
| 1373 |
\immediate\write\solutionstream{\string\begin{exsol@solution}{}} |
| 1374 |
\else |
| 1375 |
\ifexsol@inline |
| 1376 |
\immediate\write\solutionstream{\string\begin{exsol@solution}{}} |
| 1377 |
\else |
| 1378 |
\immediate\write\solutionstream{\string\begin{exsol@solution}{\theexercise}} |
| 1379 |
\fi |
| 1380 |
\fi |
| 1381 |
% \ifexsol@copyexercisesinsolutions |
| 1382 |
% \immediate\write\solutionstream{\string\begin{exsol@solution}{}} |
| 1383 |
% \else |
| 1384 |
% \immediate\write\solutionstream{\string\begin{exsol@solution}{\theexercise}} |
| 1385 |
% \fi |
| 1386 |
\@bsphack |
| 1387 |
\begingroup |
| 1388 |
\FV@UseKeyValues |
| 1389 |
\FV@DefineWhiteSpace |
| 1390 |
\def\FV@Space{\space}% |
| 1391 |
\FV@DefineTabOut |
| 1392 |
\let\FV@ProcessLine\GPSS@write@detok % |
| 1393 |
\relax |
| 1394 |
\let\FV@FontScanPrep\relax |
| 1395 |
\let\@noligs\relax |
| 1396 |
\FV@Scan |
| 1397 |
} |
| 1398 |
\def\FVE@solution{ |
| 1399 |
\endgroup\@esphack |
| 1400 |
\immediate\write\solutionstream{\string\end{exsol@solution}} |
| 1401 |
\ifexsol@inline |
| 1402 |
\immediate\closeout\solutionstream |
| 1403 |
\input{\jobname.sol.tex} |
| 1404 |
\immediate\openout\solutionstream=\jobname.sol.tex |
| 1405 |
\fi |
| 1406 |
} |
| 1407 |
\DefineVerbatimEnvironment{solution}{solution}{} |
| 1408 |
% \end{macrocode} |
| 1409 |
% \end{macro} |
| 1410 |
% |
| 1411 |
% \begin{macro}{exsol@solution} |
| 1412 |
% The |exsol@solution| environment is an internal macro used |
| 1413 |
% to typeset your solutions. Do not use it directly. Use the proper |
| 1414 |
% environment |solution| instead. |
| 1415 |
% \changes{v1.2}{2016/05/05}{Added |exsol@solution| environment for |
| 1416 |
% improved control on solution typesetting} |
| 1417 |
% \begin{macrocode} |
| 1418 |
\newenvironment{exsol@solution}[1] |
| 1419 |
{% |
| 1420 |
\ifthenelse{\boolean{exsol@minipage}}{\begin{minipage}[t]{\textwidth}}{}% |
| 1421 |
\ifthenelse{\boolean{exsol@exerciseaslist}} |
| 1422 |
{\begin{list}% |
| 1423 |
{% |
| 1424 |
}% |
| 1425 |
{% |
| 1426 |
\setlength{\topsep}{\exsolexercisetopbottomsep}% |
| 1427 |
\setlength{\leftmargin}{\exsolexerciseleftmargin}% |
| 1428 |
\setlength{\rightmargin}{\exsolexerciserightmargin}% |
| 1429 |
\setlength{\listparindent}{\exsolexerciseparindent}% |
| 1430 |
\setlength{\itemindent}{\exsolexerciseitemindent}% |
| 1431 |
\setlength{\parsep}{\exsolexerciseparsep} |
| 1432 |
\setlength{\labelsep}{\exsolexerciselabelsep} |
| 1433 |
\setlength{\labelwidth}{\exsolexerciselabelwidth}} |
| 1434 |
\item[\ifexsol@nolabels #1:\else% |
| 1435 |
\solutionname{}\@ifmtarg{#1}{}{~}#1:\fi] |
| 1436 |
}% |
| 1437 |
{\ifexsol@nolabels #1:\else% |
| 1438 |
\subparagraph{\solutionname{}\@ifmtarg{#1}{}{~}#1:}\fi} |
| 1439 |
} |
| 1440 |
{% |
| 1441 |
\ifthenelse{\boolean{exsol@exerciseaslist}}% |
| 1442 |
{\end{list}}{}% |
| 1443 |
\ifthenelse{\boolean{exsol@minipage}}{\end{minipage}}{\par}% |
| 1444 |
} |
| 1445 |
% \end{macrocode} |
| 1446 |
% \end{macro} |
| 1447 |
% |
| 1448 |
% |
| 1449 |
% \begin{macro}{exercises} |
| 1450 |
% The |exercises| environment helps typesetting your exercises to |
| 1451 |
% stand out from the rest of the text. You may use it at the end of |
| 1452 |
% a chapter, or just to group some exercises in the text. |
| 1453 |
% \changes{v0.2}{2012/01/06}{Attempted to fix MiKTeX formatting problems} |
| 1454 |
% \changes{v0.3}{2012/01/07}{Added some extra whitespace below |
| 1455 |
% exercisesname} |
| 1456 |
% \changes{v1.2}{2016/05/05}{Added multicolumn feature} |
| 1457 |
% \begin{macrocode} |
| 1458 |
\define@key{exercises}{columns}{\renewcommand\columncount{#1}} |
| 1459 |
\define@key{exercises}{exsubrule}{\renewcommand\exsubrule{#1}} |
| 1460 |
\define@key{exercises}{solsubrule}{\renewcommand\solsubrule{#1}} |
| 1461 |
\define@key{exercises}{subrule}{\renewcommand\exsubrule{#1}\renewcommand\solsubrule{#1}} |
| 1462 |
\newenvironment{exercises}[1][] |
| 1463 |
{% |
| 1464 |
\newcommand\columncount{1}% default |
| 1465 |
\newcommand\exsubrule{}% default |
| 1466 |
\newcommand\solsubrule{}% default |
| 1467 |
\setkeys{exercises}{#1}% |
| 1468 |
\exercisesfontsize\rule{.25\linewidth}{0.15mm}% |
| 1469 |
\vspace*{-1.5\baselineskip}% |
| 1470 |
\paragraph{\exercisesname}~\\* |
| 1471 |
\ifthenelse{\columncount > 1}{\begin{multicols}{\columncount}}{}% |
| 1472 |
}% |
| 1473 |
{ |
| 1474 |
\ifthenelse{\columncount > 1}{\end{multicols}}{}\relax% |
| 1475 |
\vspace*{-\baselineskip}\vspace*{\exsolexercisesbelowskip}% |
| 1476 |
\exsubrule\par} |
| 1477 |
% \end{macrocode} |
| 1478 |
% \end{macro} |
| 1479 |
% |
| 1480 |
% \changes{v1.2}{2016/05/05}{Added exerciseseries environment} |
| 1481 |
% \begin{macro}{exerciseseries} |
| 1482 |
% The |exerciseseries| environment helps typesetting your |
| 1483 |
% exercises in series. |
| 1484 |
% \begin{macrocode} |
| 1485 |
\define@key{exerciseseries}{columns}{\renewcommand\columncount{#1}} |
| 1486 |
\define@key{exerciseseries}{exsubrule}{\renewcommand\exsubrule{#1}} |
| 1487 |
\define@key{exerciseseries}{solsubrule}{\renewcommand\solsubrule{#1}} |
| 1488 |
\define@key{exerciseseries}{subrule}{\renewcommand\exsubrule{#1}\renewcommand\solsubrule{#1}} |
| 1489 |
\newenvironment{exerciseseries}[2][] |
| 1490 |
{ |
| 1491 |
\refstepcounter{exerciseseries}% |
| 1492 |
\newcommand\columncount{1} % default |
| 1493 |
\newcommand\exsubrule{} % default |
| 1494 |
\newcommand\solsubrule{} % default |
| 1495 |
\setkeys{exerciseseries}{#1}% |
| 1496 |
\paragraph{\seriesname~\theexerciseseries:~#2}~\par |
| 1497 |
\ifthenelse{\columncount > 1}{\begin{multicols}{\columncount}}{} |
| 1498 |
\ifexsol@inline\else |
| 1499 |
\immediate\write\solutionstream{\string\begin\string{solutionseries\string}% |
| 1500 |
\string[#1\string]\string{#2\string}\string{\theexerciseseries\string}} |
| 1501 |
\fi |
| 1502 |
} |
| 1503 |
{ |
| 1504 |
\ifthenelse{\columncount > 1}{\end{multicols}}{}\relax |
| 1505 |
\exsubrule\par |
| 1506 |
\ifexsol@inline\else |
| 1507 |
\immediate\write\solutionstream{\string\end\string{solutionseries\string}} |
| 1508 |
\fi |
| 1509 |
} |
| 1510 |
% \end{macrocode} |
| 1511 |
% \end{macro} |
| 1512 |
% \changes{v1.2}{2016/05/05}{Added solutionseries environment} |
| 1513 |
% \changes{v1.4}{2018/10/23}{. Implemented option to display |
| 1514 |
% solutionserieslabels when option 'usersolutionserieslabels' is true} |
| 1515 |
% \begin{macro}{solutionseries} |
| 1516 |
% The |solutionseries| environment helps typesetting your |
| 1517 |
% solutions in series. You don't need to use this function |
| 1518 |
% explicitly. The package does this for you. |
| 1519 |
% \begin{macrocode} |
| 1520 |
\newenvironment{solutionseries}[3][] |
| 1521 |
{ |
| 1522 |
\newcommand\columncount{1} % default |
| 1523 |
\newcommand\exsubrule{} % default |
| 1524 |
\newcommand\solsubrule{} % default |
| 1525 |
\setkeys{exercises}{#1}% |
| 1526 |
\paragraph{\seriesname~#3\ifexsol@usesolutionserieslabels: #2\fi}~\par |
| 1527 |
\ifthenelse{\columncount > 1}{\begin{multicols}{\columncount}}{} |
| 1528 |
} |
| 1529 |
{ |
| 1530 |
\ifthenelse{\columncount > 1}{\end{multicols}}{} |
| 1531 |
\solsubrule\par |
| 1532 |
} |
| 1533 |
% \end{macrocode} |
| 1534 |
% \end{macro} |
| 1535 |
% |
| 1536 |
% \begin{macro}{informulacollection} |
| 1537 |
% The |informulacollection| environment is used to write its |
| 1538 |
% contents to the formula collection stream and load back into the |
| 1539 |
% main text for typesetting. The code is almost litteraly |
| 1540 |
% taken from the \textsf{fancyvrb} package. |
| 1541 |
% \begin{macrocode} |
| 1542 |
\def\informulacollection{\FV@Environment{}{informulacollection}} |
| 1543 |
\def\FVB@informulacollection{% |
| 1544 |
\immediate\openout\formulastream=\jobname.for.tex |
| 1545 |
%\typeout{Writing formula to \jobname.for.tex and \jobname.fc.tex} |
| 1546 |
\@bsphack |
| 1547 |
\begingroup |
| 1548 |
\FV@UseKeyValues |
| 1549 |
\FV@DefineWhiteSpace |
| 1550 |
\def\FV@Space{\space}% |
| 1551 |
\FV@DefineTabOut |
| 1552 |
\let\FV@ProcessLine\GPFORCOL@write@detok % |
| 1553 |
\relax |
| 1554 |
\let\FV@FontScanPrep\relax |
| 1555 |
\let\@noligs\relax |
| 1556 |
\FV@Scan |
| 1557 |
} |
| 1558 |
\def\FVE@informulacollection{ |
| 1559 |
\endgroup\@esphack |
| 1560 |
\immediate\closeout\formulastream |
| 1561 |
\input{\jobname.for.tex} |
| 1562 |
} |
| 1563 |
\DefineVerbatimEnvironment{informulacollection}{informulacollection}{} |
| 1564 |
% \end{macrocode} |
| 1565 |
% \end{macro} |
| 1566 |
% |
| 1567 |
% \begin{macro}{informulacollectiononly} |
| 1568 |
% The |informulacollectiononly| environment is used to write its |
| 1569 |
% contents to the formula collection stream \emph{without} loading |
| 1570 |
% it back into the main text for typesetting. The code is almost litteraly |
| 1571 |
% taken from the \textsf{fancyvrb} package. |
| 1572 |
% \begin{macrocode} |
| 1573 |
\def\informulacollectiononly{\FV@Environment{}{informulacollectiononly}} |
| 1574 |
\def\FVB@informulacollectiononly{% |
| 1575 |
%\typeout{Writing special to \jobname.fc.tex} |
| 1576 |
\@bsphack |
| 1577 |
\begingroup |
| 1578 |
\FV@UseKeyValues |
| 1579 |
\FV@DefineWhiteSpace |
| 1580 |
\def\FV@Space{\space}% |
| 1581 |
\FV@DefineTabOut |
| 1582 |
\let\FV@ProcessLine\GPFORCOLONLY@write@detok % |
| 1583 |
\relax |
| 1584 |
\let\FV@FontScanPrep\relax |
| 1585 |
\let\@noligs\relax |
| 1586 |
\FV@Scan |
| 1587 |
} |
| 1588 |
\def\FVE@informulacollectiononly{ |
| 1589 |
\endgroup\@esphack |
| 1590 |
} |
| 1591 |
\DefineVerbatimEnvironment{informulacollectiononly}{informulacollectiononly}{} |
| 1592 |
% \end{macrocode} |
| 1593 |
% \end{macro} |
| 1594 |
% |
| 1595 |
% \subsection{Some Babel provisions} |
| 1596 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1597 |
% \changes{v0.2}{2012/01/06}{Fixed babel errors} |
| 1598 |
% \begin{macrocode} |
| 1599 |
\newcommand{\exercisename}{Exercise} |
| 1600 |
\newcommand{\exercisesname}{Exercises} |
| 1601 |
\newcommand{\solutionname}{Solution} |
| 1602 |
\newcommand{\solutionsname}{Solutions} |
| 1603 |
\newcommand{\seriesname}{Series} |
| 1604 |
% \end{macrocode} |
| 1605 |
% |
| 1606 |
% |
| 1607 |
% You may redefine these macros, but to help you out a little bit, we |
| 1608 |
% provide with some basic Babel auxiliaries. If you're a true polyglot |
| 1609 |
% and are willing to help me out by providing translations for other |
| 1610 |
% languages, I'm very willing to incorporate them into the code. |
| 1611 |
% |
| 1612 |
% \changes{v0.7}{2014/07/14}{Added Finnish language support} |
| 1613 |
% \changes{v1.2}{2016/05/05}{Added Spanish language support} |
| 1614 |
% \changes{v1.2}{2016/05/05}{Completed German language support |
| 1615 |
% (i.e. new spelling ngerman) support} |
| 1616 |
% \begin{macrocode} |
| 1617 |
\addto\captionsdutch{% |
| 1618 |
\renewcommand{\exercisename}{Oefening}% |
| 1619 |
\renewcommand{\exercisesname}{Oefeningen}% |
| 1620 |
\renewcommand{\solutionname}{Oplossing}% |
| 1621 |
\renewcommand{\solutionsname}{Oplossingen}% |
| 1622 |
\renewcommand{\seriesname}{Reeks}% |
| 1623 |
} |
| 1624 |
\addto\captionsgerman{% |
| 1625 |
\renewcommand{\exercisename}{Aufgabe}% |
| 1626 |
\renewcommand{\exercisesname}{Aufgaben}% |
| 1627 |
\renewcommand{\solutionname}{L\"osung}% |
| 1628 |
\renewcommand{\solutionsname}{L\"osungen}% |
| 1629 |
\renewcommand{\seriesname}{Serie}% |
| 1630 |
} |
| 1631 |
\addto\captionsngerman{% |
| 1632 |
\renewcommand{\exercisename}{Aufgabe}% |
| 1633 |
\renewcommand{\exercisesname}{Aufgaben}% |
| 1634 |
\renewcommand{\solutionname}{L\"osung}% |
| 1635 |
\renewcommand{\solutionsname}{L\"osungen}% |
| 1636 |
\renewcommand{\seriesname}{Serie}% |
| 1637 |
} |
| 1638 |
\addto\captionsfrench{% |
| 1639 |
\renewcommand{\exercisename}{Exercice}% |
| 1640 |
\renewcommand{\exercisesname}{Exercices}% |
| 1641 |
\renewcommand{\solutionname}{Solution}% |
| 1642 |
\renewcommand{\solutionsname}{Solutions}% |
| 1643 |
\renewcommand{\seriesname}{Serie}% |
| 1644 |
} |
| 1645 |
\addto\captionsfinnish{ |
| 1646 |
\renewcommand{\exercisename}{Teht\"av\"a}% |
| 1647 |
\renewcommand{\exercisesname}{Teht\"avi\"a}% |
| 1648 |
\renewcommand{\solutionname}{Ratkaisu}% |
| 1649 |
\renewcommand{\solutionsname}{Ratkaisut}% |
| 1650 |
\renewcommand{\seriesname}{Sarja} |
| 1651 |
} |
| 1652 |
\addto\captionsspanish{% |
| 1653 |
\renewcommand{\exercisename}{Ejercicio}% |
| 1654 |
\renewcommand{\exercisesname}{Ejercicios}% |
| 1655 |
\renewcommand{\solutionname}{Soluci\'on}% |
| 1656 |
\renewcommand{\solutionsname}{Soluciones}% |
| 1657 |
\renewcommand{\seriesname}{Serie}% |
| 1658 |
} |
| 1659 |
% \end{macrocode} |
| 1660 |
% |
| 1661 |
% |
| 1662 |
% |
| 1663 |
% Now the final hack overloads the basic sectioning commands to make |
| 1664 |
% sure that they are copied into your solution book. |
| 1665 |
% |
| 1666 |
% \changes{v1.0}{2015/09/16}{Added congruence of chaptercounter of |
| 1667 |
% main document and chapter counter of exercises document} |
| 1668 |
% \changes{v1.1}{2015/09/16}{Corrected congruence of chaptercounter of |
| 1669 |
% main document and chapter counter of exercises document (taking |
| 1670 |
% intou account alphanumbered chapters} |
| 1671 |
% \changes{v1.3}{2016/08/09}{Corrected counter in solutionstream} |
| 1672 |
% \changes{v1.3}{2016/08/09}{Added macro to suppress chapter in |
| 1673 |
% solution stream} |
| 1674 |
% \changes{v1.5}{2019/01/02}{Added writing the sectioning code to the |
| 1675 |
% exercise stream in external mode} |
| 1676 |
% \changes{v1.7}{2025/02/14}{Changed makechapterhead into @chapter to avoid incompatibility with spelatex} |
| 1677 |
% \begin{macrocode} |
| 1678 |
\newif\ifnoexinchapter |
| 1679 |
\noexinchapterfalse |
| 1680 |
\ifexsol@local |
| 1681 |
\else |
| 1682 |
\ifx\chapter\@undefined\else |
| 1683 |
\let\exsol@@chapter\@chapter |
| 1684 |
\def\@chapter[#1]#2{% |
| 1685 |
\exsol@@chapter[#1]{#2} |
| 1686 |
\ifnoexinchapter |
| 1687 |
\noexinchapterfalse |
| 1688 |
\else |
| 1689 |
\addtocounter{chapter}{-1} |
| 1690 |
\immediate\write\solutionstream{\string\setcounter{chapter}{\arabic{chapter}}% |
| 1691 |
\string\chapter{#1}}% |
| 1692 |
\ifexsol@external |
| 1693 |
\immediate\write\exercisestream{\string\setcounter{chapter}{\arabic{chapter}}% |
| 1694 |
\string\chapter{#1}}% |
| 1695 |
\fi |
| 1696 |
\addtocounter{chapter}{1} |
| 1697 |
\fi |
| 1698 |
} |
| 1699 |
\fi |
| 1700 |
|
| 1701 |
\ifdefined\frontmatter |
| 1702 |
\let\exsol@@frontmatter\frontmatter |
| 1703 |
\def\frontmatter{% |
| 1704 |
\immediate\write\solutionstream{\string\frontmatter}% |
| 1705 |
\ifexsol@external% |
| 1706 |
\immediate\write\exercisestream{\string\frontmatter}% |
| 1707 |
\fi% |
| 1708 |
\exsol@@frontmatter |
| 1709 |
} |
| 1710 |
\fi |
| 1711 |
\ifdefined\frontmatter |
| 1712 |
\let\exsol@@mainmatter\mainmatter |
| 1713 |
\def\mainmatter{% |
| 1714 |
\immediate\write\solutionstream{\string\mainmatter}% |
| 1715 |
\ifexsol@external% |
| 1716 |
\immediate\write\exercisestream{\string\mainmatter}% |
| 1717 |
\fi% |
| 1718 |
\exsol@@mainmatter |
| 1719 |
} |
| 1720 |
\fi |
| 1721 |
\ifdefined\backmatter |
| 1722 |
\let\exsol@@backmatter\backmatter |
| 1723 |
\def\backmatter{% |
| 1724 |
\immediate\write\solutionstream{\string\backmatter}% |
| 1725 |
\ifexsol@external% |
| 1726 |
\immediate\write\exercisestream{\string\backmatter}% |
| 1727 |
\fi% |
| 1728 |
\exsol@@backmatter |
| 1729 |
} |
| 1730 |
\fi |
| 1731 |
\ifdefined\appendix |
| 1732 |
\let\exsol@@appendix\appendix |
| 1733 |
\def\appendix{% |
| 1734 |
\immediate\write\solutionstream{\string\appendix}% |
| 1735 |
\ifexsol@external% |
| 1736 |
\immediate\write\exercisestream{\string\appendix}% |
| 1737 |
\fi% |
| 1738 |
\exsol@@appendix |
| 1739 |
} |
| 1740 |
\fi |
| 1741 |
\fi |
| 1742 |
% \end{macrocode} |
| 1743 |
% |
| 1744 |
% \begin{macro}{\noexercisesinnextchapter} |
| 1745 |
% If you have chapters without exercises, you may want to leave them |
| 1746 |
% out of your solution book. You can do this by putting the |
| 1747 |
% |\noexercisesinnextchapter| macro before your chapter mark. |
| 1748 |
% \begin{macrocode} |
| 1749 |
\newcommand{\noexercisesinnextchapter} |
| 1750 |
{ |
| 1751 |
\noexinchaptertrue |
| 1752 |
} |
| 1753 |
% \end{macrocode} |
| 1754 |
% \end{macro} |
| 1755 |
% |
| 1756 |
% \begin{macro}{\noexercisesinnextchapter} |
| 1757 |
% As an alternative you may just want to put this marker in your |
| 1758 |
% text to cause the printing of the sentence ``No exercises in this |
| 1759 |
% chapter'' in your solution book. |
| 1760 |
% \begin{macrocode} |
| 1761 |
\newcommand{\noexercisesinchapter} |
| 1762 |
{ |
| 1763 |
\immediate\write\solutionstream{No exercises in this chapter} |
| 1764 |
\ifexsol@external% |
| 1765 |
\immediate\write\exercisestream{No exercises in this chapter}% |
| 1766 |
\fi% |
| 1767 |
} |
| 1768 |
% \end{macrocode} |
| 1769 |
% \end{macro} |
| 1770 |
% |
| 1771 |
% \begin{macrocode} |
| 1772 |
%</package> |
| 1773 |
% \end{macrocode} |
| 1774 |
% |
| 1775 |
% \bibliographystyle{alpha} |
| 1776 |
% |
| 1777 |
% \begin{thebibliography}{99} |
| 1778 |
% |
| 1779 |
% \bibitem{fancyvrb} |
| 1780 |
% Timothy Van Zandt, Herbert Vo\ss, Denis Girou, Sebastian Rahtz, Niall |
| 1781 |
% Mansfield |
| 1782 |
% \newblock The \texttt{fancyvrb} package. |
| 1783 |
% \newblock \url{http://ctan.org/pkg/fancyvrb}. |
| 1784 |
% \newblock online, accessed in January 2012. |
| 1785 |
% |
| 1786 |
% \bibitem{CTAN} |
| 1787 |
% The Comprehensive TeX Archive Network. |
| 1788 |
% \newblock \url{http://www.ctan.org}. |
| 1789 |
% \newblock online, accessed in January 2012. |
| 1790 |
% |
| 1791 |
% \end{thebibliography} |
| 1792 |
% |
| 1793 |
% \Finale |
| 1794 |
\endinput |