% \iffalse meta-comment
%
% Copyright (C) 2020-2025 by Antoine Missier <antoine.missier@ac-toulouse.fr>
% ----------------------------------------------------------------------
% 
% 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}
%</driver>
%<class|package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
%<class>\ProvidesClass{exesheet}
%<package>\ProvidesPackage{exesheet}
%<*class|package>
[2025/05/04 v2.9 Typesetting exercise or exam sheets]
%</class|package>
%<*driver>
\documentclass{ltxdoc}

\usepackage{hypdoc} % to avoid a bug
% uncomment the following lines when not using the ltxdoc class
%\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{fixcmex}
\usepackage{multicol}
\usepackage{hyperref}
\usepackage{sectsty}
\usepackage{pstricks}
\usepackage{array}
\usepackage[pifont]{spacingtricks}
%
\psset{unit=1cm}
\geometry{textwidth=355pt,textheight=600pt,vmarginratio=1:1,hmarginratio=3:2}
% very close from the default geometry used by ltxdoc.
% The following instruction provides the same margin width
% as with display=notes without altering the margin ratio
\leftnotemarginwidth{0.65}
\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,
    citecolor=red, 
    pdftitle={exesheet},
    pdfsubject={LaTeX class and package},
    pdfauthor={Antoine Missier}
}

