% \iffalse meta-comment % % Copyright (C) 2020-2023 by Antoine Missier % ---------------------------------------------------------------------- % % This file may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 % of this license or (at your option) any later version. % The latest version of this license is in: % % http://www.latex-project.org/lppl.txt % % and version 1.3 or later is part of all distributions of LaTeX % version 2005/12/01 or later. % % \fi % % \iffalse %<*driver> \ProvidesFile{exesheet.dtx} % %\NeedsTeXFormat{LaTeX2e}[2005/12/01] %\ProvidesClass{exesheet} %\ProvidesPackage{exesheet} %<*class|package> [2023/08/25 v2.1 .dtx exesheet file] % %<*driver> \documentclass{ltxdoc} % % uncomment the following lines if you want to use the exesheet class instead of ltxdoc %\usepackage{doc} %\AtBeginDocument{\MakeShortVerb{\|}} %\providecommand\marg[1]{{\ttfamily\{}\meta{#1}{\ttfamily\}}} %\providecommand\oarg[1]{{\ttfamily[}\meta{#1}{\ttfamily]}} \usepackage[exetoc=false,marginwidth=unset,display=notes]{exesheet} \usepackage{schooldocs} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[english]{babel} \usepackage{lmodern} \usepackage{multicol} \usepackage{hyperref} \usepackage{sectsty} \usepackage{pstricks} \usepackage{array} \usepackage{spacingtricks} % \psset{unit=1cm} \geometry{textwidth=355pt,vmarginratio=1:1,hmarginratio=3:2} % altered by schoodocs, now very close from the default geometry used by ltxdoc. % The following instruction gives the same margin width % as with display=notes without altering the margin ratio \leftnotemarginwidth{0.55} % special setting here \newcommand{\ds}{\displaystyle} \newcommand{\bs}{\textbackslash} \definecolor{darkbrown}{rgb}{0.5,0.1,0.1} \allsectionsfont{\sffamily\color{darkbrown}} \renewcommand{\labelexercisestyle}{\rmfamily\color{black}} \renewcommand{\labelsubpartstyle}{\rmfamily\color{black}} \renewcommand{\annexstyle}{\rmfamily\color{black}\MakeUppercase} \renewcommand{\correctionstyle}{\rmfamily\color{correctioncolor}} \renewcommand{\titlestyle}{\LARGE\sffamily\bfseries} % \DisableCrossrefs %\CodelineIndex %\RecordChanges \title{The \textsf{exesheet} class and package} \subject{Antoine Missier \\ \texttt{antoine.missier@ac-toulouse.fr}} \date{\filedate, \fileversion} \hypersetup{% colorlinks, linkcolor=blue, pdftitle={exesheet}, pdfsubject={LaTeX class and package}, pdfauthor={Antoine Missier} } \begin{document} \DocInput{exesheet.dtx} \end{document} % % \fi % % \CheckSum{1132} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z % 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 % Digits \0\1\2\3\4\5\6\7\8\9 % Exclamation \! Double quote \" Hash (number) \# % Dollar \$ Percent \% Ampersand \& % Acute accent \' Left paren \( Right paren \) % Asterisk \* Plus \+ Comma \, % Minus \- Point \. Solidus \/ % Colon \: Semicolon \; Less than \< % Equals \= Greater than \> Question mark \? % Commercial at \@ Left bracket \[ Backslash \\ % Right bracket \] Circumflex \^ Underscore \_ % Grave accent \` Left brace \{ Vertical bar \| % Right brace \} Tilde \~} % % \changes{v0.0}{2010/09/01}{Initial personal version} % \changes{v0.9}{2020/01/02}{Initial documentation in french} % \changes{v1.0}{2020/07/22}{Initial public version with documentation in english} % \changes{v1.1}{2021/08/30}{ % Macro tablenum (also used by siunitx) replaced by tablenum1, % small modifications due to changes in tasks package} % % \changes{v1.2}{2021/09/18}{ % Bug correction in macros tablenum1 and tablenuma, % using the translations package for internationalization} % % \changes{v1.3}{2021/11/15}{ % Bad spacing in the exe macro and bug correction in the starred version of this macro} % % \changes{v2.0}{2022/12/28}{ % options toc and setlist with kvoptions (instead of notoc and nosetlist), % introducing the key 'output' instead of old commands questionsonly, answersonly, % introducing the key 'display' instead of old command displaypts, displaypoints, % displaynotes, % introducing the keys 'margin' and 'noteragged' to set how the notes are displayed, % introducing the key 'correct'} % \changes{v2.0}{2023/01/02}{ % documentation update, % new option checkpts} % \changes{v2.0}{2023/01/09}{ % new option 'marginwidth', % modifying hmarginratio from 5:1 to 3:1 when display=notes, % correct management of two side mode documents} % \changes{v2.0}{2023/01/16}{ % \enskip between titles and their optional argument, % simplifying macros markingstyle and notestyle, % use of ragged2e package, % code revision and simplification, % documentation update} % % \changes{v2.1}{2023/07/30}{ % new environments tablenuma* and tablitem*} % \changes{v2.1}{2023/08/24}{ % English correction in the documentation} % % \GetFileInfo{exesheet.dtx} % % \maketitle % \tableofcontents % \enlargethispage{1ex} % % \section{Introduction} % % The \textsf{exesheet} \emph{package} is designed for typesetting exercise or exam sheets. % Additionally, the \textsf{exesheet} \emph{class} loads the \textsf{schooldocs} package. % The latter makes adjustments to margins and titles, and defines various layout styles % with specific headers and footers suitable for exercise sheets, among other uses. % Refer to the documentation of the \textsf{schooldocs} package for more details. % The \textsf{exesheet} \emph{class} is build upon the \textsf{article} class % and forwards any unknown options to it. % % There are many other packages dedicated to exercise sheets. % Most of them suggest encapsulating each exercise within an environment. % In contrast, \textsf{exesheet} starts each exercise with |\exercise|, % which functions similarly to a subsection (with the same features) % and is suitable for documents that primarily consist of exercises. % The package also offers alternative formatting, % which is more suitable for shorter exercises. % % Another distinctive feature of the \textsf{exesheet} package is its specific settings % for enumeration lists, which are % useful for numbering questions or answers within an exercise. % % While other packages often offer more or less complex mechanisms % for managing the placement of answers, % \textsf{exesheet} doesn't aspire to such complexity. However, % for all exercises within the sheet, you have the capability to display only questions, % only answers, or both, all while preserving their placement as they appear % in the source file. This choice allows for great flexibility: % you can create a correct version for all exercises collectively, % or individual corrections per exercise, % per part (subpart of exercise), per question, per sub-question. % % Finally this package enables to display a detailed marking scheme in the margin, % with optional explanations or remarks, % and offering consistency control. % % Many settings can be customized, and various options are available % to manage the output document. % These options rely on the key-val mechanism: \texttt{key=value} % (thanks to Maxime Chupin and Denis Bitouzé for suggesting this idea to improve this package). % These options can be applied to the class or the package, \eg % \begin{center} % |\documentclass[a4paper,11pt,output=answers,display=pts]{exesheet}| % \end{center} % or later using the command |\exesheetset|\marg{options}. % In the example above, \texttt{a4paper,11pt} are options % that are passed to the underlying \textsf{article} class. % %\medskip % \emph{In the current document, a frame is utilized to emphasize output % examples.} % % \section{Titles} % % \subsection{The \texttt{\bs exercise} command} % % \DescribeMacro{\exercise} % Each exercise starts with the |\exercise|\oarg{opt} command. % This command typesets \textbf{\exercisename}, as a document % subsection, followed by automatic numbering % unique to the entire document. % The optional parameter \meta{opt} is utilized to include additional text % on the same title line, such as specifying a subject or a marking scheme. % Thus, using |\exercise[(to begin)]| results in: % % \exercise[(to begin)] % \psframe(-0.25,1.3)(12.75,-0.3) % Give this initial command a try; it's straightforward. % % \bigskip % To bring additional text closer to the exercise number, % we can employ |\unskip| which removes any preceding space. % Take a look at the following example, achieved with % |\exercise[\unskip*** (difficult)]|: % \exercise[\unskip*** (difficult)] % \psframe(-0.25,1.3)(12.75,-0.3) % Calculate $1+1$. % % \bigskip % ^^A Various settings can be modified by refining the following commands. % % ^^A \medskip % \DescribeMacro{\exercisename} % The term ``\exercisename'' is automatically translated into various languages % \footnote{Currently, translation is integrated into the package % for the following languages: French, German, Spanish, Italian, and Portuguese.} % depending on the language that is loaded (via \textsf{babel} or \textsf{polyglossia}). % You can redefine it using |\renewcommand|. % A better approach is to use macros from the \textsf{translations} % package by Clemens Niederberger (which allows dynamic language switching), \eg % |\DeclareTranslation{Swedish}{exesheet-exercise}{\"Ovning}}|. % % \smallskip % \DescribeMacro{\labelexercise} % This command combines |\exercisename| with the exercise number and % can be redefined. For instance, if you want to include a period after the exercise number, % you can redefine it as follows:\\ % |\renewcommand{\labelexercise}{\exercisename~\theexercise.}| % % \smallskip % \DescribeMacro{\theexercise} % If you wish to alter only the numbering style, you can redefine % the |\theexercise| command based on the |exercise| counter. % % \smallskip % \DescribeMacro{\labelexercisestyle} % This macro, which is initially empty, enables the definition of a specific style % for exercise titles. In this document, we have set the following in the preamble: % |\renewcommand{\labelexercisestyle}{\rmfamily\color{black}}| % \footnote{In this document, real section and subsection titles have been highlighted by % modifying their color and font using the % \texttt{\bs allsectionsfont} macro from the \textsf{sectsty} package.}. % % \medskip % \DescribeMacro{\exercise*} % The starred version |\exercise*|\oarg{opt}\marg{label} % permits the selection of an alternative \meta{label} for a specific exercise % while omitting the numbering. For instance: % |\exercise*[(Fermat's theorem)]{Problem}| results in: % % \exercise*[(Fermat's theorem)]{Problem} % \psframe(-0.25,1.3)(12.75,-0.7) % Prove that there are no positive integers $x, y, z$ such that $x^n+y^n=z^n$ % for any integer $n$ greater than 2. % % \subsection{The \texttt{\bs subpart} command} % \DescribeMacro{\subpart} % An exercise may consist of multiple parts, which can be created using % the |\subpart|\oarg{opt} command. % The part title is typeset similar to a sub-subsection. % % \exercise % \subpart[(preliminary)] % \psframe(-0.25,1.95)(12.75,-1.85) % To begin, prepare your cup of tea. % \subpart % Now you are ready to proceed with the current exercise. % \bigskip % % \pagebreak % The following macros manage formatting in the same manner as for |\exercise|. % % \medskip % \DescribeMacro{\thesubpart} % By default, subpart numbering employs letters : A, B, C, and so on. % This numbering style can be modified using the |\thesubpart| command, which relies on % the |subpart| counter. For example, you can redefine it as follows: % |\renewcommand\thesubpart{\arabic{subpart}}|. % % \smallskip % \DescribeMacro{\subpartname} \DescribeMacro{\labelsubpart} % \DescribeMacro{\labelsubpartstyle} % The |\subpart| command % utilizes |\subpartname| (with automatic translation in several languages % according to the chosen language), as well as % |\labelsubpart| and |\labelsubpartstyle|, all of which can be modified. % % \medskip % \DescribeMacro{\subpart*} % Similar to |\exercise*|, the starred version |\subpart*|\oarg{opt}\marg{label} % permits an alternative \meta{label} and omits the numbering. For instance, % you can use |\subpart*{First part}|. % % \subsection{The \texttt{\bs annex} command} % \DescribeMacro{\annex} % The |\annex|\oarg{opt} command composes the title \textbf{ANNEX} % in uppercase letters, centered, using the subsection style, % with an optional parameter that will be added on the same line. % % \vspace{-\baselineskip} % \noindent\psframe(-0.25,-0.3)(12.75,-1.3) % \annex[(to be returned)] % % \bigskip % \DescribeMacro{\annexname} % The term ``\annexname'' is automatically translated into several languages. % It can be extended to additional languages or altered by redefining |\annexname| % or by utilizing macros from the \textsf{translations} package. % % \smallskip % \DescribeMacro{\annexstyle} % The style of the annex title is determined by the |\annexstyle| macro, % which is defined as follows: |\newcommand\annexstyle{\MakeUppercase}|. % This command may be redefined according to your preferences. % % \subsection{Exercise titles in the table of contents} \label{toc} % \DescribeMacro{[exetoc=\meta{bool}]} % By default, the titles \textbf{\exercisename}, \textbf{\subpartname} % and \textbf{\annexname} are included in the table of contents if there is any % (or in the PDF file's summary when the \textsf{hyperref} package is utilized). % To prevent this, you can set the package option \texttt{exetoc=false} % (with the default being \texttt{true}). % However, note that optional title arguments will always be ignored in the table of contents. % % \subsection{Short exercises: the \texttt{\bs exe} command} % \DescribeMacro{\exe} % The |\exe| command initiates an exercise with the abbreviation \textbf{\exname}.\@ % followed by the exercise number. This is achieved without % utilizing sectioning commands, and the exercise content begins on the same % line. An exercise begins a new paragraph without any indentation. % % \exe This is a brief exercise that can encompass several % paragraphs or questions. % % \noindent\psframe(-0.25,1.4)(12.75,-1.2) % \indent Here for example a new paragraph begins. % \exe This is another concise exercise. % % \bigskip % \DescribeMacro{\exname} \DescribeMacro{\exlabel} \DescribeMacro{\exsepmark} % The abbreviation \textbf{\exname} can be modified by % redefining |\exname| or with macros from the \textsf{translations} package. % The |\exlabel| macro combines |\exname| with a period then the exercise number % (given by the \texttt{exercise} counter), % while |\exsepmark| typesets a long dash. % You can alter these characteristics by redefining these commands. % % \medskip % \DescribeMacro{\exe*} % The starred version doesn't display a separator, as demonstrated below: % % \vspace{-\baselineskip} % \noindent\psframe(-0.25,-0.35)(12.75,-1.1) % \exe* Another short exercise without a separator. % % \section{Enumerations and lists} % % \subsection{List settings} \label{setlist} % \DescribeEnv{enumerate} \DescribeMacro{\item} % Enumeration lists are designed to represent questions and sub-questions % within exercises. To provide clear emphasis, % labels are formatted in bold. % Additionally, these labels are aligned to the left, positioned at the start of the line % without indentation, and the vertical spacing between items % is increased compared to standard \LaTeX{} lists. % These formatting adjustments are achieved using the |\setlist| command % \footnote{Labels can also be modified by providing an optional argument, % \eg \texttt{\bs begin\{enumerate\}[A.]}, % or globally through the use of \texttt{\bs labelenumi} % and \texttt{\bs labelenumii} commands.}, % a feature from the \textsf{enumitem} package by Javier Bezos. % Lists created with the \texttt{itemize} environment retain their default % configuration % \footnote{The \texttt{french} option of the \textsf{babel} package % changes the behavior of \texttt{itemize} lists and employs long dashes % as labels for each list level. % This behavior can cause issues when mathematical content follows the dash % symbol, as it might be mistaken for the minus sign. % The default \texttt{itemize} list style is reinstated to address this concern.}. % % \vspace{-\baselineskip} % \noindent\psframe(-0.25,-0.35)(12.75,-3.9) % \exercise % \begin{enumerate} % \item First question % \begin{enumerate} % \item First sub-question % \item Second sub-question % \end{enumerate} % \item Second question % \end{enumerate} % % \smallskip % \DescribeMacro{[setlist=\meta{bool}]} % To prevent changes to enumeration lists and revert to the default \LaTeX{} % settings, you can utilize the package option |setlist=false| % (with the default value being \texttt{true} of course). % % \subsection{List of exercises : the \texttt{exenumerate} environment} % \DescribeEnv{exenumerate} % When an exercise sheet consists of short, independent questions, % it might be unreasonable to display the full title \textbf{\exercisename} for each one. % In addition to the previously mentioned |\exe| command, % we offer an even more streamlined solution using the |exenumerate| environment. % This environment is essentially an enumeration list with increased spacing % between items, compared to the \texttt{enumerate} environment. % Here is an example (the main list uses the \texttt{exenumerate} environment, while the % sub-list is created using the standard \texttt{enumerate} environment): % % \pagebreak % ^^A \vspace{-\baselineskip} % \noindent\psframe(-0.25,-0.3)(12.75,-6) % \begin{exenumerate} % \item Translate the following sentences in English: % \begin{enumerate} % \item Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. % \item Nam lacus libero, pretium at, lobortis vitae, ultricies et, tellus. % \end{enumerate} % \item Translate the following sentence in German: % \par Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna, % vitae ornare odio metus a mi. % \item Translate the following sentence in French: % Cum sociis natoque penatibus % et magnis dis parturient montes, nascetur ridiculus mus. % \end{exenumerate} % % \medskip % The environment takes an optional parameter, similar to \texttt{enumerate}, % that allows, among others things, % the typesetting of alternative list labels, \eg % |\begin{exenumerate}[A.]|. % There are numerous other options available % (refer to the \textsf{enumitem} package documentation for details). % % \subsection{Items aligned by row: \texttt{tablenum1}, \texttt{tablenuma}, \texttt{tablitem}} % \DescribeEnv{tablenum1} % \DescribeEnv{tablenuma} % \DescribeEnv{tablitem} % These three environments are employed to typeset brief questions (\texttt{tablenum1}), % sub-questions (\texttt{tablenuma}) or \texttt{itemize} lists (\texttt{tablitem}) % on the same line. They share the same syntax: % |\begin{tablenum1}|\oarg{opt}|(|\meta{cols}|)|. % The \meta{cols} parameter denotes the number of columns utilized by the environment. % It must be enclosed \emph{in parentheses}. % This parameter can be omitted, in which case its default value is 2. % Similar to conventional lists, each item is initiated with the |\item| command. % % These three environments are defined using the % |\NewTasksEnvironment| macro from the \textsf{tasks} package by Clemens Niederberger. % They accept an optional argument \meta{opt}, which is % explained in the documentation of this package. % For example, similar to the \texttt{enumitem} package, % |label=\arabic*)| produces an Arabic numbering % followed by a closing parenthesis. % Additionally there are numerous possibilities for arranging items in original ways. % For instance, the |\item*| command allows you to % specify the number of columns the item is supposed to span. % In the subsequent example, % the five |\item| commands are sequentially positioned between % |\begin{tablenum1}(3)| and |\end{tablenum1}|. % It's important to notice that numbering occurs line by line in this context. % % \exercise % \psframe(-0.25,1.3)(12.75,-2.8) % Provide the derivative of the following functions: % \begin{tablenum1}(3) % \item $\ds f(x) = \frac{1-x^2}{\mathrm{e}^x +\mathrm{e}^{-x}}$, % \item $\ds g(x) = \ln \left( \frac{1-x}{1+x^2}\right)$, % \item $\ds h(x) = \int_{0}^{1}\mathrm{e}^{xy}\, \mathrm{d}y$, % \item $\ds k(x) = \sum_{i=1}^{\infty}\frac{1}{x^i}$, % \item $\ds l(x) = \int_{\frac{1}{x}}^{x}\frac{1}{\ln t}\, \mathrm{d}t$. % \end{tablenum1} % % \smallskip % For \texttt{tablenuma}, labels are % letters (a, b, c, \ldots) enclosed in % parentheses. This cannot be globally altered, % except by redefining the environment using |\RenewTasksEnvironment|. % If the \textsf{exesheet} package is invoked with the option \texttt{setlist=false}, % labels within \texttt{tablenum1} and \texttt{tablenuma} environments % will be presented with indentation and in regular font rather than bold. % % \medskip % \DescribeEnv{tablenuma*} \DescribeEnv{tablitem*} % When you intend to utilize \texttt{tablenuma} (or \texttt{tablitem}) % immediately after inserting the |\item| command % within an \texttt{enumerate} environment, % a vertical misplacement occurs, as demonstrated in the following example: % \begin{enumerate} % \item % \begin{tablenuma}(3) \item One \item Two \item Three \end{tablenuma} % \end{enumerate} % % To achieve proper vertical spacing in such cases, we offer % the starred environments \texttt{tablenuma*} and \texttt{tablitem*}, % with corrected alignment as shown below: % % \noindent\psframe(-0.25,0.05)(12.75,-1) % \psline[linewidth=0.1pt,linecolor=green,linestyle=dashed](0, -0.63)(10.5, -0.63) % \begin{enumerate} % \item % \begin{tablenuma*}(3) \item One \item Two \item Three \end{tablenuma*} % \end{enumerate} % % \medskip % If the vertical alignment is still not optimal, include % |\mbox{}\vspace|\marg{height} just before invoking |\begin{tablenuma*}| % (or |\begin{tablitem*}|), where \meta{height} can be a positive or negative length. % % \subsection{Items aligned by column: \texttt{colsenum}, \texttt{colsitem}} % \DescribeEnv{colsenum} % To achieve numbering of items by column, the % \texttt{colsenum} environment is available: % |\begin{colsenum}|\oarg{opt}\marg{cols}. % The mandatory parameter is the number of columns, % and the optional parameter will be passed to the \texttt{enumerate} environment, % allowing you to change the numbering type (\eg a, A, etc.), among other possibilities. % To use this environment, you need to load the % \textsf{multicol} package in the preamble. % Here's an example with |\begin{colsenum}{3}|: % % \exercise % \psframe(-0.25,1.3)(12.75,-2.65) % Provide the derivative of the following functions: % \begin{colsenum}{3} % \item $\ds f(x) = \frac{1-x^2}{\mathrm{e}^x +\mathrm{e}^{-x}}$, % \item $\ds g(x) = \ln \left( \frac{1-x}{1+x^2}\right)$, % \item $\ds h(x) = \int_{0}^{1}\mathrm{e}^{xy}\, \mathrm{d}y$, % \item $\ds k(x) = \sum_{i=1}^{\infty}\frac{1}{x^i}$, % \item $\ds l(x) = \int_{\frac{1}{x}}^{x}\frac{1}{\ln t}\, \mathrm{d}t$. % \end{colsenum} % % \medskip % \DescribeEnv{colsenum*} % We will observe that, on each line, items are not necessarily properly % aligned, which can result in ungraceful effects. % On the other hand the \texttt{colsenum} environment doesn't attempt to align columns % from the bottom by adjusting the spacing between items. % If we desire this alignment % (which is the default behavior in \textsf{multicol}), we can use the % \texttt{colsenum*} environment (with the same syntax as \texttt{colsenum}). % Here's what we obtain with \texttt{colsenum*}, using the same exercise: % % \pagebreak % \exercise % \psframe(-0.25,1.3)(12.75,-2.65) % Provide the derivative of the following functions: % \begin{colsenum*}{3} % \item $\ds f(x) = \frac{1-x^2}{\mathrm{e}^x +\mathrm{e}^{-x}}$, % \item $\ds g(x) = \ln \left( \frac{1-x}{1+x^2}\right)$, % \item $\ds h(x) = \int_{0}^{1}\mathrm{e}^{xy}\, \mathrm{d}y$, % \item $\ds k(x) = \sum_{i=1}^{\infty}\frac{1}{x^i}$, % \item $\ds l(x) = \int_{\frac{1}{x}}^{x}\frac{1}{\ln t}\, \mathrm{d}t$. % \end{colsenum*} % % \medskip % We can observe that these alignments are not as elegant as those % achieved through row numbering. However, column numbering % might still be more suitable when dealing with numerous items of varying heights, % and especially when the number of items can differ from column to column. % Additionally, a benefit of \texttt{colsenum} is that the label selection % is automatic based on the list level (and the language), % unlike \texttt{tablenum1} or \texttt{tablenuma}. % % \bigskip % \DescribeEnv{colsitem} % \DescribeEnv{colsitem*} % For \texttt{itemize} lists, the \texttt{colsitem} environment % generates items aligned by column, unlike the line-by-line alignment of % \texttt{tablitem}. To use it, simply employ % |\begin{colsitem}|\oarg{opt}\marg{cols}. The optional parameter, % passed to the underlying \texttt{itemize} environment, % permits the modification of the item label (bullet by default). % Furthermore, just like \texttt{colsenum*}, the \texttt{colsitem*} environment % produces column alignment from the bottom. % % \section{Questions and solutions} % % \subsection{Environments \texttt{questions} and \texttt{answers}} % \label{output} % % \DescribeEnv{questions} \DescribeEnv{answers} % The package offers two environments, \texttt{questions} and \texttt{answers}, % which allow you to optionally show or hide questions and answers within exercises. % % \bigskip % \DescribeMacro{[output=\meta{opt}]} % The output is governed by the \texttt{output} key option which recognizes three % values: \texttt{questions}, \texttt{answers}, and \texttt{both}. % The \texttt{questions} value shows only questions without answers, % \texttt{answers} displays answers without questions, and % \texttt{both} (the default option) displays both questions and answers. % % \bigskip % \DescribeMacro{\correctionstyle} \DescribeMacro{correctioncolor} % In the default case where both questions and answers are displayed, % the answers are typeset using the |\correctionstyle| style, % which utilizes the color \texttt{correctioncolor}. % You can modify this color using the |\definecolor| macro % \footnote{The \texttt{\bs definecolor} command is provided by the \textsf{xcolor} package % developed by Uwe Kern, which is automatically loaded by \textsf{exesheet}.}. % By default, |\definecolor{correctioncolor}{rgb}{0,0.2,0.6}| is used, % resulting in a kind of dark blue. % % \medskip % \DescribeMacro{\correctionname} % Furthermore, when using \texttt{output=both} % the title \textbf{\correctionname} is displayed at the beginning % of \texttt{answers} environments. % This title is defined by the |\correctionname| macro, % with translation available in several languages, and it can also be modified. % For instance you might prefer ``Solution'' % over ``\correctionname''. % The style defined by |\correctionstyle| will be applied to the title % as well as the entire environment. % Here's an example to illustrate this: % % \pagebreak % ^^A \vspace{-\baselineskip} % \noindent\psframe(-0.25,-0.25)(12.75,-6.9) % \exercise % \begin{questions} % \begin{enumerate} % \item Is the \textsf{exesheet} package useful ? % \item Aren't there any other packages that deal with exercises ? % \end{enumerate} % \end{questions} % \begin{answers} % \begin{enumerate} % \item Yes, the \textsf{exesheet} package is indeed useful for teachers. % \item There are numerous other packages that handle exercises and % provide the capability to create questions and solutions separately. % For instance the % \textsf{exercise} package by Paul Pichaureau, \textsf{exercises} by Roger Jud, % \textsf{exsheets} (now superseded by \textsf{xsim}) by Clemens Niederberger, % \textsf{exframe} by Niklas Beisert, % \textsf{exam} by Philip Hirschhorn, % \textsf{answers} by Mike Piff and Joseph Wright, % \textsf{probsoln} by Nicola Talbot, and more. % \end{enumerate} % \end{answers} % % \medskip % When only answers are displayed, the text color remains black and % the word ``\correctionname'' is not displayed. % % \subsection{About the title ``\correctionname'' in \texttt{answers} environments} % Internally, we have utilized the |\comment| and |\endcomment| macros % from the \textsf{versions} package by Uwe Lück. % Several other outstanding packages also enable selective management of code portions. % Notably, the \textsf{verbatim} package by Rainer Schöpf, % \textsf{comment} by Victor Eijkhout, % \textsf{version} by Donald Arseneau and Stephen Bellantoni, % \textsf{optional} by Donald Arseneau % and \textsf{codesection} by Matthias Pospiech. % % Moreover the \textsf{versions} package includes % the |\includeversion|\marg{env} and % |\excludeversion|\marg{env} macros which allow for the inclusion or exclusion of % any environment \meta{env}. These ``optional'' environments % can be nested % \footnote{The \textsf{codesection} package also supports % such nesting, including within the preamble, as well as % the \textsf{optional} package, but the latter manages only short sections of optional code.}. % % However the \texttt{questions} and \texttt{answers} environments % serve a broader purpose beyond merely displaying or hiding text. % For instance, you can choose to have a single answers environment % for the entire sheet, or alternatively, have separate answers environments % for each exercise, exercise part, question, or sub-question. % The format in which the title \textbf{\correctionname} should appear % in the output, and its placement in the table of contents % or PDF file summary, depends on the nesting level of the environment. % In fact, the rendering of the \textbf{\correctionname} title and its corresponding % table of contents level will be automatically calculated by the environment. % % \medskip % \DescribeEnv{answers\oarg{level}} % However, there are perhaps twisted situations in which % the title level may not always be accurate. % Furthermore, users might wish to adjust the title's level themselves. % To achieve this, you can manually set the level of the title ``\correctionname'' % using |\begin{answers}|\oarg{level}. % The optional \meta{level} parameter is defined as follows: % 1 for section-level titles, % 2 for subsections (akin \textbf{\exercisename}), % 3 for sub-subsections (similar to \textbf{\partname}), % other numbers for lower levels % (which won't appear in the table of contents or in the PDF file’s summary). % % \smallskip % \DescribeMacro{answers*} % The starred version \texttt{answers*}, completely hides the % \textbf{\correctionname} title. % % \subsection{Commands \texttt{\bs question}, \texttt{\bs answer} and \texttt{\bs answerspace}} % \label{answerspace} % \DescribeMacro{\question}\DescribeMacro{\answer} % Instead of using \texttt{questions} and \texttt{answers} environments, % we can also employ the simpler |\question|\marg{ques} and |\answer|\marg{ans} macros. % The visibility of \meta{ques} and \meta{ans} content is % regulated by the same previous \texttt{output=\meta{opt}} key option. % This approach might be more fitting for brief questions and answers, such as when % you wish to display the answer immediately after each question item. % The title ``\correctionname'' won't appear at the start % of each answer with the |\answer| macro. % The answers are formatted using |\correctionstyle| % if \texttt{output=both}. % However these commands do not support \texttt{verbatim} text within them, % unlike the \texttt{questions} and \texttt{answers} environments which do. % % \bigskip % \DescribeMacro{\answerspace} % Some teachers are accustomed to providing their students with documents % where questions are typeset, leaving blank spaces instead of answers. % This layout allows students to fill in their responses on the paper. % To achieve this, thanks to a suggestion from Maxime Chupin, % we offer the |\answerspace|\marg{height} macro, % in which the parameter \meta{height} is a valid length, % \eg |\answerspace{3cm}|. % % \medskip % \DescribeMacro{[answerspace=\meta{bool}]} % The blank spaces introduced by |\answerspace| can be displayed % or hidden, controlled by the % \texttt{answerspace} option key, which can be set to either % \texttt{true} or \texttt{false} (the default). % Of course the |\answerspace| macro is not meant to be used within \texttt{answers} % environments. % % \section{Marginal notes for marking scheme} % % The \textsf{exesheet} package enables the display of a detailed marking % scheme in the margins, along with comments and explanations about answers. % % \subsection{The \texttt{\bs points} command}\label{points} % \DescribeMacro{\points} % The |\points|\marg{pts} command displays the number of points awarded for an exercise. % It is intended to be included in the optional argument of the % |\exercise| command % \footnote{However using this command in the optional argument of % \texttt{\bs exercise} is not compatible with % the \textsf{memoir} class, as the \textsf{memoir} class redefines section commands.}. % In the following example, we used % |\exercise[\points{5}]|: % \exercise[\points{5}] % \psframe(-0.25,1.3)(12.75,-0.4) % Try to read this document to the end without drinking tea and you get five points. % % \bigskip % When only the correction is displayed in an exercise, the |\points| macro doesn't % show the points. % A more comprehensive solution for printing answers along with the point scale % will be presented % in section \ref{totalpoints}, which includes another |\totalpoints| macro. % % \bigskip % \DescribeMacro{\pointsname} \DescribeMacro{\pointname} % The term ``\pointsname'' (or ``\pointname'' in the singular % if \meta{pts} is less than 2), is appended and % is automatically translated into several languages % (and can also be modified). % % \smallskip % \DescribeMacro{\pointsstyle} \DescribeMacro{pointscolor} % You can adjust the |\points| command's style through |\pointsstyle|. % The color setting (red by default) is managed by |pointscolor| using |\definecolor|, % for example you can declare: |\definecolor{pointscolor}{named}{blue}|. % % \subsection{The \texttt{\bs pts} command} \label{pts} % \DescribeMacro{\pts} % When exercises are typeset using the |\exe| macro % or as a list with the \texttt{exenumerate} environment, % the marking scheme can be shown in the margin, aligned with the line where % the |\pts|\marg{num} command is placed (typically the first line of the exercise). % The \meta{num} parameter represents the number of points assigned to the exercise. % Here's an example with |\exe\pts{3}... \exe\pts{1.5}...| % % \vspace{-\baselineskip} % \noindent\psframe(-3.0,-0.25)(12.75,-1.95) % \exe \pts{3} The first short exercise with a marking scheme. % \exe \pts{1.5} The second one. % % \bigskip % \DescribeMacro{\ptsname} \DescribeMacro{\ptname} % \DescribeMacro{ptscolor} \DescribeMacro{\ptsstyle} % The abbreviation ``\ptsname'' (or ``\ptname'' % when the number of points is less than 2) % is added automatically using |\ptsname| or |\ptname| macros % (translated in several languages % if \textsf{babel} or \textsf{polyglossia} is loaded). % The point's display color is defined by \texttt{ptscolor}, changeable via % |\definecolor| (red by default). % The display style is determined by |\ptsstyle|, which among other things, % adds parenthesis around. % % \bigskip % \DescribeMacro{[display=\meta{opt}]} % The marking scheme visibility is controlled by the % \texttt{display} option key. % The default option is |display=none|, keeping the marking scheme hidden. % To reveal the marking scheme, use |display=pts|. % More details are available in section \ref{margin}. % % \medskip % \DescribeMacro{[marginpos=\meta{opt}]} % The positioning of the scale is determined by the |marginpos| option key, % typically \texttt{left} or \texttt{right}. % The default value is \texttt{left} % even though \LaTeX{} positions marginal notes on the right side by default. % This option has no impact when |display=none|. % % For a two-sided document, the default behavior is to place text in the outer margin, % which is wider than the inner margin (that contains the binding). % The outer margin aligns with the right side on odd pages and with the left side % on even pages. Therefore, the \texttt{marginpos} option can also take the % values \texttt{inner} or \texttt{outer}. % If you specify \texttt{left} or \texttt{right} when the \texttt{twoside} mode is activated, % this value will be converted to \texttt{outer}, accompanied by a warning message. % % \medskip % With the \texttt{twoside} mode, marginal notes might occasionally % appear on the wrong side of a page. % This is a known \LaTeX{} bug, and the solution involves using % the \textsf{mparhack} package (which \textsf{exesheet} automatically includes % for documents in two-side mode) and \emph{running \LaTeX{} twice}. % If necessary, a warning message will prompt you to perform the re-run. % % \subsection{Commands \texttt{\bs totalexe}, \texttt{\bs note*} and \texttt{\bs note}} % % \label{note} % For a more comprehensive marking scheme, the following commands are available. % % \medskip % \DescribeMacro{\totalexe} % The |\totalexe|\marg{num} macro displays the total number of points of an exercise. % By default, it appears inside an oval box, with the addition of the word % ``\ptsname'' (or ``\ptname'') in bold red. % In the following example, the exercise title has been generated % using |\exercise[\totalexe{4}]|. % % \medskip % \DescribeMacro{\note*} % For each answer or solution in the correct version, the % |\note*|\marg{num} command indicates the number of points allocated to that question. % The appearance slightly varies compared to |\pts|: % by default the number is displayed in bold without the ``\ptsname'' or ``\ptname'' suffix, % and without parenthesis. % In the following example, for answer 3, % we employed |\note*{1.5}|, placed right after |\item|. % % \medskip % \DescribeMacro{\note} % The |\note|\marg{comment} macro is utilized to provide additional information % regarding the marking scheme and to explain how points are assigned. % In the \meta{comment} argument you can use |\\| to create a line break % or even |\\[|\meta{height}|]| to adjust the line spacing by \meta{height}. % % \DescribeMacro{\note\oarg{num}} % Placing |\note*|\marg{num}|\note|\marg{comment} % at the beginning of an answer is often practical. % In such cases \LaTeX{} will align the margin % notes vertically, which leads to a warning like: % \texttt{LaTeX Warning: Marginpar on page \ldots\@ moved.} % However, this warning is not an issue, as \LaTeX{} can usually handle the arrangement % of these marginal notes, stacking them one below the other. % Nonetheless, to prevent unnecessary warnings, you can combine both commands into a % single one by specifying the number of points as an optional argument of the |\note| command: % |\note|\oarg{num}\marg{comment}. % % The initial comment in the following example is generated (immediately after |\item|) using % |\note[1]{0.5 for the anti-derivative\\0.5 for simplifying}|. % % \exercise[\totalexe{4}] \label{totalexe} % \begin{questions} % \psframe(-3.5,1.3)(12.75,-14) % For each subsequent question, determine whether the statement is true or false. % Provide a thorough justification for your answer. % \begin{tablenum1} % \item $\ds \int_{0}^{\sqrt{3}}\frac{1}{x+\sqrt{3}} \,\mathrm{d}x = \ln 2$, % \item $\ds \int_{2}^{\mathrm{e}} \frac{1}{x\ln x} \,\mathrm{d}x = -\ln 2$, % \item* The function $F$, defined on $\mathbf{R}$ by % $F(x) = \ds \int_{0}^{x}\frac{1}{t^2+t+1}\,\mathrm{d} t$, is increasing on $\mathbf{R}$. % \end{tablenum1} % \end{questions} % % \begin{answers} % \begin{enumerate} % \item \note[1]{0.5 for the anti-derivative\\0.5 for simplifying} % We calculate: % \[ \int_{0}^{\sqrt{3}}\frac{1}{x+\sqrt{3}}\,\mathrm{d}x % = \bigg[ \ln\left(x+\sqrt{3}\right) \bigg]_0^{\sqrt{3}} % = \ln\left(2\sqrt{3}\right)-\ln \sqrt{3} % = \ln\left(\frac{2 \sqrt{3}}{\sqrt{3}}\right) % =\ln 2. % \] % \textbf{TRUE}. % % \item \note[1.5]{1 for the anti-derivative \\0.5 for the final value \\[2ex] % Other method: $\frac{1}{x \ln x} >0$ on $[2, \mathrm{e}]$ % whereas $-\ln2<0$ % } % We have $\ds\frac{1}{x \ln x}= \frac{\frac{1}{x}}{\ln x}= \frac{u'(x)}{u(x)}$ % with $u(x)=\ln x$, which is positive on $[2, \mathrm{e}]$. Hence % % \[ \int_{2}^{\mathrm{e}}\frac{1}{x \ln x}\,\mathrm{d}x % = \Big[ \ln(\ln x) \Big]_2^\mathrm{e} % = \ln(\ln \mathrm{e})-\ln(\ln2)= \ln1 -\ln(\ln2)=-\ln(\ln2). % \] % \textbf{FALSE}. % % \item \note*{1.5} % The function $F$, defined on $\mathbf{R}$ by % \[ F(x)= \int_{0}^{x}\frac{1}{t^2+t+1}\, \mathrm{d}t, \] % is derivable on $\mathbf{R}$ and its derivative is such that % $F'(x)=\frac{1}{x^2+x+1}$. % \note{0.5 for $F'$\\1 for the sign of $F'$ and conclusion} % The denominator is a quadratic polynomial, always positive because its discriminant is % $\Delta=-3 <0$. % Thus $F$ is increasing on $\mathbf{R}$. \\ % \textbf{TRUE}. % \end{enumerate} % \end{answers} % In the comment for answer 2, a larger vertical space is created with % the optional argument |\\[2ex]| for line break. % The last comment, which isn't positioned next to the points number, % was produced by placing the following on the first line after the formula: % |\note{0.5 for $F'$\\1 for the sign of $F'$ and conclusion}|. % % \medskip % \DescribeMacro{markingcolor} \DescribeMacro{\markingstyle} \DescribeMacro{\ptsboxlength} % The color and style for displaying points in |\totalexe| and |\note*| % can be customized using \texttt{markingcolor} and |\markingstyle|, respectively. % The oval box produced by |\totalexe| is created using the |\ovalbox| command % from the \textsf{fancybox} package (by Timothy Van Zandt), % with corner arcs set by |\cornersize{1}|. % The box's length is determined by % |\ptsboxlength|, and not by the box's content, to ensure uniformity across exercises. % % \medskip % \DescribeMacro{notecolor} \DescribeMacro{\notestyle} % By default, comment notes are typeset in a dark green color % defined by |\definecolor{notecolor}{rgb}{0.0,0.4,0.0}|. % The style of the comment is determined by the |\notestyle| macro. % % \subsection{Margin notes options} \label{margin} % % \DescribeMacro{[display=\meta{opt}]} % The \texttt{display} key option governs the presentation of the marking scheme: % as discussed previously (subsection \ref{pts}), % \texttt{display=none} shows nothing. When using \texttt{display=pts} % the numbers provided as arguments to |\pts|, |\totalexe|, |\note*| % or as optional arguments of |\note|\oarg{num}\texttt{\{...\}} will be exhibited. % The final option is \texttt{display=notes} which reveals the complete marginal % notes, containing points and comments (the mandatory argument of |\note|), % as illustrated in the previous example. % % \medskip % \DescribeMacro{[marginpos=\meta{opt}]} % As previously mentioned in subsection \ref{pts}, the side on which % to position the scale is determined by the \texttt{marginpos} key option, % with possible values of \texttt{left} and \texttt{right} % (or \texttt{inner} and \texttt{outer} if the document is in \texttt{twoside} mode). % % \medskip % \DescribeMacro{[marginwidth=\meta{opt}]} % The margin layout is governed by the \texttt{marginwidth} key option, % which can take one of the following values: % \texttt{standard}, \texttt{expand}, or \texttt{unset}. % % This option has no effect when \texttt{display=none}. % In this case, both the left and right margins have the same width, % except in a two-sided document where the ratio between the left and right % margins is 2:3. % Otherwise the \texttt{marginwidth} key option behaves as follows: % \begin{description} % \item[\texttt{standard}] % The left margin is widened, and the % right margin is reduced, with a ratio of 3:2 (or 2:3 if \texttt{marginpos=right}). % The text body is shifted without changing its width. % The margin paragraph width remains relatively short % (depends on page geometry). % This option is not ideal for lengthy comments. % % \item[\texttt{expand}] (default value)\enskip % The behavior is the same as with the % \texttt{standard} value when \texttt{display=pts}. However, when \texttt{display=notes}, % the margin expands with a ratio of 3:1 (or 1:3) and the width of margin paragraphs % increases. % % \item[\texttt{unset}] This option is provided for cases where the previous settings % are not suitable. % In this case, no adjustments are made to the margin width. Instead, you can define % your own settings using the convenient |\geometry| macro % from the \textsf{geometry} package (by Hideo Umeki). % For instance, you can place the following in the preamble: % \centeredline{|\geometry{hmarginratio=2:1,marginparwidth=2.5cm}|.} % % If \texttt{marginpos=right}, you need to invert the ratio, \eg 1:2 instead of 2:1. % If \texttt{marginwidth} is not set to \texttt{unset}, % such a command will have no effect. % \end{description} % Margin settings are applicable to the entire document % and need to be configured in the preamble. % % \medskip % \DescribeMacro{[noteragged=\meta{opt}]} % The package option \texttt{noteragged} controls the text alignment within the margins % for the mandatory argument of |\note|. % It offers the following values: % \texttt{left}, \texttt{right}, \texttt{center}, \texttt{justify} or \texttt{twoside}. % The default value is \texttt{noteragged=left}, resulting in right-aligned text, % which is common for text in the left margin. % When \texttt{noteragged=right}, the text is left-aligned text. % Using \texttt{justify} makes the text justified, aligning with % \LaTeX's default behavior for marginal notes. % Finally \texttt{noteragged=twoside} aligns text to the left on odd pages % and to the right on even pages in a two-sided document. % It has no effect otherwise (the default \texttt{noteragged=left} is used % and a warning message appears in the terminal). % % When \texttt{display} is not set to \texttt{notes}, the \texttt{noteragged} option % has no impact, as it specifically applies to text within the mandatory argument of |\note|. % % \subsection{The \texttt{\bs totalpoints} command} \label{totalpoints} % % \DescribeMacro{\totalpoints} % The |\totalpoints|\marg{num} macro serves as a replacement for % |\points| when using a comprehensive marking scheme. % When the scale isn't visible, % it functions similarly to |\points|, and when the scale is shown, % it's akin to |\totalexe|. % For instance, in the exercise \ref{totalexe}, it's preferable to use % |\totalpoints| instead of |\totalexe|, % as when the detailed marking scheme isn't displayed, the total points will be typeset % in a manner similar to exercise \ref{points} rather than in the margin. % % \subsection{Marking scheme consistency checking}\label{scale} % % \DescribeMacro{[checkpts=\meta{bool}]} % The marking scheme can be checked % \footnote{Thanks to Denis Bitouzé for his suggestion about this feature.} % using the key-val option \texttt{checkpts=true}; % the default value is \texttt{false}. % % \medskip % For each exercise, the cumulative points allocated to each question (via |\pts|, |\note*| % or |\note[ ]| are compared to the exercise's total specified in % |\points|, |\totalexe| or |\totalpoints|. % A warning message will be displayed in the shell to indicate whether % the scale is valid % for the exercise or not. For example: % \begin{center} % \texttt{Package exesheet warning: Exercise 3: Sum of points is 4.5pt instead of 5pt.} % \end{center} % Both comma notation (\eg 4,5) and decimal point format (\eg 4.5) % may be accepted, depending on your chosen language. % The validation occurs at the beginning of the subsequent exercise. % No warning messages will be presented at this level if no points are specified % for the questions. % % \medskip % \DescribeMacro{\totalsheet} % At the end of the sheet, the last exercise is checked, % followed by a global examination of the entire sheet. % This last task requires knowledge of the total points for the sheet. To achieve this, use % the |\totalsheet|\marg{total} macro in the preamble; % otherwise, a warning message will be displayed. % If subtotals have been assigned to exercises, the overall comparison % is made between the sum of these subtotals and the total points recorded % using the |\totalsheet| macro. % If not, the evaluation encompasses the sum of points for each individual question. % A subsequent warning message indicates the outcome of this last verification. % Finally, a message indicates whether all scale controls have been successfully % passed or not. % % \section{Options} \label{options} % % \subsection{Summary of available options} % % Here we provide a summary table of the available options. Details on their usage % can be found in the respective sections. % The default value is displayed in bold. % % \begin{center} \ttfamily % \setlength{\extrarowheight}{1pt} % \begin{tabular}{llc} % \hline % \textsf{Key} & \textsf{Possible values} & \textsf{See section} \\ % \hline % exetoc & \textbf{true}, false & \ref{toc} \\ % setlist & \textbf{true}, false & \ref{setlist} \\ % output & questions, answers, \textbf{both} & \ref{output} \\ % answerspace & true, \textbf{false} & \ref{answerspace}\\ % display & \textbf{none}, pts, notes & \ref{pts}, \ref{margin} \\ % marginpos & \textbf{left} (inner), right (\textbf{outer}) & \ref{pts}, \ref{margin} \\ % marginwidth & standard, \textbf{expand}, unset & \ref{margin} \\ % noteragged & \textbf{left}, right, center, justify, twoside & \ref{margin} \\ % checkpts & true, \textbf{false} & \ref{scale} \\ % correct & true, \textbf{false}, conditional & \hyperlink{correct}{see below} \\ % \hline % \end{tabular} % \end{center} % % When an invalid key is provided, an error is generated. However, % if a value is not recognized, a warning message will appear:\\ % \texttt{Value `\meta{value}'\ is not supported by `\meta{key}' option % on input line \ldots} \\ % For each option, you can set them through the class or package invocation, \eg % |\usepackage[output=answers,display=notes,noteragged=right]{exesheet}| % % \bigskip % \DescribeMacro{\exesheetset} % You can also use the |\exesheetset|\{list of \meta{key}=\meta{value}\} % command. % Note that some options, \texttt{output}, \texttt{answerspace}, \texttt{display}, % and \texttt{noteragged}, % can be changed dynamically, even within the document, % while the others are applicable in the preamble exclusively. % Dynamic options are processed with each call, whereas the others are processed once, % when the document begins. % \hypertarget{correct}{} % % \bigskip % \DescribeMacro{[correct=\meta{opt}]} % A special option, \texttt{correct}, can be employed when using the \textsf{exesheet} % \emph{class} or in conjunction with the \textsf{schooldocs} package. % This option adds ``\correctname'' (or its translation) % to the document title and headers. % Possible values are: \texttt{true}, \texttt{false} (default) or \texttt{conditional}. % When set to \texttt{correct=conditional}, it behaves as \texttt{true} % when answers are displayed and \texttt{false} when they're not. % % \subsection{Alternative (deprecated) commands} % % Prior to version 2.0, we used specialized commands to configure % output and display options. % Thanks to a suggestion from Maxime Chupin, we have now implemented \emph{key=value} % options in the package. % Although the latter is more user-friendly, % the older commands are still supported for compatibility reasons and are outlined here. % While these commands will trigger a warning message, they remain functional. % However, the previous options \texttt{nosetlist} and \texttt{notoc} % are no longer supported. % % \bigskip % \DescribeMacro{\questionsonly} \DescribeMacro{\answersonly} % The command |\questionslonly| is equivalent to setting \texttt{output=questions} % and |\answersonly| means \texttt{output=answers}. % % \medskip % \DescribeMacro{\displaypts} \DescribeMacro{\displaypoints} % \DescribeMacro{\displaynotes}\DescribeMacro{\displaynotesright} % The commands |\displaypts| and |\displaypoints| % are equivalent to setting \texttt{display=pts}; % |\displaynotes| means \texttt{display=notes}, % and |\displaynotesright| corresponds to % \texttt{display=notes} and \texttt{marginpos=right}. % % \StopEventually{} % % \section{Implementation} % % \subsection{Options and required packages} % The \texttt{exesheet} class is build upon the \texttt{article} class % and transfers all its unknown options to it. The use of % |\ProcessKeyvalOptions*| is unnecessary within the class % as it will be managed by the package. % \begin{macrocode} %<*class> \RequirePackage{kvoptions} \DeclareBoolOption[true]{exetoc} \DeclareBoolOption[true]{setlist} \DeclareStringOption[both]{output} \DeclareStringOption[none]{display} \DeclareBoolOption[false]{answerspace} \DeclareStringOption[left]{marginpos} \DeclareStringOption[expand]{marginwidth} \DeclareStringOption[left]{noteragged} \DeclareBoolOption[false]{checkpts} \DeclareStringOption[false]{correct} \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} \ProcessOptions \relax \LoadClass{article} \RequirePackage{exesheet} \RequirePackage{schooldocs} % % \end{macrocode} % % Options are established using the \textsf{kvoptions} package (build on \textsf{keyval}). % String options are managed through distinct macros % that are defined in their respective sections. % For options whose effects cannot be dynamically altered % and must be configured in the preamble, they are processed once % upon the start of the document. % The other options are executed upon package loading % (at the end of the package, as |\exs@process...| % commands are not recognized at the outset). % % A distinct case emerges with \texttt{setlist} when utilized in conjunction with % \textsf{babel-french}. % In this instance, it is processed immediately and subsequently disabled % (further clarification follows below). % % \begin{macrocode} %<*package> \@ifclassloaded{exesheet}{}{ \RequirePackage{kvoptions} \DeclareBoolOption[true]{exetoc} \DeclareBoolOption[true]{setlist} \DeclareStringOption[both]{output} \DeclareStringOption[none]{display} \DeclareBoolOption[false]{answerspace} \DeclareStringOption[left]{marginpos} \DeclareStringOption[expand]{marginwidth} \DeclareStringOption[left]{noteragged} \DeclareBoolOption[false]{checkpts} \DeclareStringOption[false]{correct} } \ProcessKeyvalOptions* \def\exs@process@dynoptions{ \exs@process@output \exs@process@display \exs@process@noteragged } \AtEndOfPackage{\exs@process@dynoptions} \AtBeginDocument{ \newif\ifexesheet@multicol \@ifpackageloaded{multicol}{ \exesheet@multicoltrue}{\exesheet@multicolfalse} % configuring the rule color within answers environments \exs@process@setlist \exs@process@marginpos \exs@process@marginwidth \exs@process@checkpts \exs@process@correct \DisableKeyvalOption[action=warning,package=exesheet]{exesheet}{setlist} \DisableKeyvalOption[action=warning,package=exesheet]{exesheet}{marginpos} \DisableKeyvalOption[action=warning,package=exesheet]{exesheet}{marginwidth} \DisableKeyvalOption[action=warning,package=exesheet]{exesheet}{checkpts} \DisableKeyvalOption[action=warning,package=exesheet]{exesheet}{correct} } % \end{macrocode} % \begin{macro}{\exesheetset} % The |\exesheetset| macro can accept key-val options and % can be utilized anywhere in the document to adjust certain settings. % However, it won't affect non dynamic options if called outside the preamble. % In such cases a warning message occur due to the use of |\DisableKeyValOption|. % \begin{macrocode} \def\exesheetset#1{\setkeys{exesheet}{#1}\exs@process@dynoptions} % \end{macrocode} % \end{macro} % Now, we load several packages. % If the \textsf{geometry} package is already loaded, it will not be reloaded % to prevent an option clash. % The \texttt{shortlabel} option in the \textsf{enumitem} package allows the use % of labels similar to % the \textsf{enumerate} package such as 1., a), A., and so on. % The \textsf{mparhack} package (by Tom Sgouros and Stefan Ulrich) % is loaded exclusively for documents in \texttt{twoside} mode. % \begin{macrocode} \RequirePackage{ifthen} \@ifpackageloaded{geometry}{}{\RequirePackage{geometry}} \RequirePackage{xcolor} \RequirePackage[shortlabels]{enumitem} \RequirePackage{tasks} \RequirePackage{versions} \RequirePackage{fancybox} \RequirePackage{translations} \RequirePackage{ragged2e} \ifthenelse{\boolean{@twoside}}{\RequirePackage{mparhack}}{} % \end{macrocode} % % \subsection{Internationalization} % Here we define keywords along with their translations in French, German, Spanish % Italian, Portuguese. We achieve this using macros from the \textsf{translations} package % by Clemens Niederberger. This package automatically detects the language being used, % as loaded by \textsf{babel} or \textsf{polyglossia}. % % Accented characters cannot be utilized here, as they might not be recognized % if \textsf{inputenc} is loaded after \textsf{exesheet}. % As a workaround, we rely on basic \LaTeX{} control sequences to generate them. % % \begin{macrocode} \DeclareTranslationFallback{exesheet-exercise}{Exercise} \DeclareTranslationFallback{exesheet-subpart}{Part} \DeclareTranslationFallback{exesheet-annex}{Annex} \DeclareTranslationFallback{exesheet-ex}{Ex} \DeclareTranslationFallback{exesheet-points}{points} \DeclareTranslationFallback{exesheet-point}{point} \DeclareTranslationFallback{exesheet-correction}{Correction} \DeclareTranslationFallback{exesheet-pts}{pts} \DeclareTranslationFallback{exesheet-pt}{pt} \DeclareTranslation{English}{exesheet-exercise}{Exercise} \DeclareTranslation{English}{exesheet-subpart}{Part} \DeclareTranslation{English}{exesheet-annex}{Annex} \DeclareTranslation{English}{exesheet-ex}{Ex} \DeclareTranslation{English}{exesheet-points}{points} \DeclareTranslation{English}{exesheet-point}{point} \DeclareTranslation{English}{exesheet-correction}{Correction} \DeclareTranslation{English}{exesheet-pts}{pts} \DeclareTranslation{English}{exesheet-pt}{pt} \DeclareTranslation{French}{exesheet-exercise}{Exercice} \DeclareTranslation{French}{exesheet-subpart}{Partie} \DeclareTranslation{French}{exesheet-annex}{Annexe} \DeclareTranslation{French}{exesheet-ex}{Ex} \DeclareTranslation{French}{exesheet-points}{points} \DeclareTranslation{French}{exesheet-point}{point} \DeclareTranslation{French}{exesheet-correction}{Correction} \DeclareTranslation{French}{exesheet-pts}{pts} \DeclareTranslation{French}{exesheet-pt}{pt} \DeclareTranslation{German}{exesheet-exercise}{\"Ubung} \DeclareTranslation{German}{exesheet-subpart}{Teil} \DeclareTranslation{German}{exesheet-annex}{Anhang} \DeclareTranslation{German}{exesheet-ex}{\"Ub} \DeclareTranslation{German}{exesheet-points}{Punkte} \DeclareTranslation{German}{exesheet-point}{Punkt} \DeclareTranslation{German}{exesheet-correction}{Verbesserung} \DeclareTranslation{German}{exesheet-pts}{P.} \DeclareTranslation{German}{exesheet-pt}{P.} \DeclareTranslation{Spanish}{exesheet-exercise}{Ejercicio} \DeclareTranslation{Spanish}{exesheet-subpart}{Parte} \DeclareTranslation{Spanish}{exesheet-annex}{Anexo} \DeclareTranslation{Spanish}{exesheet-ex}{Ej} \DeclareTranslation{Spanish}{exesheet-points}{puntos} \DeclareTranslation{Spanish}{exesheet-point}{punto} \DeclareTranslation{Spanish}{exesheet-correction}{Correcci\'on} \DeclareTranslation{Spanish}{exesheet-pts}{ptos} \DeclareTranslation{Spanish}{exesheet-pt}{pto} \DeclareTranslation{Italian}{exesheet-exercise}{Esercizio} \DeclareTranslation{Italian}{exesheet-subpart}{Parte} \DeclareTranslation{Italian}{exesheet-annex}{Annesso} \DeclareTranslation{Italian}{exesheet-ex}{Es} \DeclareTranslation{Italian}{exesheet-points}{punti} \DeclareTranslation{Italian}{exesheet-point}{punto} \DeclareTranslation{Italian}{exesheet-correction}{Correzione} \DeclareTranslation{Italian}{exesheet-pts}{pti} \DeclareTranslation{Italian}{exesheet-pt}{pt} \DeclareTranslation{Portuges}{exesheet-exercise}{Exerc\'icio} \DeclareTranslation{Portuges}{exesheet-subpart}{Parte} \DeclareTranslation{Portuges}{exesheet-annex}{Anexo} \DeclareTranslation{Portuges}{exesheet-ex}{Ex} \DeclareTranslation{Portuges}{exesheet-points}{pontos} \DeclareTranslation{Portuges}{exesheet-point}{ponto} \DeclareTranslation{Portuges}{exesheet-correction}{Corre\c c\~ao} \DeclareTranslation{Portuges}{exesheet-pts}{pts} \DeclareTranslation{Portuges}{exesheet-pt}{pt} \newcommand*\exercisename{\GetTranslation{exesheet-exercise}} \newcommand*\subpartname{\GetTranslation{exesheet-subpart}} \newcommand*\annexname{\GetTranslation{exesheet-annex}} \newcommand*\exname{\GetTranslation{exesheet-ex}} \newcommand*\pointsname{\GetTranslation{exesheet-points}} \newcommand*\pointname{\GetTranslation{exesheet-point}} \newcommand*\correctionname{\GetTranslation{exesheet-correction}} \newcommand*\ptsname{\GetTranslation{exesheet-pts}} \newcommand*\ptname{\GetTranslation{exesheet-pt}} % \end{macrocode} % % \subsection{Titles} % % The \texttt{exercise} counter assigns numbers to exercises throughout the entire document, % regardless of sections. % To reset the counter manually, simply use |\setcounter{exercise}{0}|. % For an automatic reset at each new section, % include the following code in the preamble \\ % |\makeatletter \@addtoreset{exercise}{section} \makeatother|. % % The parts counter depends on the \texttt{exercise} counter and is reset % with each new exercise. % % The commands |\labelexercisestyle| and |\labelsubpartstyle| % are initially empty, but they allow you to customize the styling. For example:\\ % |\renewcommand\labelexercisestyle{\sffamily}|. % % The |\exe@check| macro, responsible for verifying the marking scheme, will be defined % in section \ref{MSoptions}. % % By default, the table of contents includes both exercises and parts titles, % as controlled by the boolean |\ifexesheet@exetoc|. % To only display exercise titles in the table of contents while omitting parts, % include the following code in the preamble: |\setcounter{tocdepth}{2}|. % % \begin{macro}{\exercise} % \begin{macrocode} \newcounter{exercise} \newcommand{\labelexercise}{\exercisename\space \theexercise} \newcommand{\labelexercisestyle}{} \newcommand*{\@exercise}[1][]{% \ifexesheet@checkpts \exe@check{\labelexercise} \fi % curiously, the \execheck must be performed before \refstepcounter ! \refstepcounter{exercise} \subsection*{\labelexercisestyle\labelexercise\enskip #1} \ifexesheet@exetoc \addcontentsline{toc}{subsection}{\labelexercise} \fi } \newcommand*{\@@exercise}[2][]{% \ifexesheet@checkpts \exe@check{#2} \fi \subsection*{\labelexercisestyle #2\enskip #1} \setcounter{subpart}{0} % resets the parts counter \ifexesheet@exetoc \addcontentsline{toc}{subsection}{#2} \fi } \newcommand{\exercise}{\@ifstar{\@@exercise}{\@exercise}} % \end{macrocode} % \end{macro} % \begin{macro}{\subpart} % \begin{macrocode} \newcounter{subpart}[exercise] % \renewcommand{\thesubpart}{\Alph{subpart}} \newcommand{\labelsubpart}{\subpartname~\thesubpart} \newcommand{\labelsubpartstyle}{} \newcommand*{\@subpart}[1][]{% \refstepcounter{subpart}% \subsubsection*{\labelsubpartstyle\labelsubpart\enskip #1} \ifexesheet@exetoc \addcontentsline{toc}{subsubsection}{\labelsubpart} \fi } \newcommand*{\@@subpart}[2][]{% \subsubsection*{\labelsubpartstyle #2\enskip #1} \ifexesheet@exetoc \addcontentsline{toc}{subsubsection}{#2} \fi } \newcommand{\subpart}{\@ifstar{\@@subpart}{\@subpart}} % \end{macrocode} % \end{macro} % \begin{macro}{\annex} % \begin{macrocode} \newcommand{\annexstyle}{\MakeUppercase} \newcommand*{\annex}[1][]{% \subsection*{\mbox{}\hfill\annexstyle{\annexname} #1\hfill\mbox{}} \ifexesheet@exetoc \addcontentsline{toc}{subsection}{\annexname} \fi } % \end{macrocode} % \end{macro} % \begin{macro}{\exe} % \begin{macrocode} \newcommand{\exlabel}{\exname.~\theexercise} \newcommand{\exsepmark}{---} \newcommand{\@exe}{\bigskip\refstepcounter{exercise} \par\noindent\textbf{\exlabel~\exsepmark}~} \newcommand{\@@exe}{\bigskip\refstepcounter{exercise} \par\noindent\textbf{\exlabel}~} \newcommand{\exe}{\@ifstar{\@@exe}{\@exe}} % \end{macrocode} % \end{macro} % % \subsection{Enumerations and lists} % % \begin{macro}{\exenumerate} % The |\setlist| command is part of the \textsf{enumitem} package % (|\setenumerate| is deprecated). By default, |itemsep=1ex| is set for first-level lists, % and |leftmargin=1.5em| is used to align labels with the start of lines. % \begin{macrocode} \newenvironment{exenumerate}[1][]{% \setlist[enumerate]{font=\bfseries} \setlist[enumerate,1]{leftmargin=1.5em, itemsep=3ex plus 1ex minus 1ex,topsep=3ex plus 1ex minus 1ex} \setlist[enumerate,3]{noitemsep,nolistsep} \setlist[itemize]{noitemsep,nolistsep} \begin{enumerate}[#1] }{\end{enumerate}} % \end{macrocode} % \end{macro} % When using the \textsf{babel} package with the \texttt{french} option, % \texttt{itemize} lists are altered to use the same dash label for each list level. % These modifications are undone here to revert to the default % \LaTeX\ \texttt{itemize} lists, including labels and spaces. % We have created the |\standardfrenchlists| command, which should be invoked within the % |AtBeginDocument| command, depending on whether % \textsf{exesheet} is loaded before or after \textsf{babel}. % \begin{macrocode} \newcommand\standardfrenchlists{% \@ifpackagewith{babel}{french}{ \frenchsetup{StandardLists=true} }{} } \ifexesheet@setlist \standardfrenchlists % necessary when exesheet is loaded after babel \DisableKeyvalOption[action=warning,package=exesheet]{exesheet}{setlist} \fi \def\exs@process@setlist{% must be executed at begin document \ifexesheet@setlist \standardfrenchlists % if exesheet is loaded before babel \setlist[enumerate]{font=\bfseries} \setlist[enumerate,1]{topsep=1.5ex plus 1ex minus 1ex,leftmargin=1.5em} \fi % \end{macrocode} % \DescribeEnv{tablenum1} \DescribeEnv{tablenuma} % The |\NewTasks| command is part of the \textsf{tasks} package. % It enables the definition of the environments \texttt{tablenum1}, % \texttt{tablenuma} and \texttt{tablitem}. % Horizontal spacing is adjusted to ensure proper alignment with % items in other \texttt{enumerate} (or \texttt{itemize}) environments. % \begin{macrocode} \ifexesheet@setlist \NewTasksEnvironment[label=\arabic*.,label-format=\bfseries, column-sep=1em,label-align=right, item-indent=1.5em,label-width=1em,label-offset=0.5em, after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablenum1}[\item](2) \NewTasksEnvironment[label=(\alph*),label-format=\bfseries, column-sep=1em,label-align=right, item-indent=2.15em,label-width=1.6em,label-offset=0.5em, after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablenuma}[\item](2) \else \NewTasksEnvironment[label=\arabic*., column-sep=1em, after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablenum1}[\item](2) \NewTasksEnvironment[label=(\alph*), column-sep=1em,label-align=right, item-indent=2.15em,label-width=1.6em,label-offset=0.5em, after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablenuma}[\item](2) \fi } % end of macro \exs@process@setlist % \end{macrocode} % \DescribeEnv{tablitem} % \begin{macrocode} \NewTasksEnvironment[label=\labelitemi, label-align=right, item-indent=2.3333em,label-offset=0.5em, after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablitem}[\item](2) % \end{macrocode} % \DescribeEnv{tablenuma*} \DescribeEnv{tablitem*} % The starred environments \texttt{tablenuma*} and \texttt{tablitem*} % are designed to be employed within an \texttt{enumerate} environment, % precisely at the outset of an |\item|, in order to achieve correct horizontal % alignment. % The length of |-1.667\baselineskip| has been tested with various font families and sizes. % It functions properly. % \begin{macrocode} \newenvironment{tablenuma*}{% \mbox{}\vspace{-1.667\baselineskip}\begin{tablenuma}}{ \end{tablenuma}} \newenvironment{tablitem*}{% \mbox{}\vspace{-1.667\baselineskip}\begin{tablitem}}{ \end{tablitem}} % \end{macrocode} % \DescribeEnv{colsenum} % \begin{macrocode} \newenvironment{colsenum}[2][]{% \setlength{\multicolsep}{2ex} \raggedcolumns % default is \flushcolumns \begin{multicols}{#2} % #2 = number of columns \begin{enumerate}[#1] % #1 = options of enumerate }{ \end{enumerate} \end{multicols} } % \end{macrocode} % \DescribeEnv{colsenum*} % \begin{macrocode} \newenvironment{colsenum*}[2][]{% \setlength{\multicolsep}{2ex} \begin{multicols}{#2} % #2 = number of columns \begin{enumerate}[#1] % #1 = options of enumerate }{ \end{enumerate} \end{multicols} } % \end{macrocode} % \DescribeEnv{colsitem} % \begin{macrocode} \newenvironment{colsitem}[2][]{% \setlength{\multicolsep}{2ex} \raggedcolumns \begin{multicols}{#2} \begin{itemize}[#1] }{ \end{itemize} \end{multicols} } % \end{macrocode} % \DescribeEnv{colsitem*} % \begin{macrocode} \newenvironment{colsitem*}[2][]{% \setlength{\multicolsep}{2ex} \begin{multicols}{#2} \begin{itemize}[#1] }{ \end{itemize} \end{multicols} } % \end{macrocode} % % \subsection{Questions and answers} % % \begin{macro}{\exs@process@output} % The booleans |exesheet@questions| and |exesheet@answers| % governs the visibility of their corresponding environments. % These booleans are configured through the \texttt{output} key option within the % |\exs@process@output| macro. % \begin{macrocode} \newboolean{exesheet@questions}\setboolean{exesheet@questions}{true} \newboolean{exesheet@answers}\setboolean{exesheet@answers}{true} \def\exs@process@output{ \ifthenelse{\equal{\exesheet@output}{questions}}{ \setboolean{exesheet@questions}{true} \setboolean{exesheet@answers}{false} }{% else if \ifthenelse{\equal{\exesheet@output}{answers}}{ \setboolean{exesheet@questions}{false} \setboolean{exesheet@answers}{true} }{% else if \ifthenelse{\equal{\exesheet@output}{both}}{ \setboolean{exesheet@questions}{true} \setboolean{exesheet@answers}{true} }{% else \PackageWarning{exesheet}{Value `\exesheet@output' is not supported by `output' option} }}} } % \end{macrocode} % \end{macro} % % \begin{environment}{questions} % We utilize the \textsf{versions} package developed by Uwe Lück, % which introduces the macros |\comment| and |\endcomment|. % These macros facilitate conditional displays, a technique also employed % in the \textsf{verbatim} and \textsf{version} packages. % Additionally, the notable \textsf{codesection} package offers the capability % to enclose optional code between |\BeginCodeSection|\marg{skip} % and |\EndCodeSection|\marg{skip} macros, % both in the text body and the preamble. % However, these macros cannot be used within an environment % as we've done here with |\comment| and |\endcomment|. % Several of our tests use the \LaTeX{} syntax |\ifthenelse{\bolean{...}}| % since |\comment| and |\endcomment| can sometimes interfere % with the \TeX\ structure |\if| \ldots |\else| \ldots |\fi|. % % The two counters |exe@ini| and |subpart@ini| are employed in % the subsequent |\set@toclevel| macro. % \begin{macrocode} \newcounter{exe@ini} \newcounter{subpart@ini} \newenvironment{questions}{ \ifthenelse{\boolean{exesheet@questions}}{% \setcounter{exe@ini}{\value{exercise}} \setcounter{subpart@ini}{\value{subpart}} }{\comment} }{\ifthenelse{\boolean{exesheet@questions}}{}{\endcomment}} % \end{macrocode} % \end{environment} % \begin{environment}{answers} % The internal macro |\set@toclevel| calculates the title level (counter |toc@level|) % to ensure correct typesetting of ``\correctionname'' at the start of an % \texttt{answers} environment, when \texttt{questions} and \texttt{answers} are % displayed together. It involves comparing the \texttt{exercise} and \texttt{subpart} % counters with their values at the time of the \texttt{questions} environment call. % The |\@enumdepth| counter indicates the % current \texttt{enumerate} list level (with 0 indicating outside of any list). % The optional parameter of the \texttt{answers} environment permits % the explicit specification of this title level. % \begin{macrocode} \newcounter{@toclevel} \newcommand{\set@toclevel}[1][]{ \ifthenelse{\equal{#1}{}}{ \ifthenelse{\value{exercise} > \value{exe@ini}}{ \setcounter{@toclevel}{1} }{% else \ifthenelse{\equal{\the\@enumdepth}{0}}{ % we're not in an enumerate environment \ifthenelse{\(\value{subpart} > \value{subpart@ini}\) \or \(\value{subpart} = 0\)}{ \setcounter{@toclevel}{2} }{\setcounter{@toclevel}{3}} }{\setcounter{@toclevel}{4}}} }{\setcounter{@toclevel}{#1}}} % \end{macrocode} % The internal macro |\typeset@correctionname|, % displays the term ``\correctionname'' at the appropriate level. % \begin{macrocode} \definecolor{correctioncolor}{rgb}{0,0.2,0.6} % kind of dark blue \newcommand{\correctionstyle}{\color{correctioncolor}} \newcommand{\typeset@correctionname}{ \ifthenelse{\value{@toclevel} = 1}{ \section*{\correctionstyle\correctionname} \ifexesheet@exetoc \addcontentsline{toc}{section}{\correctionname} \fi \setcounter{exercise}{0} }{% else if \ifthenelse{\value{@toclevel} = 2}{% \subsection*{\correctionstyle\correctionname} \ifexesheet@exetoc \addcontentsline{toc}{subsection}{\correctionname} \fi \setcounter{subpart}{0} }{% else if \ifthenelse{\value{@toclevel} = 3}{% \subsubsection*{\correctionstyle\correctionname} \ifexesheet@exetoc \addcontentsline{toc}{subsubsection}{\correctionname} \fi }{% else \par\textbf{\correctionstyle\correctionname}\par }}} } % \end{macrocode} % Then we proceed to define the \texttt{answers} environment. % \begin{macrocode} \newenvironment{answers}[1][]{% #1 is the optional level \ifthenelse{\boolean{exesheet@answers}}{% \ifthenelse{\boolean{exesheet@questions}}{ \set@toclevel[#1] \typeset@correctionname \correctionstyle% \ifexesheet@multicol \renewcommand{\columnseprulecolor}{\color{correctioncolor}} \fi }{} }{\comment} }{\ifthenelse{\boolean{exesheet@answers}}{}{\endcomment}} \newenvironment{answers*}{ \ifthenelse{\boolean{exesheet@answers}}{}{\comment} }{\ifthenelse{\boolean{exesheet@answers}}{}{\endcomment}} % \end{macrocode} % In the \texttt{answers} environment, when placing |\correctionstyle| % before |\subsubsection| (as in the case of |\typeset@correctionname|), % the preceding vertical space may become too wide. % \end{environment} % % \begin{macro}{\question} % \begin{macrocode} \newcommand{\question}[1]{\ifexesheet@questions #1\fi} % \end{macrocode} % \end{macro} % \begin{macro}{\answer} % \begin{macrocode} \newcommand{\answer}[1]{% \ifexesheet@answers% \ifexesheet@questions \correctionstyle #1\else #1\fi \fi } % \end{macrocode} % \end{macro} % \begin{macro}{\answerspace} % The |\answerspace| macro was suggested by Maxime Chupin % to allow students space for writing their answers on the provided paper. % \begin{macrocode} \newcommand\answerspace[1]{ \ifexesheet@answerspace \par\vspace{#1} \fi} % \end{macrocode} % \end{macro} % % \subsection{Marking scheme options processing} \label{MSoptions} % % The options \texttt{display}, \texttt{marginpos}, \texttt{marginwidth} % and \texttt{noteragged} are handled using the following internal commands. % % \medskip % The \texttt{display} key option determines the value of the two booleans % |exesheet@pts| and |exesheet@notes|. % The |exesheet@pts| boolean controls the display of the content of |\pts| % and optional arguments of |\note|, % while the |exesheet@notes| boolean controls mandatory arguments of |\note|. % % \begin{macro}{\exs@process@display} % \begin{macrocode} \newboolean{exesheet@pts} \newboolean{exesheet@notes} \def\exs@process@display{ \ifthenelse{\equal{\exesheet@display}{pts}}{ \setboolean{exesheet@pts}{true} \setboolean{exesheet@notes}{false} }{% else if \ifthenelse{\equal{\exesheet@display}{notes}}{ \setboolean{exesheet@pts}{true} \setboolean{exesheet@notes}{true} }{% else if \ifthenelse{\equal{\exesheet@display}{none}}{ \setboolean{exesheet@pts}{false} \setboolean{exesheet@notes}{false} }{% else \PackageWarning{exesheet}{Value `\exesheet@display' is not supported by `display' option} }}} } % \end{macrocode} % \end{macro} % \begin{macro}{\exs@process@marginpos} % The \texttt{marginpos} key option takes the values \texttt{left} (the default value) % or \texttt{right} (or \texttt{inner} and \texttt{outer}). % In practice, \texttt{inner} is equivalent to \texttt{left}, % but in two-sided mode, the values \texttt{left} or \texttt{right} % are converted to \texttt{outer} (which is then the default value for two-sided mode). % \begin{macrocode} \newboolean{exesheet@leftmargin} \def\exs@process@marginpos{ \ifthenelse{\equal{\exesheet@marginpos}{left}}{ \if@twoside% \PackageWarningNoLine{exesheet}{The default `marginpos' option \MessageBreak for two-sided documents is `outer'.\MessageBreak To change the side, use `inner'} \def\exesheet@marginpos{outer} \setboolean{exesheet@leftmargin}{false} \normalmarginpar \else% default \setboolean{exesheet@leftmargin}{true} \reversemarginpar \fi }{% else if \ifthenelse{\equal{\exesheet@marginpos}{right}}{ \if@twoside% \PackageWarningNoLine{exesheet}{The default `marginpos' option \MessageBreak for two-sided documents is `outer'.\MessageBreak To change the side, use `inner'} \def\exesheet@marginpos{outer} \fi \setboolean{exesheet@leftmargin}{false} \normalmarginpar }{% else if \ifthenelse{\equal{\exesheet@marginpos}{inner}}{ \setboolean{exesheet@leftmargin}{true} \reversemarginpar }{% else if \ifthenelse{\equal{\exesheet@marginpos}{outer}}{ \setboolean{exesheet@leftmargin}{false} \normalmarginpar }{% else \PackageWarningNoLine{exesheet}{The value `\exesheet@marginpos' is not supported by the `marginpos' option} }}}} } % \end{macrocode} % \end{macro} % \begin{macro}{\exs@process@marginwidth} % The \texttt{marginwidth} option adjusts the ratio between left and right margins % based on what needs to be displayed in the margin (points only or full notes) % \footnote{To ensure the accurate effect on the margin ratio, this option is processed % at beginning of the document, after other commands % that could potentially alter the page geometry.}. % % When \texttt{display=notes}, the additional length of \texttt{1\,in} corresponds to % the default free space to the left of |\oddsidemargin|. % % The macros |\standardmarginwidthfactor| and |\largemarginwidthfactor| % represent the ratios between the total margin width and |\marginparwidth|. % % \begin{macrocode} \def\standardmarginwidthfactor{0.6} \def\largemarginwidthfactor{0.8} \newcommand*{\leftnotemarginwidth}[1]{ \setlength{\marginparwidth}{\oddsidemargin} \addtolength{\marginparwidth}{1in} \addtolength{\marginparwidth}{-\marginparsep} \setlength{\marginparwidth}{#1\marginparwidth} } \newcommand*\rightnotemarginwidth[1]{ \setlength{\marginparwidth}{\paperwidth} \addtolength{\marginparwidth}{-\textwidth} \addtolength{\marginparwidth}{-\oddsidemargin} \addtolength{\marginparwidth}{-\marginparsep} \addtolength{\marginparwidth}{-1in} \setlength{\marginparwidth}{#1\marginparwidth} } \def\exesheet@smallmargins{ \geometry{hmarginratio=1:1} \leftnotemarginwidth{\standardmarginwidthfactor} } \def\exesheet@standardmargins{ \ifexesheet@leftmargin \geometry{hmarginratio=3:2} \leftnotemarginwidth{\standardmarginwidthfactor} \else \geometry{hmarginratio=2:3} \rightnotemarginwidth{\standardmarginwidthfactor} \fi } \def\exesheet@largemargins{ \ifexesheet@leftmargin \geometry{hmarginratio=3:1} \leftnotemarginwidth{\largemarginwidthfactor} \else \geometry{hmarginratio=1:3} \rightnotemarginwidth{\largemarginwidthfactor} \fi } \def\exs@process@marginwidth{ \ifthenelse{\equal{\exesheet@marginwidth}{standard}}{ \ifthenelse{\equal{\exesheet@display}{none}}{ \if@twoside \exesheet@standardmargins \else \exesheet@smallmargins \fi }{% else display=pts or display=notes \exesheet@standardmargins } }{% else if \ifthenelse{\equal{\exesheet@marginwidth}{expand}}{ \ifthenelse{\equal{\exesheet@display}{none}}{ \if@twoside \exesheet@standardmargins \else \exesheet@smallmargins \fi }{% else if \ifthenelse{\equal{\exesheet@display}{pts}}{ \exesheet@standardmargins }{% else display=notes \exesheet@largemargins }} }{% else if \ifthenelse{\equal{\exesheet@marginwidth}{unset}}{ % do nothing }{% else \PackageWarningNoLine{exesheet}{The value `\exesheet@marginwidth' is not supported by the `marginwidth' option} }}} } % \end{macrocode} % \end{macro} % For a two-sided document, the \textsf{geometry} package doe not correctly set % the width of the margin paragraph by default; it's too wide. % Therefore we provide an explicit setting here, which is % useful when \texttt{marginwidth=unset}. Otherwise, the setting is % handled by the \texttt{marginwidth} key option. % % \begin{macrocode} \if@twoside \rightnotemarginwidth{0.5} \fi % \end{macrocode} % \begin{macro}{\exs@process@noteragged} % The noteragged option can take one of the following values: % \texttt{left}, \texttt{right}, \texttt{center}, \texttt{justify} or \texttt{twoside}. % When working with a two-sided document, |\marginpar| can be used with an optional parameter % to distinguish left from right contents. % In this context, we employ |\noteraggedleft| and |\noteraggedright| instead of |\noteragged|. % The \textsf{ragged2e} package by Martin Schröder offers the commands % |\RaggedLeft|, |\RaggedRight|, |\Centering|, and |\justifying|. % These commands yield better results compared to the standard % |\raggedleft|, |\raggedright| and |\centering| commands. % Margin paragraphs are justified by default in \LaTeX. % \begin{macrocode} \newcommand{\noteragged}{} \newcommand{\noteraggedleft}{} \newcommand{\noteraggedright}{} \def\exs@process@noteragged{ \ifthenelse{\equal{\exesheet@noteragged}{left}}{ \if@twoside \renewcommand{\noteraggedleft}{\RaggedLeft} \renewcommand{\noteraggedright}{\RaggedLeft} \else \renewcommand{\noteragged}{\RaggedLeft} \fi }{% else if \ifthenelse{\equal{\exesheet@noteragged}{right}}{ \if@twoside \renewcommand{\noteraggedleft}{\RaggedRight} \renewcommand{\noteraggedright}{\RaggedRight} \else \renewcommand{\noteragged}{\RaggedRight} \fi }{% else if \ifthenelse{\equal{\exesheet@noteragged}{center}}{ \if@twoside \renewcommand{\noteraggedleft}{\Centering} \renewcommand{\noteraggedright}{\Centering} \else \renewcommand{\noteragged}{\Centering} \fi }{% else if \ifthenelse{\equal{\exesheet@noteragged}{justify}}{ \renewcommand{\noteraggedleft}{\justifying} % equiv to nothing \renewcommand{\noteraggedright}{\justifying} \renewcommand{\noteragged}{\justifying} % justify is the default LaTeX setting }{% else if \ifthenelse{\equal{\exesheet@noteragged}{twoside}}{ \if@twoside \renewcommand{\noteraggedleft}{\RaggedLeft} \renewcommand{\noteraggedright}{\RaggedRight} \else \PackageWarning{exesheet}{Invalid option `noteragged=twoside' when the document \MessageBreak is not in two-side mode} \fi }{% else \PackageWarning{exesheet}{The value `\exesheet@noteragged' is not supported by the `noteragged' option} }}}}} } % \end{macrocode} % \end{macro} % % \begin{macro}{\exs@process@checkpts} % The scale control option relies on calculations with \emph{lengths}, % which need to have a \emph{global} scope. % To achieve this, we employ the macros |\gsetlength| and |\gaddtolength|. % These macros include \% symbols at the end of lines to avoid expanded blank % spaces. % % For questions, assigned points will be added in |\sum@pts|, % while for exercises, points accumulate in |\sum@exe|. % These lengths are compared against |\exe@total| and |\sheet@total|. % The |\exe@check| macro validates the calculations of the previous exercise % when triggered by |\points|, |\totalexe| or |\totalpoints| macros. % It is also invoked within |\exs@process@checkpts| at the document's end % for a final check on the last exercise. % \begin{macrocode} \newlength{\sheet@total} \newlength{\sum@exe} \newlength{\exe@total} \newlength{\sum@pts} \def\exe@label{none} \newboolean{scale@valid} \setboolean{scale@valid}{true} \gdef\gsetlength#1#2{% for obtaining global length values \begingroup \setlength\skip@{#2}% local assignment to a scratch register \global#1=\skip@% global assignment to #1 \endgroup % \skip@ is restored at the end of the group } \gdef\gaddtolength#1#2{% percent symbol necessary here! \begingroup \setlength\skip@{#1}% \addtolength\skip@{#2}% \global#1=\skip@% \endgroup } \def\exe@check#1{ \ifthenelse{\lengthtest{\sum@pts = 0pt}\or\equal{\exe@label}{none}}{ % do not check, no \pts or first exercise begins }{ \ifthenelse{\lengthtest{\exe@total = \sum@pts}}{ \PackageWarningNoLine{exesheet}{\exe@label: The scale of \the\exe@total\space is valid} }{ \PackageWarningNoLine{exesheet}{\exe@label: Sum of points is \the\sum@pts\space instead of \the\exe@total} \setboolean{scale@valid}{false} } \gsetlength{\sum@pts}{0pt} } \def\exe@label{#1} % for the upcoming exercise } \def\exs@process@checkpts{ \ifexesheet@checkpts \ifthenelse{\lengthtest{\sheet@total = 0pt}}{ \PackageWarningNoLine{exesheet}{Option checkpts is true, \MessageBreak but \string\totalsheet\space is missing in the preamble. \MessageBreak See documentation} }{} \gsetlength{\sum@exe}{0pt} \gsetlength{\exe@total}{0pt} \gsetlength{\sum@pts}{0pt} \AtEndDocument{ \ifthenelse{\equal{\exe@label}{none}}{ \ifthenelse{\lengthtest{\sheet@total = \sum@pts}}{ \PackageWarningNoLine{exesheet}{Sum of points is valid: \the\sheet@total} }{ \PackageWarningNoLine{exesheet}{Inconsistent sum of points: \the\sum@pts\space instead of \the\sheet@total} \setboolean{scale@valid}{false} } }{ \exe@check{end} \ifthenelse{\lengthtest{\sheet@total = \sum@exe}}{ \PackageWarningNoLine{exesheet}{Sum of points is valid: \the\sheet@total} }{ \PackageWarningNoLine{exesheet}{Inconsistent sum of points: \the\sum@exe\space instead of \the\sheet@total} \setboolean{scale@valid}{false} } } \ifthenelse{\boolean{scale@valid}}{ \PackageWarningNoLine{exesheet}{Scale is valid} }{ \PackageWarningNoLine{exesheet}{INVALID SCALE! Refer to above} } } \fi } % \end{macrocode} % \end{macro} % % \subsection{Margin notes commands} % % \begin{macro}{\points} % \begin{macrocode} \definecolor{pointscolor}{named}{red} \newcommand{\pointsstyle}{% \small\mdseries\sffamily\color{pointscolor}\fbox} \newcommand*{\exesheet@points}[1]{\hfill \pointsstyle{#1~% \ifthenelse{\lengthtest{#1pt < 2pt}}{\pointname}{\pointsname}} \ifexesheet@checkpts\gaddtolength{\sum@exe}{#1pt}\fi% } \newcommand*{\points}[1]{% \ifthenelse{\boolean{exesheet@questions}}{\exesheet@points{#1}}{}} % \end{macrocode} % To prevent spaces between the |\fbox| and its inner text, % percent symbols are necessary. % The test |#1 < 2| doesn't work with decimal numbers without |\lengthtest|, % but it works with lengths. % \end{macro} % \DescribeMacro{\pts} % \begin{macrocode} \definecolor{ptscolor}{named}{red} \newcommand{\ptsstyle}[1]{% \footnotesize\centering\sffamily\color{ptscolor} (#1)} \newcommand*{\ptsmark}[1]{% \ifthenelse{\lengthtest{#1pt < 2pt}}{#1 \ptname}{#1 \ptsname}} \newcommand*{\pts}[1]{% \ifexesheet@pts% \mbox{}% \marginpar{\hspace{0pt}\ptsstyle{\ptsmark{#1}}}% \ifexesheet@checkpts% \gaddtolength{\sum@pts}{#1pt}% \fi% \fi% \ignorespaces } % \end{macrocode} % % \begin{macro}{\totalexe} % In the subsequent macros that utilize % |\marginpar|, the presence of percent symbols and |\ignorespaces| is essential % to prevent the occurrence of expanded blank spaces in the text (or the margin), % where these macros are incorporated. % \begin{macrocode} \definecolor{markingcolor}{named}{red} \newcommand{\markingstyle}[1]{\footnotesize\sffamily% \centering\color{markingcolor}\textbf{#1}} % inner arguments enable the implementation of boxed styles \newlength{\ptsboxlength} \setlength{\ptsboxlength}{3.1em} \cornersize{1} \newcommand*{\totalexe}[1]{% \ifexesheet@pts% \mbox{}% \marginpar{\hspace{0pt}\markingstyle{\ovalbox{% \makebox[\ptsboxlength]{\ptsmark{#1}}}}}% \fi% \ifexesheet@checkpts% \gsetlength{\exe@total}{#1pt}% \gaddtolength{\sum@exe}{#1pt}% \fi% \ignorespaces } % \end{macrocode} % \end{macro} % \begin{macro}{\totalsheet} % \begin{macrocode} \newcommand*{\totalsheet}[1]{ \gsetlength{\sheet@total}{#1pt} } % \end{macrocode} % \end{macro} % % \begin{macro}{\note} % The booleans \texttt{exesheet@pts} and \texttt{exesheet@notes} control % the display of marginal notes. If \texttt{exesheet@pts} is set to \texttt{false}, % \DescribeMacro{\note*} % \texttt{exesheet@notes} will be ignored. % |\noindent| is required when using |\justifying| from the \textsf{ragged2e} % package. % Within the |\note@marginpar| macro, enclosing |\markingstyle| in double braces % helps prevent unintended formatting within the mandatory argument of |\note|. % A vicious error occurs when using an |\if| \ldots |\fi| structure % instead of |\ifthenelse| inside |\note@marginpar| % (but only if |@twoside| is \texttt{true}). % \begin{macrocode} \definecolor{notecolor}{rgb}{0.0, 0.4, 0.0} % kind of dark green \newcommand{\notestyle}[1]{\footnotesize\sffamily\color{notecolor} #1} \newcommand{\note@marginpar}[1]{% \if@twoside% \marginpar[\noteraggedleft #1]{\noteraggedright #1}% \else% \marginpar{\noteragged #1}% \fi% } \newcommand{\@note}[2][]{% \ifexesheet@pts% \mbox{}% \note@marginpar{% \ifthenelse{\equal{#1}{}}{}{{% \noindent\hspace{0pt}\markingstyle{#1}\\}}% \ifthenelse{\boolean{exesheet@notes}}{% \noindent\hspace{0pt}\notestyle #2% }{}% }% \fi% \ifexesheet@checkpts% \ifthenelse{\equal{#1}{}}{}{% \gaddtolength{\sum@pts}{#1pt}}% \fi% \ignorespaces } \newcommand{\@@note}[1]{% \ifexesheet@pts% \mbox{}% \marginpar{\noindent\hspace{0pt}\markingstyle{#1}}% \fi% \ifexesheet@checkpts% \gaddtolength{\sum@pts}{#1pt}% \fi% \ignorespaces } \newcommand{\note}{\@ifstar{\@@note}{\@note}} % \end{macrocode} % \end{macro} % \begin{macro}{\totalpoints} % \begin{macrocode} \newcommand{\totalpoints}{% \ifthenelse{\boolean{exesheet@pts}}{\totalexe}{\points}} % \end{macrocode} % \end{macro} % % \subsection{The \texttt{correct} option and other (deprecated) commands} % % \begin{macro}{\exs@process@correct} % \begin{macrocode} \def\exs@process@correct{ \ifthenelse{\equal{\exesheet@correct}{false}}{ % do nothing }{% else \@ifpackageloaded{schooldocs}{ \ifthenelse{\equal{\exesheet@correct}{true}}{ \correct }{% else \ifthenelse{\equal{\exesheet@correct}{conditional}}{ \ifexesheet@answers \correct \fi }{}} }{ \PackageWarningNoLine{exesheet}{The `correct' option requires \MessageBreak the `schooldocs' package to be loaded} }} } % \end{macrocode} % \end{macro} % % For the time being, the following macros are kept for compatibility reasons. % \begin{macrocode} \newcommand{\questionsonly}{ \PackageWarning{exesheet}{The command \string\questionsonly\space is deprecated; \MessageBreak use the package option `output=questions' instead} \renewcommand\exesheet@output{questions} \exs@process@output } \newcommand{\answersonly}{ \PackageWarning{exesheet}{The command \string\answersonly\space is deprecated; \MessageBreak use the package option `output=answers' instead} \renewcommand\exesheet@output{answers} \exs@process@output } \newcommand{\displaypts}{% \PackageWarning{exesheet}{The command \string\displaypts\space is deprecated; \MessageBreak use the package option `display=pts' instead} \renewcommand\exesheet@display{pts} \exs@process@display } \newcommand{\displaypoints}{% \PackageWarning{exesheet}{The command \string\displaypoints\space is deprecated; \MessageBreak use the package option `display=pts' instead} \renewcommand\exesheet@display{pts} \exs@process@display } \newcommand*{\displaynotes}[1][\RaggedLeft]{% % \renewcommand{\noteragged}{#1} no effect now! \PackageWarning{exesheet}{The command \string\displaynotes\space is deprecated; \MessageBreak use the package option `display=notes' instead} \renewcommand\exesheet@display{notes} \exs@process@display \renewcommand{\noteragged}{#1} } \newcommand*{\displaynotesright}[1][\RaggedRight]{% % \renewcommand{\noteragged}{#1} no effect now! \PackageWarning{exesheet}{The command \string\displaynotes\space is deprecated; \MessageBreak use the package options `display=notes, margin=right' instead} \renewcommand\exesheet@display{notes} \exs@process@display \renewcommand\exesheet@margin{right} \renewcommand{\noteragged}{#1} } \PackageInfo{exesheet}{The environment `tablenum' is deprecated \MessageBreak and has been replaced by `tablenum1'. \MessageBreak The options `notoc' and `nosetlist' \MessageBreak are no longer supported\@gobble} % \@gobble suppresses the line number here % % \end{macrocode} % % \Finale \endinput