\begin{document}
\DocInput{exesheet.dtx}
\end{document}
%</driver>
% \fi
%
% \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) is replaced by tablenum1, 
%    - small modifications due to changes in the tasks package}
%
% \changes{v1.2}{2021/09/18}{
%    - bug correction in the tablenum1 and tablenuma macros, 
%    - 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 'output' key instead of the old commands questionsonly, answersonly,
%    - introducing the 'display' key instead of the old commands displaypts, displaypoints,
%        displaynotes,
%    - introducing the 'margin' and 'noteragged' keys, to set how the notes are displayed,
%    - introducing the 'correct' key}
% \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-sided mode documents}
% \changes{v2.0}{2023/01/16}{
%    - \enskip between titles and their optional argument,
%    - simplifying the macros markingstyle and notestyle,
%    - use of the ragged2e package,
%    - code revision and simplification,
%    - documentation update}
%
% \changes{v2.1}{2023/07/30}{
%    - new starred environments tablenuma* and tablitem*}
% \changes{v2.1}{2023/08/24}{
%    - English corrections in the documentation}
%
% \changes{v2.2}{2023/09/02}{
%    - correction of a color bug in the answer macro and the answers* environment
%    - additional remark about the use of answers environments}
% \changes{v2.2}{2023/09/04}{
%    - new commands, labelenumone and labelenuma, allowing for global changes to
%        tasks environments
%    - the answerspace option is set to false when answers are displayed}
%
% \changes{v2.3}{2023/10/24}{
%    - new implementation of marking scheme checking:
%        checking is done in points or totalpoints instead of exercise command,
%    - correct ref macro for tablenuma using ref option in tasks, 
%        available since 2020/08/19
%    - new commands question* and answer* for executing code when 
%        questions are displayed but not answers, or the contrary
%    - using basic languages (with lower case first letter) instead of aliases
%        in translations commands}
%
% \changes{v2.4}{2023/10/28}{
%    - a small mistake in the documentation about the example of the tablenuma environment
%        is now corrected
%    - other small changes in the documentation
%    - lack of percent symbols at end of lines in the exe@check macro causes an unwanted
%        space in points macro}
%
% \changes{v2.5}{2023/12/30}{
%    - gsetlength and gaddtolength unnecessary
%    - deprecated commands -> old commands
%    - comparison with other packages
%    - modifying introduction}
%
% \changes{v2.6}{2024/02/03}{
%    - error message when using colsenum or colsitem without loading multicol
%    - changes in the comparison with other packages}
%
% \changes{v2.7}{2024/02/13}{
%    - an expl3 update prevents the correction color in tasks environment -> fixed
%    - new command enumfont
%    - babel-french option 'StandardLists=true' works now if french 
%        is passed in documentclass
%    - completion of the comparison with other packages}
%
% \changes{v2.8}{2024/12/22}{
%    - improvements in answers environment
%    - starred environments tablenuma* and tablitem* no longer supported
%    - character table and checksum removed from dtx file (useless)}
%
% \changes{v2.9}{2025}{
%    - improvements in answerspace command
%    - new way of resetting the exercise and part counters in answers environments
%    - annex with source code of the examples
%    - including exam-n in the comparison subsection in place of hideanswer}
%
% \GetFileInfo{exesheet.dtx}
%
% \maketitle
% \enlargethispage{1ex}
% \tableofcontents
%
% \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~\cite{SCHOOL}.
% 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.
% In section \ref{comparison} we provide an overview of some of their functionalities.
% 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 ways to introduce exercises, 
% which are more appropriate for shorter exercises.
%
% The \textsf{exesheet} package provides specific settings
% for enumeration lists, which are
% suitable for numbering questions or answers within an exercise.
%
% For all exercises within the sheet, you can display only the questions, 
% only the 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.
%
% The ability to hide questions or answers is found in many packages, 
% but the main interest of \textsf{exesheet} is to be able to display or not 
% a detailed scoring guide, along with correction instructions. 
% This is very useful for grading papers with multiple graders.
% Furthermore \textsf{exesheet} can check the consistency of the scale.
%
% 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}.
% These options can be applied when calling 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. Their source code is presented in an \hyperlink{source}{annex}
% after the \hyperlink{ref}{references}.}
%
% \section{Titles}
%
% \subsection{The \texttt{\bs exercise} command}
%
% \DescribeMacro{\exercise}
% The |\exercise|\oarg{opt} command initiates an exercise with the title 
% \textbf{\exercisename}, typeset 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)
% Try this first command; easy!
%
% \bigskip
% To bring optional text closer to the exercise number, 
% you 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
% \DescribeMacro{\exercisename}
% The word ``\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 alter it by modifying |\exercisename|.
% A better approach is to use macros from the \mbox{\textsf{translations}}
% package by Clemens Niederberger~\cite{TRAN} (which allows 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
% |\theexercise| which is 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 (sans serif) using the
% \texttt{\bs allsectionsfont} macro from the \textsf{sectsty} package~\cite{SECT}.}.
%
% \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 allow customization 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
% (depending on the chosen language).
% It can be extended to additional languages or altered by redefining |\annexname|
% or by utilizing macros from the \textsf{translations} package~\cite{TRAN}.
%
% \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{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~\cite{TRAN}.
% The |\exlabel| macro combines |\exname| with a period then the exercise number
% (given by the same \texttt{exercise} counter),
% while |\exsepmark| typesets a long dash.
% These characteristics can be altered 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 used to represent questions and sub-questions
% within exercises. To provide clear emphasis,
% labels are typeset 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,
% a feature from the \textsf{enumitem} package by Javier Bezos~\cite{ENUM}.
%
% \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
% The \texttt{enumerate} environment takes an optional parameter, 
% that allows, among others things, 
% the typesetting of alternative list labels. For instance, typing
% |\begin{enumerate}[label=\alph*),font=\itshape\normalfont]|
% will produce the labels ``\emph{a)}, \emph{b)}, \emph{c)}\ldots''.
% There are many other options available
% (see the \textsf{enumitem}~\cite{ENUM} package documentation)
% \footnote{Labels can also be modified using a ``shortlabel'' argument, 
% \eg \texttt{\bs begin\{enumerate\}[A.]},
% or globally through the redefinition of \texttt{\bs labelenumi} 
% or \texttt{\bs labelenumii} commands.}.
% Label font formatting can be changed globally using
% |\setlist[enumerate]{font=...}|
% (called \emph{after} |\begin{document}|).
%
% Lists created with the \texttt{itemize} environment retain their default 
% configuration
% \footnote{However, the \texttt{french} option of the \textsf{babel} package
% changes the appearance of \texttt{itemize} lists and employs long dashes
% as labels for each list level.
% This can cause issues when mathematical content follows the dash
% symbol, as it might be mistaken for the minus sign.
% Thus, with the option \texttt{setlist=true}, the default \LaTeX{}
% \texttt{itemize} list style is 
% reinstated with \texttt{\bs frenchsetup\{StandardLists=true\}}.}.
% ^^A The \texttt{\bs frenchsetup} command can also achieve other settings.}.
%
% \medskip
% \DescribeMacro{[setlist=\meta{bool}]}
% The package option |setlist=false|  prevents changes to enumeration lists 
% and reverts to the default \LaTeX{} settings 
% (the default value is \texttt{true}).
%
% \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):
%
% \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}
%
% \smallskip
% The \texttt{exenumerate} environment (also based on the 
% \textsf{enumitem}~\cite{ENUM} package) accepts an optional parameter, 
% similar to the \texttt{enumerate} environment.
%
% \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.
%
% \smallskip
% Internally we have utilized the
% |\NewTasksEnvironment| macro from the \textsf{tasks} package by 
% Clemens Niederberger~\cite{TASK}.
% The usage of the optional argument \meta{opt} is
% explained in the documentation of this package.
% For example, similar to the \mbox{\textsf{enumitem}} package~\cite{ENUM},
% |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}|.
% Notice that numbering occurs line by line in this context.
%
% \exercise
% \psframe(-0.25,1.3)(12.75,-2.7)
% Calculate 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. 
%
% \DescribeMacro{\labelenumone}\DescribeMacro{\labelenuma}
% You can change the labels by redefining the macros |\labelenumone| 
% (for \texttt{tablenum1}) and |\labelenuma| (for \texttt{tablenuma}), 
% using the \texttt{task} counter:
% \eg |\renewcommand\labelenuma{\Alph{task}.}| yields the labels 
% \textbf{A.}, \textbf{B.}, etc.
%
% \smallskip
% \DescribeMacro{\enumfont}
% With the default option \texttt{setlist=true},
% the font of all enumeration labels may be changed by redefining |\enumfont|
% (|\bfseries| by default).
% 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 normal font rather than bold.
% You can change the label formatting globally with the command |\settask|, \eg
% |\settask{label-format=\itshape}|.
% You can also completely redefine the environments using |\RenewTasksEnvironment|.
% When \texttt{setlist=true}, place these commands \emph{after} |\begin{document}|.
%
% \medskip
% When you intend to utilize \texttt{tablenuma} (or \texttt{tablitem})
% immediately after inserting the |\item| command
% within an \texttt{enumerate} environment,
% a vertical misplacement may occur as shown below:
% \begin{enumerate}
% \item 
% \begin{tablenuma}(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$.
% \end{tablenuma}
% \end{enumerate}
% To adjust the vertical alignment, include
% |\mbox{}\vspace|\marg{height} just after |\item| and before invoking |\begin{tablenuma}|
% (or |\begin{tablitem}|), where \meta{height} can be a positive or negative length.
% Here we used |\vspace{-5.4ex}|.
%
% \noindent\psframe(-0.25,0.15)(12.75,-1.05)
% \psline[linewidth=0.1pt,linecolor=green,linestyle=dashed](0,-0.56)(12,-0.56)
% \begin{enumerate}
% \item \mbox{}\vspace{-5.4ex}
% \begin{tablenuma}(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$.
% \end{tablenuma}
% \end{enumerate}
%
% \subsection{Items aligned by column: \texttt{colsenum}, \texttt{colsitem}}
% \DescribeEnv{colsenum}    
% To achieve numbering of items by column, we provide the
% \texttt{colsenum} environment:
% |\begin{colsenum}|\oarg{opt}\marg{cols}. 
% The mandatory parameter is the number of columns,
% and the optional parameter will be passed to the underlying 
% \texttt{enumerate} environment,
% allowing you to change the numbering type (\eg a, A, etc.), among other possibilities.
% \emph{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.7)
% Calculate 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*}
% It may be observed 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 vertical spacing between items.
% If you desire this alignment
% (which is the default behavior in \textsf{multicol}), you can use the
% \texttt{colsenum*} environment (with the same syntax as \texttt{colsenum}).
% Here's what we obtain with \texttt{colsenum*}:
%
% \exercise
% \psframe(-0.25,1.3)(12.75,-2.67)
% Calculate 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}. It follows the same syntax as \texttt{colsenum}:
% |\begin{colsitem}|\oarg{opt}\marg{cols}. The optional parameter,
% passed to the underlying \texttt{itemize} environment, 
% allow to change the item label (bullet by default).
% Furthermore, just like \texttt{colsenum*}, the \texttt{colsitem*} environment
% produces column alignment from the bottom.
% \emph{The \textsf{multicol} package is also required and must be loaded in the preamble.}
%
% \section{Questions and solutions}
%
% \subsection{Environments \texttt{questions} and \texttt{answers}}
% \label{output}
%
% \DescribeEnv{questions} \DescribeEnv{answers}
% The \textsf{exesheet} 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
% \noindent\psframe(-0.25,-0.25)(12.75,-7.1) 
% \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 The \textsf{exesheet} package is 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, 
% \textsf{eqexam} by D. P. Story\ldots
% They are briefly presented in section \ref{comparison}.
% \end{enumerate}
% \end{answers}
%
% \medskip
% When only answers are displayed, the text color remains black and
% the word ``\correctionname'' is not displayed.
%
% \subsection{More about \texttt{answers} environments}
% Internally, we have utilized the |\comment| and |\endcomment| macros
% from the \mbox{\textsf{versions}} package by Uwe Lück~\cite{VERS}.
% Several other 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~\cite{VERS} offers 
% the |\excludeversion|\marg{env} and
% |\includeversion|\marg{env} macros which allow for the exclusion or inclusion 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.
% 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, users might wish to adjust the title's level themselves.
% To achieve this, you can manually set the level of the title ``\correctionname''
% using an optional \meta{level} argument which is defined as follows:
% 1 for section-level titles,
% 2 for subsections (akin to \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).
%
% \medskip
% \DescribeMacro{answers*}
% The starred version \texttt{answers*} doesn't display 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 when
% you wish to display answers immediately after each question item.
% The title ``\correctionname'' won't appear at the start
% of each answer with the |\answer| macro. 
% The answers are also 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.
% 
% \DescribeMacro{\question*}\DescribeMacro{\answer*}
% When a code must be executed only when questions are displayed but not
% answers, or the contrary, you have the starred versions \eg |\question*{\pagebreak}|.
%
% \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.
% Thanks to a suggestion from Maxime Chupin,
% we achieve this with 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).
% The  \texttt{answerspace} key option has no effect (equivalent to \texttt{false})
% when the answers are displayed (\texttt{output=answers} or \texttt{both}).
% Of course the |\answerspace| macro is not meant to be used within \texttt{answers}
% environments.
%
% \section{Marking scheme commands} 
%
% The \textsf{exesheet} package provides several commands to display a marking
% scheme, with optional comments and explanations about answers in the margins.
%
% \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 \texttt{\bs points} 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.35)
% Try to read this document to the end without drinking tea and you get five points.
%
% \bigskip
% When only the answers are displayed in an exercise, the |\points| macro doesn't
% show the points.
% Further, we provide another macro, which displays points
% in \texttt{questions} like here, and differently in \texttt{answers} environments
% (see section \ref{totalpoints}).
%
% \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}...|
%
% \leftnotemarginwidth{0.4}
% \vspace{-\baselineskip}
% \noindent\psframe(-2.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.
%
% \leftnotemarginwidth{0.65}
% \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 is positioned on the right side on odd pages and on 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 by Tom Sgouros and Stefan Ulrich~\cite{MPAR}
% (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 first comment in the following example is obtained using (immediately after |\item|)
% |\note[1]{0.5 for the anti-derivative\\0.5 for simplifying}|.
%
% \leftnotemarginwidth{0.55}
% \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}|.
% \leftnotemarginwidth{0.65}
%
% \vspace{-1ex}
% \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~\cite{FBOX},
% 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 comments 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.
% 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~\cite{GEOM}.
% For instance, you can place the following in the preamble:
% |\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.
% 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 is not displayed,
% it functions similarly to |\points| (visible in questions but not in answers),
% and when the scale is shown,
% it's akin to |\totalexe|.
% For instance, in exercise \ref{totalexe}, we could have used |\totalpoints| 
% instead of |\totalexe|. Thus,
% if the detailed marking scheme is not displayed, the total points would be presented
% similarly to exercise \ref{points}.
%
% \subsection{Marking scheme consistency checking}\label{scale}
%
% \DescribeMacro{[checkpts=\meta{bool}]}
% The marking scheme can be checked out
% \footnote{Thanks to Denis Bitouzé for his suggestion about this feature.}
% using the key-val option \texttt{checkpts=true} (or just \texttt{checkpts});
% 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 control is made at the beginning of the subsequent exercise,
% inside the |\points|, |\totalexe| or |\totalpoints| macros.
% No deep checking will be processed at this level if no points are displayed
% for the questions inside the exercise (with \texttt{display=none} option).
%
% \medskip
% \DescribeMacro{\totalsheet}
% At the end of the document, 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, which must be given
% by the |\totalsheet|\marg{points} macro in the preamble;
% otherwise, a warning message will be displayed.
% If subtotals have been assigned to exercises and \emph{displayed}, the overall comparison
% is made between the sum of these subtotals and the total points recorded
% using |\totalsheet|.
% 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 and comparison with other packages} 
%
% \subsection{Summary of available options}\label{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,
% an unrecognized value only triggers a warning message:
% \centeredline{\texttt{Value ... is not supported by ... 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,
% at the beginning of the document.
% \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} (by default) or \texttt{conditional}.
% Using \texttt{correct=conditional}, it behaves as \texttt{true} 
% when answers are displayed and \texttt{false} when they're not.
%
% \subsection{Alternative commands}
% 
% Prior to version 2.0, we used specialized commands to configure 
% output and display options.
% We have now implemented \emph{key=value} options.
% Although the latter are more user-friendly,
% one may prefer the old commands, so they are still supported,
% but will trigger a warning message. These commands are presented below.
%
% 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}.
%
% \DescribeMacro{\displaypts} \DescribeMacro{\displaypoints} 
% The commands |\displaypts| and |\displaypoints| 
% are equivalent to setting \texttt{display=pts}.
%
% \pagebreak
% \DescribeMacro{\displaynotes}\DescribeMacro{\displaynotesright}
% |\displaynotes| means \texttt{display=notes},
% and |\displaynotesright| corresponds to
% \texttt{display=notes,marginpos=right}.
% These two commands have an optional argument |\displaynotes|\marg{ragged}
% where \meta{ragged} is an alignment command to work inside margin notes.
% By default it is |\RaggedLeft| with |\displaynotes| and |RaggedRight|
% \footnote{These commands come from the \textsf{ragged2e} package 
% by Martin Schröder~\cite{RAGG}.}
% with |\displaynotesright|.
%
% \subsection{Comparison with other packages}\label{comparison}
%
% In this section, we will provide an overview of the functionalities (at he time version 2.7 
% of this package was published, February 13, 2024) 
% of various packages or classes found in the `Exercise' or `Exam' sections 
% of the CTAN archives
% (Comprehensive \TeX\ Archive Network).
% Considering the substantial number of packages in these sections, 
% some omissions may have been unintentionally made.
% Those excluded are those with documentation not in English 
% or primarily dedicated to producing multiple-choice questions 
% or random question generation. 
% We have focused here on typesetting functionalities and not on managing exercise 
% databases as there are specialized packages or external softwares for that.
%
% The following table is not a result of tests but presents a summary of information 
% collected from the documentation of these packages. 
%
% \begin{multicols}{2}
% \begin{flushleft}
% \begin{enumerate}[label=\Alph*., font=\normalfont, noitemsep]
% \item \textsf{exercise}, Paul Pichaureau~\cite{EXER}
% \item \textsf{exercises}, Roger Jud~\cite{EXES}
% \item \textsf{xsim}, Clemens Niederberger~\cite{XSIM}
% \item \textsf{exframe}, Niklas Beisert~\cite{EXFR}
% \item \textsf{exam}, Philip Hirschhorn~\cite{EXAM}
% \item \textsf{answers}, Mike Piff and Joseph Wright~\cite{ANSW}
% \item \textsf{probsoln}, Nicola L.C.\@ Talbot~\cite{PROB}
% \item \textsf{exsol}, Walter Daems~\cite{EXSO}
% \item \textsf{exercisepoints}, Henning Kerstan~\cite{EXEP}
% \item \textsf{worksheet}, Benjamin Zöllner~\cite{WORK}
% \item \textsf{exam-n}, Norman Gray~\cite{EXAN}
% \item \textsf{eqexam}, D. P. Story~\cite{EQEX}
% \item \textsf{cesenaexam}, Alex Pacini~\cite{CESE}
% \item \textsf{esami}, Grazia Messineo, Salvatore Vassallo~\cite{ESAMI}
% \item \textsf{randexam}, Jianrui Lyu~\cite{RAND}
% ^^A\item \textsf{hideanswer}, Yukoh Kusakabe~\cite{HIDE}
% \item \textsf{exam-n}, Norman Gray~\cite{EXAMN}
% \item \textsf{mathexam}, Jan Hlavacek~\cite{MATH}
% \item \textsf{exesheet}, Antoine Missier
% \end{enumerate}
% \end{flushleft}
% \end{multicols}
%
% \newcommand\X{\ding{56}}
% \setlength{\extrarowheight}{2pt}\noindent
% {\small
% \begin{tabular}{@{\hspace{2pt}}l@{\hspace{5pt}}|%
%      *{18}{@{\hspace{1.8pt}}c@{\hspace{2pt}}|}}
% \hline
% Functionality &A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R \\
% \hline
% Optional text for exercise titles &\X&&\X&\X&\X&&&&\X&&&&\X&&&&&\X \\
% Subparts of exercises &\X&&&\X&\X&&&&\X&&\X&\X&\X&\X&\X&&&\X \\
% Annex title or appendix &&&&&&&&&&&&&&&\X&&&\X \\
% Exercise titles in TOC of PDF files &\X&&&&&&&&&&&&&&&&&\X \\
% Short labels for exercises &\X&&\X&\X&&&&&&&&&&&&&&\X \\
% Hiding questions or answers* &\X&*&\X&\X&*&\X&\X&\X&&&*&\X&&\X&*&*&&\X \\
% Different placements for answers &\X&&&&&&&&&&\X&\X&&&&&&\X \\
% Change answers placement in output &\X&&&\X&&\X&&\X&&&&\X&&&&&& \\
% Blank spacing in place of answers &&\X&\X&&\X&&&&&&&\X&&\X&\X&&\X&\X \\
% Marking scheme commands &&\X&\X&\X&\X&&&&\X&\X&\X&\X&&\X&\X&\X&&\X \\
% Various positions of points &&&&\X&\X&&&&&&&\X&&\X&&&&\X \\
% Marking scheme calculation/checking &&\X&\X&\X&\X&&&&\X&&\X&\X&&&\X&&&\X \\
% Detailed notes for scoring guide &&&&&&&&&&&&&&&&&&\X \\
% \hline
% \end{tabular}
% }
% \medskip
%
% \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}
%</class>
%    \end{macrocode}
%
% Options are defined using the \textsf{kvoptions} package.
% String options are managed through distinct processing macros 
% that are implemented in their respective sections.
% For options whose effects cannot be dynamically altered 
% and must be configured in the preamble, they are processed once, 
% at |\begin{document}|.
% The other options are executed when this package is loaded
% (at the end of the package, as |\exs@process...| 
% commands are not recognized at the outset).
%
% A distinct case is to mention with \texttt{setlist} when utilized in conjunction with
% \textsf{babel-french}.
% In this instance, this option is processed immediately
% (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*

\PackageInfo{exesheet}{The options `notoc' and `nosetlist' 
    \MessageBreak are no longer supported\@gobble}
    % \@gobble suppresses the line number here

\def\exs@process@dynoptions{
    \exs@process@output
    \exs@process@display 
    \exs@process@noteragged
} % answerspace do not need a special process macro

\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}
%
% The following old macros (used before version 2.0) provide an alternative 
% to keyval options.
% They are kept for compatibility reasons.
%    \begin{macrocode}
\newcommand{\questionsonly}{
    \PackageWarning{exesheet}{Old command \string\questionsonly\space 
        is used. \MessageBreak
        It can be replaced by the option `output=questions'}
    \renewcommand\exesheet@output{questions}
    \exs@process@output
}
\newcommand{\answersonly}{
    \PackageWarning{exesheet}{Old command \string\answersonly\space 
        is used. \MessageBreak
        It can be replaced by the option `output=answers'}
    \renewcommand\exesheet@output{answers}
    \exs@process@output
}
\newcommand{\displaypts}{%
    \PackageWarning{exesheet}{Old command \string\displaypts\space 
        is used. \MessageBreak
        It can be replaced by the option `display=pts'}
    \renewcommand\exesheet@display{pts}
    \exs@process@display
}
\newcommand{\displaypoints}{%
    \PackageWarning{exesheet}{Old command \string\displaypoints\space 
        is used. \MessageBreak
        It can be replaced by the option `display=pts'}
    \renewcommand\exesheet@display{pts}
    \exs@process@display
}
\newcommand*{\displaynotes}[1][\RaggedLeft]{%
    \PackageWarning{exesheet}{Old command \string\displaynotes\space 
        is used. \MessageBreak
        It can be replaced by the option `display=notes'}
    \renewcommand\exesheet@display{notes}
    \exs@process@display
    \renewcommand{\noteragged}{#1}
}
\newcommand*{\displaynotesright}[1][\RaggedRight]{%
    \PackageWarning{exesheet}{Old command \string\displaynotesright
        \space is used. \MessageBreak
        It can be replaced by the options `display=notes, margin=right'}
    \renewcommand\exesheet@display{notes}
    \exs@process@display
    \renewcommand\exesheet@margin{right}
    \renewcommand{\noteragged}{#1}
}

%    \end{macrocode}
%
% 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~\cite{ENUM} 
% 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~\cite{MPAR}
% is loaded exclusively for documents in \texttt{twoside} mode.
%    \begin{macrocode}
\RequirePackage{ifthen}
\@ifpackageloaded{geometry}{}{\RequirePackage{geometry}}
\RequirePackage{xcolor}
\RequirePackage[shortlabels]{enumitem}
\RequirePackage{tasks}[2020/08/19]
\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~\cite{TRAN}. 
% This package automatically detects the language being used,
% as loaded by \textsf{babel} or \textsf{polyglossia}.
%
%    \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 (\texttt{subpart}) 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@label| macro, which needs the |exe@check| counter, will be used
% inside warning messages about the marking scheme (see 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}
\newcounter{exe@check}

\newcommand{\labelexercise}{\exercisename\space \theexercise}
\newcommand{\labelexercisestyle}{}
\newcommand*{\@exercise}[1][]{%
    \refstepcounter{exercise}
    \subsection*{\labelexercisestyle\labelexercise\enskip #1}
    \ifexesheet@exetoc
        \addcontentsline{toc}{subsection}{\labelexercise}
    \fi
    \ifexesheet@checkpts
    	\setcounter{exe@check}{\value{exercise}} 
        \def\exe@label{\exercisename\space\theexe@check} 
    \fi
}
\newcommand*{\@@exercise}[2][]{%
    \subsection*{\labelexercisestyle #2\enskip #1}
    \setcounter{subpart}{0} % resets the parts counter
    \ifexesheet@exetoc
        \addcontentsline{toc}{subsection}{#2}
    \fi
    \ifexesheet@checkpts \def\exe@label{#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}
    \ifexesheet@checkpts
        \setcounter{exe@check}{\value{exercise}} 
        \def\exe@label{\exname\space\theexe@check} 
    \fi
    \par\noindent\textbf{\exlabel~\exsepmark}~}
\newcommand{\@@exe}{\bigskip\refstepcounter{exercise}
    \ifexesheet@checkpts
        \setcounter{exe@check}{\value{exercise}} 
        \def\exe@label{\exname\space\theexe@check} 
    \fi
    \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}
\newcommand\enumfont{\bfseries}

\newenvironment{exenumerate}[1][]{%
    \setlist[enumerate]{font=\enumfont}
    \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-french} package,
% \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.
% This setting is done by the |\frenchsetup| command, which should be invoked within
% the |\AtBeginDocument| command or immediately, depending on whether
% \textsf{exesheet} is loaded before or after \textsf{babel}.
%    \begin{macrocode}
\ifexesheet@setlist
    \@ifundefined{frenchsetup}{}{\frenchsetup{StandardLists=true}}
    % must be executed here (and not at begin doc) if loaded after babel
\fi

\newcommand\labelenumone{\arabic{task}.}
\newcommand\labelenuma{(\alph{task})}
\newcommand\refenuma{\alph{task}}

\def\exs@process@setlist{% must be executed at begin document
  \ifexesheet@setlist
    \@ifundefined{frenchsetup}{}{\frenchsetup{StandardLists=true}}
    % executed at begin doc if loaded before babel
    \setlist[enumerate]{font=\enumfont}
    \setlist[enumerate,1]{topsep=1.5ex plus 1ex minus 1ex,
        leftmargin=1.5em}
  \fi
%    \end{macrocode}

% \DescribeEnv{tablenum1} \DescribeEnv{tablenuma}
% The |\NewTasksEnvironment| command is part of the \textsf{tasks} package~\cite{TASK}.
% 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
    \settasks{label-format=\enumfont}
    \NewTasksEnvironment[label=\labelenumone,
        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=\labelenuma,ref=\refenuma,
        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=\labelenumone,
        column-sep=1em,label-align=right,
        label-width=1em,label-offset=0.5em,
        after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablenum1}[\item](2)
    \NewTasksEnvironment[label=\labelenuma,ref=\refenuma,
        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

\PackageInfo{exesheet}{The environment `tablenum' is deprecated 
    \MessageBreak and has been replaced by `tablenum1'\@gobble}
    % \@gobble suppresses the line number here

%    \end{macrocode}
% \DescribeEnv{tablitem}
%    \begin{macrocode}
\NewTasksEnvironment[label=\labelitemi,
    label-align=right,
    item-indent=2.5em,label-offset=0.5em,
    after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablitem}[\item](2)
   
%    \end{macrocode}
% \DescribeEnv{colsenum}\DescribeEnv{colsenum*}
% For items aligned by columns, we provide the \texttt{colsemnum} and \texttt{colsenum*}
% environments. The \textsf{multicol} package is required and an error message
% is produced if it has not been loaded.
% |\multicolsep| is the amount of space that should be added above or below the
% environment.
%    \begin{macrocode}
\newenvironment{colsenum*}[2][]{%
    \ifexesheet@multicol \else
        \PackageError{exesheet}{The environments colsenum and colsenum* 
            \MessageBreak need the multicol package}{
            Add \string\usepackage{multicol}\space in the preamble.}
    \fi
    \setlength{\multicolsep}{2ex}
    \begin{multicols}{#2} % #2 = number of columns
    \begin{enumerate}[#1] % #1 = options of enumerate
    }{
    \end{enumerate}
    \end{multicols}
}

\newenvironment{colsenum}[2][]{%
    \raggedcolumns % default is \flushcolumns
    \begin{colsenum*}[#1]{#2}
    }{
    \end{colsenum*}
}

%    \end{macrocode}
% \DescribeEnv{colsitem}\DescribeEnv{colsitem*}
% The corresponding environments for itemize lists.
%    \begin{macrocode}
\newenvironment{colsitem*}[2][]{%
    \ifexesheet@multicol \else
        \PackageError{exesheet}{The environments colsitem and colsitem* 
            \MessageBreak need the multicol package}{
            Add \string\usepackage{multicol}\space in the preamble.}
    \fi
    \setlength{\multicolsep}{2ex}
    \begin{multicols}{#2} % #2 = number of columns
    \begin{itemize}[#1] % #1 = options of itemize
    }{
    \end{itemize}
    \end{multicols}
}

\newenvironment{colsitem}[2][]{%
    \raggedcolumns % default is \flushcolumns
    \begin{colsitem*}[#1]{#2}
    }{
    \end{colsitem*}
}

%    \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}
        \exesheet@answerspacefalse
    }{% else if
    \ifthenelse{\equal{\exesheet@output}{both}}{
        \setboolean{exesheet@questions}{true}
        \setboolean{exesheet@answers}{true}
        \exesheet@answerspacefalse
    }{% 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~\cite{VERS},
% 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 have 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}\)
           \and \(\value{exe@ini} > 0 \)}{
            \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}{\value{exe@ini}}
    }{% else if
    \ifthenelse{\value{@toclevel} = 2}{%
        \subsection*{\correctionstyle\correctionname}
        \ifexesheet@exetoc
            \addcontentsline{toc}{subsection}{\correctionname}
        \fi
        \setcounter{subpart}{\value{subpart@ini}}
    }{% 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.
% It seems that the \textsf{tasks} package resets the color to black, 
% therefore the |\color{correctioncolor}| options in |\settasks|.
%    \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@setlist
                \settasks{
                    label-format = \color{correctioncolor}\enumfont,
                    item-format  = \color{correctioncolor}
                }%
            \else
                \settasks{
                    label-format = \color{correctioncolor},
                    item-format  = \color{correctioncolor}
                }%
            \fi%
            \ifexesheet@multicol
                \renewcommand{\columnseprulecolor}{%
                    \color{correctioncolor}}
            \fi%
        }{}%
    }{\comment}
}{\ifthenelse{\boolean{exesheet@answers}}{%
   \setcounter{exe@ini}{0}
   \setcounter{subpart@ini}{0}
   }{\endcomment}}

\newenvironment{answers*}{
    \ifthenelse{\boolean{exesheet@answers}}{\correctionstyle}{\comment}
}{\ifthenelse{\boolean{exesheet@answers}}{}{\endcomment}}

%    \end{macrocode}
% When placing |\correctionstyle| before |\subsubsection|
% in the \texttt{answers} environment (as in the case of |\typeset@correctionname|),
% the preceding vertical space may become too wide.
% \end{environment}
%
% \DescribeMacro{\question}\DescribeMacro{\question*}
%    \begin{macrocode}
\newcommand{\@question}[1]{\ifexesheet@questions #1\fi}
\newcommand{\@@question}[1]{%
    \ifexesheet@questions\ifexesheet@answers \else #1\fi\fi}
\newcommand{\question}{\@ifstar{\@@question}{\@question}}

%    \end{macrocode}
%
% \DescribeMacro{\answer}\DescribeMacro{\answer*}
%    \begin{macrocode}
\newcommand{\@answer}[1]{%
    \ifexesheet@answers%
        \ifexesheet@questions {\correctionstyle #1}\else #1\fi
    \fi
}
\newcommand{\@@answer}[1]{%
    \ifexesheet@answers\ifexesheet@questions \else #1\fi\fi}
\newcommand{\answer}{\@ifstar{\@@answer}{\@answer}}

%    \end{macrocode}
%
% \begin{macro}{\answerspace}
% The |\answerspace| macro leaves blank space to allow students for writing 
% their answers on the provided paper following a suggestion by Maxime Chupin.
% The blank space can expand across a page break.
%    \begin{macrocode}
\newcommand\answerspace[1]{
    \ifexesheet@answerspace \mbox{}\par\vspace*{#1} \fi}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\exs@process@correct}
% The \texttt{correct} option needs the \textsf{schooldocs} package.
% It triggers the |\correct| macro of \textsf{schooldocs} which
% adds the content of |\correctname| in the title of the document.
% Here the option \texttt{conditional} triggers |\correct| only if 
% \texttt{output=answers} or \texttt{both}.
%    \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}
%
%
% \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 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 the 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 does not correctly set 
% the default width of the margin paragraph; 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~\cite{RAGG} 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.
%
% 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.
% Percent symbols at end of lines are necessary to prevent unwanted spaces.
% |\exe@check| 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@currentlabel{none}
\newboolean{scale@valid}

\def\exe@check{%
    \ifthenelse{\lengthtest{\sum@pts = 0pt}}{%
    % do not check, no points or first exercise begins
    \ifthenelse{\equal{\exe@currentlabel}{none}}{}{%
        \PackageWarningNoLine{exesheet}{\exe@currentlabel: 
            \the\exe@total}}%
    }{%
        \ifthenelse{\lengthtest{\exe@total = \sum@pts}}{%
            \PackageWarningNoLine{exesheet}{\exe@currentlabel:
                Sum of points \the\exe@total\space is valid}%
        }{%
        \PackageWarningNoLine{exesheet}{\exe@currentlabel:
            Sum of points is \the\sum@pts\space
            instead of \the\exe@total}%
        \setboolean{scale@valid}{false}%
        }%
    }%
}

\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}
        }{}
        \global\sum@exe=0pt
        \global\exe@total=0pt
        \global\sum@pts=0pt
        \setboolean{scale@valid}{true}
        \AtEndDocument{% final checking (global)
            \ifthenelse{\equal{\exe@currentlabel}{none}}{
              \ifthenelse{\lengthtest{\sum@pts = 0pt}}{
                \PackageWarningNoLine{exesheet}{checkpts: 
                    No points displayed}
              }{
                \ifthenelse{\lengthtest{\sheet@total = \sum@pts}}{
                    \PackageWarningNoLine{exesheet}{Total:
                        Sum of points \the\sheet@total\space is valid}
                }{
                    \PackageWarningNoLine{exesheet}{Total:
                        Sum of points is \the\sum@pts\space
                        instead of \the\sheet@total}
                }}
            }{% last exercise and final checking
              \exe@check
              \ifthenelse{\lengthtest{\sum@exe} = 0pt}{
                \PackageWarningNoLine{exesheet}{checkpts: 
                    No points displayed}
                }{
                \ifthenelse{\lengthtest{\sheet@total = \sum@exe}}{
                    \PackageWarningNoLine{exesheet}{Total:
                        Sum of points \the\sheet@total\space is valid}
                }{
                    \PackageWarningNoLine{exesheet}{Total:
                        Sum of points is \the\sum@exe\space
                        instead of \the\sheet@total}
                    \setboolean{scale@valid}{false}
                }
                \ifthenelse{\boolean{scale@valid}}{
                    \PackageWarningNoLine{exesheet}{
                        Marking scheme checked without errors}
                }{
                    \PackageWarningNoLine{exesheet}{
                        Marking scheme checked with ERRORS! See above}
                }             
              }  
            }
        }
    \fi
}

%    \end{macrocode}
%
% \subsection{Marking scheme commands}
%
% The |\check@points| macro, used by |\points| and |\totalexe|, triggers
% the marking scheme control (with |\exe@check| defined above) and
% sets label and lengths for the next exercise.
%    \begin{macrocode}
\newcommand*{\check@points}[1]{%
    \ifexesheet@checkpts%
        \exe@check% checks the previous exercise
        \gdef\exe@currentlabel{\exe@label}% for the upcoming exercise 
        \global\sum@pts=0pt%
        \global\exe@total=#1pt%
        \global\advance\sum@exe by #1pt%
    \fi%        
}

%    \end{macrocode}
%
% \begin{macro}{\points}
%    \begin{macrocode}
\definecolor{pointscolor}{named}{red}
\newcommand{\pointsstyle}{%
    \small\mdseries\sffamily\color{pointscolor}\fbox}
\newcommand*{\points}[1]{%
    \ifthenelse{\boolean{exesheet@questions}}{\hfill
        \pointsstyle{#1~%
            \ifthenelse{\lengthtest{#1pt < 2pt}}{\pointname}{\pointsname}}%      
        \check@points{#1}%
    }{}
}

%    \end{macrocode}
% \end{macro}
% 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}
% \begin{macro}{\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%
            \global\advance\sum@pts by #1pt% 
        \fi%
    \fi%
    \ignorespaces
}

%    \end{macrocode}
% \end{macro}
% \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}}}}}%
        \check@points{#1}%
    \fi%
    \ignorespaces
}

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\totalsheet}
%    \begin{macrocode}
\newcommand*{\totalsheet}[1]{
    \global\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~\cite{RAGG}.
% 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%
            }{}%
        }%
        \ifexesheet@checkpts%
            \ifthenelse{\equal{#1}{}}{}{%
                \global\advance\sum@pts by #1pt%
            }%
        \fi%
    \fi%
    \ignorespaces
}
\newcommand{\@@note}[1]{%
    \ifexesheet@pts%
        \mbox{}%
        \marginpar{\noindent\hspace{0pt}\markingstyle{#1}}%
        \ifexesheet@checkpts%
            \global\advance\sum@pts by #1pt%
        \fi%
    \fi%
    \ignorespaces
}
\newcommand{\note}{\@ifstar{\@@note}{\@note}}

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\totalpoints}
%    \begin{macrocode}
\newcommand{\totalpoints}{%
    \ifthenelse{\boolean{exesheet@pts}}{\totalexe}{\points}}

%</package>
%    \end{macrocode}
% \end{macro}
%
% \hypertarget{ref}{}
% \begin{thebibliography}{27}
% % \begin{raggedright}
% \bibitem{SCHOOL} \emph{The \textsf{schooldocs} package}, Antoine Missier,
% CTAN, v1.6 2025/01/15.
% \bibitem{GEOM} \emph{The \textsf{geometry} package}, 
% Hideo Umeki, CTAN, v5.9 2020/01/02.
% \bibitem{ENUM} \emph{Customizing lists with the \textsf{enumitem} package}, 
% Javier Bezos, CTAN, v3.9 2019/06/20.
% \bibitem{TASK} \emph{\textsf{tasks} -- lists with columns filled horizontally}, 
% Clemens Niederberger. CTAN, v1.4a, 2022/01/08.
% \bibitem{VERS} \emph{The \textsf{versions} package -- Omit passages optionally 
% under \LaTeX}, Uwe Lück, CTAN, v0.55 2005/04/28.
% \bibitem{FBOX} \emph{Documentation for \texttt{fancybox.sty}: 
% Box tips and tricks for \LaTeX}, Timothy Van Zandt, CTAN, v1.4 2010/05/15.
% \bibitem{TRAN} \emph{\textsf{translations} -- Internationalization of \LaTeXe\ Packages},
% Clemens Niederberger, CTAN, v1.12 2022/02/05.
% \bibitem{RAGG} \emph{The \textsf{ragged2e-}package}, Martin Schröder,
% CTAN, v3.6 2023/06/22.
% \bibitem{MPAR} \emph{\texttt{mparhack.sty}}, Tom Sgouros, Stefan Ulrich,
% CTAN, v1.5 2021/05/02.
% \bibitem{SECT} \emph{The \textsf{sectsty} package}, Rowland McDonnell,
% CTAN, v2.0.2 2002/02/25.
% \bibitem{EXER} \emph{\texttt{exercise.sty} : a package to typeset exercises}, 
% Paul Pichaureau, CTAN, v1.6 2014/10/21.
% \bibitem{EXES} \emph{The \textsf{exercises} package}, Roger Jud,
% CTAN, v1.1 2000/05/17.
% \bibitem{XSIM} \emph{\textsf{xsim} -- eXercise Sheets IMproved --
% the official successor of the \textsf{exsheets} package}, Clemens Niederberger,
% CTAN, v0.21 2022/02/12.
% \bibitem{EXFR} \emph{The \textsf{exframe} package}, Niklas Beisert,
% CTAN, v3.4 2020/02/24.
% \bibitem{EXAM} \emph{Using the \textsf{exam} document class}, Philip Hirschhorn,
% CTAN, v2.704 2023/07/09.
% \bibitem{ANSW} \emph{\textsf{answers} Production of solution sheets in \LaTeXe}, 
% Mike Piff and Joseph Wright, CTAN, 2.16 2014/08/24.
% \bibitem{PROB} \emph{The \textsf{probsoln v3.05}: creating problem sheets
% optionally with solutions}, Nicola L.C.\@ Talbot, CTAN 2017/07/10.
% \bibitem{EXSO} \emph{The \textsf{ExSol} package}, Walter Daems,
% CTAN, 1.4 2018/10/23.
% \bibitem{EXEP} \emph{The \textsf{exercisepoints} Package}, Henning Kerstan,
% CTAN, v1.2.3 2019/01/03.
% \bibitem{WORK} \emph{\textsf{worksheet}}, Benjamin Zöllner, CTAN, v1.1 2018/08/17.
% \bibitem{EXAN} \emph{\textsf{exam-n}: exam papers}, Norman Gray, CTAN, v1.4.0 2022/10/10.
% \bibitem{EQEX} \emph{The \textsf{eqexam} Package -- part of the 
% Acro\TeX\ eDucation Bundle},
% D. P. Story, CTAN, 5.2 2021/02/26.
% \bibitem{CESE} \emph{\textsf{cesenaexam} — class file to typeset exams}, Alex Pacini,
% CTAN, v2.0 2017/08/03.
% \bibitem{ESAMI} \emph{Package \textsf{esami}}, Grazia Messineo, Salvatore Vassallo,
% CTAN, v2.8 2023/07/21.
% \bibitem{RAND} \emph{Teh \textsf{randexam} class for \LaTeX}, Jianrui Lyu,
% CTAN, 2024D, 2024/02/03.
% \bibitem{EXAMN} \emph{\textsf{exam-n}: exam papers}, Norman Gray, CTAN, v1.4.0 2022/10/10.
% \bibitem{MATH} \emph{The \textsf{mathexam} Package}, Jan Hlavacek, CTAN, v1.00 2007/07/30.
% \end{raggedright}
% \end{thebibliography}
%
% \newpage
% \hypertarget{source}{}
% \renewcommand\annexstyle{\sffamily\color{darkbrown}\MakeUppercase}
% \annex[\unskip: source code of the examples]
%
% This annex presents the source code of all the examples provided in the main document.
%
% The title is obtained with |\annex[\unskip: source code of the examples]|
% \setcounter{exercise}{0}
% \begin{multicols}{2}
%     \begin{verbatim}
% \exercise[(to begin)]
% Try this first command; easy!
%     \end{verbatim}
%     \exercise[(to begin)]
%     Try this first command; easy!
%     \columnbreak
%     \begin{verbatim}
% \exercise[\unskip*** (difficult)]
% Calculate $1+1$.
%     \end{verbatim}
%     \exercise[\unskip*** (difficult)]
%     Calculate $1+1$.
% \end{multicols}
% 
% \seprule
% \begin{verbatim}
% \exercise*[(Fermat's theorem)]{Problem}
% 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.
% \end{verbatim}
% \exercise*[(Fermat's theorem)]{Problem}
% 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.
% 
% \seprule
% \begin{verbatim}
% \exercise
% \subpart[(preliminary)]
% To begin, prepare your cup of tea.
% \subpart
% Now you are ready to proceed with the current exercise.
% \end{verbatim}
% \exercise
% \subpart[(preliminary)]
% To begin, prepare your cup of tea.
% \subpart
% Now you are ready to proceed with the current exercise.
%
% \seprule
% \begin{verbatim}
% \exe This is a brief exercise that can encompass several paragraphs 
% or questions.
% 
% Here for example a new paragraph begins.
% \exe This is another concise exercise.
% 
% \exe* Another short exercise without a separator.
% \end{verbatim}
% 
% \exe This is a brief exercise that can encompass several
% paragraphs or questions.
% 
% Here for example a new paragraph begins.
% \exe This is another concise exercise.
% 
% \exe* Another short exercise without a separator.
% 
% \seprule
% \begin{verbatim}
% \exercise
% \begin{enumerate}
%     \item First question
%     \begin{enumerate}
%         \item First sub-question
%         \item Second sub-question
%     \end{enumerate}
%     \item Second question
% \end{enumerate}
% \end{verbatim}
% 
% \begin{multicols}{2}
%     \exercise
%     \begin{enumerate}
%         \item First question
%         \begin{enumerate}
%             \item First sub-question
%             \item Second sub-question
%         \end{enumerate}
%         \item Second question
%     \end{enumerate}
% 
%     \setlist[enumerate]{font=\normalfont} ^^A local inside this multicols environment
%     \setlist[enumerate,1]{leftmargin=2.5em}
%     \setcounter{exercise}{6}
% 
%     \exercise[\normalfont(\texttt{setlist=false})]
%     \begin{enumerate}
%         \item First question
%         \begin{enumerate}
%             \item First sub-question
%             \item Second sub-question
%         \end{enumerate}
%         \item Second question
%     \end{enumerate}
% \end{multicols}
% 
% \seprule
% \begin{verbatim}
% \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}
% \end{verbatim}
% 
% \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}
% 
% \seprule
% \begin{verbatim}
% \exercise
% Calculate 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}
% \end{verbatim}
% 
% \exercise
% Calculate 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}
% 
% {
% \settasks{label-format=\normalfont}
% \RenewTasksEnvironment[label=\labelenumone,
%     column-sep=1em,label-align=right,
%     item-indent=2.5em,label-width=1em,label-offset=0.5em,
%     after-item-skip=0.5ex plus 0.5ex minus 0.5ex]{tablenum1}[\item](2)
% \RenewTasksEnvironment[label=\labelenuma,ref=\refenuma,
%     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)
% \setcounter{exercise}{7}
% \exercise[\normalfont(with \texttt{setlist=false})]
% Calculate 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}
% }
% 
% \seprule
% \begin{verbatim}
% \begin{enumerate}
%     \item \mbox{}\vspace{-5.7ex}
%     \begin{tablenuma}(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$.
%     \end{tablenuma}
% \end{enumerate}
% \end{verbatim}
% 
% \begin{enumerate}
%     \item \mbox{}\vspace{-5.7ex}
%     \begin{tablenuma}(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$.
%     \end{tablenuma}
% \end{enumerate}
% 
% \seprule
% \begin{verbatim}
% \exercise
% Calculate 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}
% \end{verbatim}
% 
% \exercise
% Calculate 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}
% 
% \exercise[\normalfont(the same with \texttt{colsenum*})]
% Calculate 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*}
% 
% \seprule
% \begin{verbatim}
% \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 The \textsf{exesheet} package is 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,
%         \textsf{eqexam} by D. P. Story\ldots
%         They are briefly presented in section 6.3.
%     \end{enumerate}
% \end{answers}
% \end{verbatim}
% 
% \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 The \textsf{exesheet} package is 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,
%         \textsf{eqexam} by D. P. Story\ldots
%         They are briefly presented in section 6.3.
%     \end{enumerate}
% \end{answers}
% 
% \seprule
% \begin{verbatim}
% \exercise[\points{5}]
% Try to read this document to the end without drinking tea and you get five 
% points.
% \end{verbatim}
% 
% \exercise[\points{5}]
% Try to read this document to the end without drinking tea and you get five points.
% 
% \seprule
% \begin{verbatim}
% \exe \pts{3} The first short exercise with a marking scheme.
% \exe \pts{1.5} The second one.
% \end{verbatim}
% 
% \exe \pts{3} The first short exercise with a marking scheme.
% \exe \pts{1.5} The second one.
% 
% \seprule
% \begin{verbatim}
% \newcommand{\ds}{\displaystyle}
% \exercise[\totalexe{4}]
% \begin{questions}
%     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=\ln2$,
%         \item $\ds\int_{2}^{\mathrm{e}}\frac{1}{x\ln x}\,\mathrm{d}x=-\ln2$,
%         \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}
% \end{verbatim}
% 
% \exercise[\totalexe{4}]
% \begin{questions}
%     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=\ln2$,
%         \item $\ds\int_{2}^{\mathrm{e}}\frac{1}{x\ln x}\,\mathrm{d}x=-\ln2$,
%         \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}
% \Finale
\endinput
