From 281750fb8dba664cd4b7e2ae4da626a83bc79d73 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 19 Sep 2015 20:46:08 +0000 Subject: exercises (19sep15) git-svn-id: svn://tug.org/texlive/trunk@38408 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/exercises/README.md | 23 + .../texmf-dist/doc/latex/exercises/exercises.pdf | Bin 0 -> 414151 bytes .../source/latex/exercises/exercises.dtx | 938 +++++++++++++++++++++ .../source/latex/exercises/exercises.ins | 55 ++ .../texmf-dist/tex/latex/exercises/exercises.sty | 200 +++++ 5 files changed, 1216 insertions(+) create mode 100644 Master/texmf-dist/doc/latex/exercises/README.md create mode 100644 Master/texmf-dist/doc/latex/exercises/exercises.pdf create mode 100644 Master/texmf-dist/source/latex/exercises/exercises.dtx create mode 100644 Master/texmf-dist/source/latex/exercises/exercises.ins create mode 100644 Master/texmf-dist/tex/latex/exercises/exercises.sty (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/exercises/README.md b/Master/texmf-dist/doc/latex/exercises/README.md new file mode 100644 index 00000000000..037dc5c6c3d --- /dev/null +++ b/Master/texmf-dist/doc/latex/exercises/README.md @@ -0,0 +1,23 @@ +This is the distribution directory for exercises, a LaTeX package to typeset exercices and solutions. +The package allows you to customize the layout of those environments. +The optional points in exercises can be added automatically. In addition you’re able to hide the solutions. + +This is exercises version 1.0, 19 September 2015. exercises is distributed +under the LaTeX Project Public License (LPPL). + + +*** Source files: + +exercises.sty The style file +exercises.dtx The documentation file +exercises.ins The installation file + + +*** Formatted versions of the documentation: + +exercises.pdf + + +Roger Jud (rogerjud@outlook.com) + + diff --git a/Master/texmf-dist/doc/latex/exercises/exercises.pdf b/Master/texmf-dist/doc/latex/exercises/exercises.pdf new file mode 100644 index 00000000000..646c3a38beb Binary files /dev/null and b/Master/texmf-dist/doc/latex/exercises/exercises.pdf differ diff --git a/Master/texmf-dist/source/latex/exercises/exercises.dtx b/Master/texmf-dist/source/latex/exercises/exercises.dtx new file mode 100644 index 00000000000..d818e495e6d --- /dev/null +++ b/Master/texmf-dist/source/latex/exercises/exercises.dtx @@ -0,0 +1,938 @@ +% \iffalse meta-comment +% +% Copyright (C) 2015 by Roger Jud +% ------------------------------------------------------- +% +% This file may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.2 +% 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.2 or later is part of all distributions of LaTeX +% version 1999/12/01 or later. +% +% \fi +% +% \iffalse +%\NeedsTeXFormat{LaTeX2e}[1999/12/01] +%\ProvidesPackage{exercises}[2015/09/19 v1.0 .dtx exercises file] +% +%<*driver> +\documentclass[a4paper]{ltxdoc} +\usepackage{doctools} +\usepackage{hyperref} +\hypersetup{colorlinks,% +citecolor=black,% +filecolor=black,% +linkcolor=black,% +urlcolor=black,% +} +\usepackage[printsolution=true]{exercises}[2015/09/19] +\usepackage[utf8]{inputenc} +\usepackage[english]{babel} +\usepackage{amsmath} +\usepackage{units} +\usepackage{xcolor} +\usepackage[toc]{multitoc} +\usepackage[T1]{fontenc} +\usepackage[mono=false]{libertine} +\usepackage[scaled=0.8]{DejaVuSansMono} +\setlength{\parindent}{0pt} +\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\begin{document} + \DocInput{exercises.dtx} +\end{document} +% +% \fi +% +% \CheckSum{0} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% +% \changes{v1.0}{2015/09/19}{Initial version} +% +% \GetFileInfo{exercises.sty} +% +% \DoNotIndex{\newcommand,\newenvironment} +% +% +% \title{The \textsf{exercises} package\thanks{This document +% corresponds to \textsf{exercises}~\fileversion, dated \filedate.}} +% \author{Roger Jud \\ \texttt{rogerjud@outlook.com}} +% +% \maketitle +% +% +% +% +% +% \begin{abstract} +% The package |exercises| defines the environments |exercise| and |solution|. They can be used to typeset exercices and solutions. The package allows you to customize the layout of those environments. The optional points in exercises can be added automatically. In addition you're able to hide the solutions. +% \end{abstract} +% +% \tableofcontents +% +% +% \newpage +% +% +% \section{Usage} +% Install the package and put |\usepackage{exercises}| in your preamble. Notice that |exercises| loads |verbatim|, |ifthen|, |kvoptions| and |xparse|. If you have already loaded these packages using |\usepackage{verbatim, ifthen, ...}|, you should unload these therefore. +% +% Now you are able to use the environments |exercise| and |solution|. The two following sections show some code examples and the corresponding output. This is followed by some explanations and a list of all the options. +% +% +% \subsection{Basic example} +% +% The following example shows the basic usage of the two environmets. There are two exercises and two solutions. Notice that the exercises and the solutions are automatically numbered. +% +% It is important to put |printsolution=true| as an option of the package, because otherwise the solutions won't be printed. (The default value is |false|.) +% +% \iffalse +%<*example> +% \fi +\begin{latexcode} +\usepackage[printsolution=true]{exercises} + +\begin{exercise} + Calculate $1 + 1 =$ +\end{exercise} + +\begin{solution} + The result is $1 + 1 = 2$ +\end{solution} + +\begin{exercise} + Is this $2 + 3 = 6$ true or false. Give a reason why. +\end{exercise} + +\begin{solution} + It is false, because $2 + 3 = 5$ +\end{solution} +\end{latexcode} +% \iffalse +% +% \fi +% +% \emph{produces} +% +% \begin{exercise} +% Calculate $1 + 1 =$ +% +% +% \end{exercise} +% +% \begin{solution} +% The result is $1 + 1 = 2$ +% +% +% \end{solution} +% +% \begin{exercise} +% Is this $2 + 3 = 6$ true or false. Give a reason why. +% \end{exercise} +% +% \begin{solution} +% It is false, because $2 + 3 = 5$ +% \end{solution} +% +% +% +% \subsection{Optional arguments} +% +% The |exercise|-environment has a optional argument -- the points. The |solution|-environment has also a optional argument -- the space which is left blank, if the solutions are hidden. +% +% \iffalse +%<*example> +% \fi +\begin{latexcode} +\usepackage[printsolution=true]{exercises} + +\begin{exercise}[2] + Calculate $1 + 1 =$ +\end{exercise} + +\begin{solution}[3cm] + The result is $1 + 1 = 2$ +\end{solution} + +\begin{exercise}[2] + Is this $2 + 3 = 6$ true or false. Give a reason why. +\end{exercise} + +\begin{solution}[2cm] + It is false, because $2 + 3 = 5$ +\end{solution} +\end{latexcode} +% \iffalse +% +% \fi +% +% \emph{produces} +% +% \begin{exercise}[1] +% Calculate $1 + 1 =$ +% \end{exercise} +% +% \begin{solution}[3cm] +% The result is $1 + 1 = 2$ +% \end{solution} +% +% +% \begin{exercise}[2] +% Is this $2 + 3 = 6$ true or false. Give a reason why. +% \end{exercise} +% +% \begin{solution}[2cm] +% It is false, because $2 + 3 = 5$ +% \end{solution} +% +% +% +% \subsection{Sum of points} +% +% The points of all exercises are added. The command \cs{totalpoints} can be used to print the sum of the points. The word |Pt.| will be added automatically. You can customize it using the package option |totalpointsname=|\meta{string}. (See also the following section.) +% +% \iffalse +%<*example> +% \fi +\begin{latexcode} +Sum of points: \totalpoints +\end{latexcode} +% \iffalse +% +% \fi +% +% \emph{produces} +% +% Sum of points: \totalpoints +% +% +% +% +% +% +% +% +% \section{Options} +% This package uses the key-value-format for the package options. You can choose them while loading the package. +% +% \cs{usepackage}\oarg{option}|{exercises}| +% +% The following options are available: +% \begin{itemize} +% \item |printsolution=|\meta{boolean}: +% \begin{itemize} +% \item |printsolution=false| \emph{(default)}\hspace{0.5em} The content between |\begin{solution}| and |\end{solution}| is not printed. +% \item |printsolution=true|\hspace{2ex} The solutions are printed. +% \end{itemize} +% \item |exercisespaceabove=|\meta{length} \hspace{0.5em} Space above the |exercise|-environment. \newline \hspace*{0.5em} \emph{default value:} \unit[2.0]{ex} plus \unit[1.0]{ex} minus \unit[0.5]{ex} +% \item |exercisespacebelow=|\meta{length} \hspace{0.5em} Space below the |exercise|-environment. \newline \hspace*{0.5em} \emph{default value:} \unit[1.5]{ex} plus \unit[1.0]{ex} minus \unit[0.5]{ex} +% \item |solutionspaceabove=|\meta{length} \hspace{0.5em} Space above the |solution|-environment. \newline \hspace*{0.5em} \emph{default value:} \unit[2.0]{ex} plus \unit[1.0]{ex} minus \unit[0.5]{ex} +% \item |solutionspacebelow=|\meta{length} \hspace{0.5em} Space below the |solution|-environment. \newline \hspace*{0.5em} \emph{default value:} \unit[1.5]{ex} plus \unit[1.0]{ex} minus \unit[0.5]{ex} +% \item |blockspace=|\meta{length} \hspace{0.5em} Space below |exercisename| respectively |solutionname|, if |exercisenameposition| respectively |solutionnameposition| is set to |block|. \newline \hspace*{0.5em} \emph{default value:} \unit[0.25]{ex} +% \item |inlinespace=|\meta{length} \hspace{0.5em} Space after |exercisename| respectively |solutionname|, if |exercisenameposition| respectively |solutionnameposition| is set to |inline|. \newline \hspace*{0.5em} \emph{default value:} \unit[0.5]{em} +% \item |exercisenumberformat=|\meta{string} \hspace{0.5em} It defines the number format for the numbering of the exercises and the solutions. You can choose from the following: +% \begin{itemize} +% \item |exercisenumberformat=arabic| \emph{(default)}\hspace{0.5em} arabic numbers +% \item |exercisenumberformat=roman| \hspace{0.5em} small roman numbers +% \item |exercisenumberformat=Roman| \hspace{0.5em} large roman numbers +% \item |exercisenumberformat=alph| \hspace{0.5em} small latin letters +% \item |exercisenumberformat=Alph| \hspace{0.5em} large latin letters +% \end{itemize} +% \item |pointsposition=|\meta{string}\hspace{0.5em} If you use points for the |exercise|-Environment, you can tell the package where to put them. You can choose from the following: +% \begin{itemize} +% \item |pointsposition=aftername| \emph{(default)} \hspace{0.5em} after the double point (Exercise 1: (3 Pt.)) +% \item |pointsposition=margin| \hspace{0.5em} at the right margin +% \end{itemize} +% \item |pointsfontsize=|\meta{string} \hspace{0.5em} You can shoose between two fontsizes for the points: +% \begin{itemize} +% \item |pointsfontsize=normalsize| \emph{(default)} \hspace{0.5em} normal fontsize (like \cs{normalsize}) +% \item |pointsfontsize=footnotesize| \hspace{0.5em} smaller fontsize (like \cs{footnotesize}) +% \end{itemize} +% \item |pointsname=|\meta{string} \hspace{0.5em} You can select which text is displayed after the points of an exercise. \emph{(default: Pt.)} +% \item |exercisename=|\meta{string} \hspace{0.5em} You can select which text is displayed at the beginning of an exercise. \emph{(default: Exercise)} +% \item |exercisenameposition=|\meta{string} \hspace{0.5em} There are two ways to position the |exercisename|: +% \begin{itemize} +% \item |exercisenameposition=block| \emph{(default)} \hspace{0.5em} There is a line break after |exercisename| and optionally an additional vertical space (|blockspace|). +% \item |exercisenameposition=inline| \hspace{0.5em} There is only a horizontal space (|inlinespace|) after |exercisename|. +% \end{itemize} +% \item |solutionname=|\meta{string} \hspace{0.5em} You can select which text is displayed at the beginning of a solution. \emph{(default: Solution)} +% \item |solutionnameposition=|\meta{string} \hspace{0.5em} There are two ways to position the |solutionname|: +% \begin{itemize} +% \item |solutionnameposition=block|: \emph{(default)} \hspace{0.5em} There is a line break after |solutionname| and optionally an additional vertical space (|blockspace|). +% \item |solutionnameposition=inline| \hspace{0.5em} There is only a horizontal space (|inlinespace|) after |solutionname|. +% \end{itemize} +% \item |totalpointsname=|\meta{string} \hspace{0.5em} You can select which text is displayed after the points using the command \cs{totalpoints}. \emph{(default: Pt.)} +% \item |braces=|\meta{string} \hspace{0.5em} You can choose between three types of braces embracing the points of an exercise: +% \begin{itemize} +% \item |braces=nobraces| \hspace{0.5em} no braces +% \item |braces=round| \emph{(default)} \hspace{0.5em} round braces like (1 Pt.) +% \item |braces=square| \hspace{0.5em} square braces like [1 Pt.] +% \end{itemize} +% \item |starpoints=|\meta{boolean}: +% \begin{itemize} +% \item |starpoints=false| \emph{(default)} \hspace{0.5em} The points are printed as normal arabic numbers. +% \item |starpoints=true| \hspace{0.5em} Stars (for exmaple **** for five points) are printed instead of numbers. +% \end{itemize} +% \end{itemize} +% +% +% \section{Special commands} +% +% \subsection{Sum of points} +% You can print the sum of points anywhere in the document using \cs{totalpoints}. \LaTeX{} needs two runs to calculate the sum. +% +% +% \subsection{Special page breaks} +% Custom page breaks using \cs{newpage} will move depending on wether or not to print the solutions. Because of that two new commands are available. +% +% \cs{exercisenewpage} inserts only a page break if |printsolution=false|, so if the solutions are \emph{not} printed. \cs{solutionnewpage} -- on the other hand -- inserts a page break if |printsolution=true|, so if the solutions are printed. +% +% +% +% +% +% +% +% +% \StopEventually{\PrintChanges} +% +% \section[Implementation]{Implementation -- how I've done it (only in German)} +% +% \subsection{Benötigte Pakete} +% +% Zuerst lade ich alle benötigten Pakete. Das Paket |verbatim| benutze ich, um die Lösungen mit den Befehlen |\comment| und |\endcomment| auszukommentieren. +% \begin{macrocode} +\RequirePackage{verbatim} +% \end{macrocode} +% Das Paket |ifthen| hilft mit Befehlen wie |\ifthenelse|, |\equal|, |\boolean| und anderen. +% \begin{macrocode} +\RequirePackage{ifthen} +% \end{macrocode} +% Um eine Komma-separierte Liste von \meta{key}=\meta{value}-Optionen erstellen zu können, benötige ich das Paket |kvoptions|. +% \begin{macrocode} +\RequirePackage{kvoptions} +% \end{macrocode} +% Das Paket |xparse| erlaubt mir das erstellen von Befehlen und Umgebungen mit mehreren (optionalen) Argumenten. +% \begin{macrocode} +\RequirePackage{xparse} +% \end{macrocode} +% Das Paket |marginnote| erlaubt mir die Erstellung von Bemerkungen am Rand. Ich benutze dieses Pakte anstelle des Befehls |marginpar|, weil |marginpar| die Notiz manchmal auf einer Seite platziert. (Paket-Warnung: marginpar on page xy moved.) +% \begin{macrocode} +\RequirePackage{marginnote} +% \end{macrocode} +% +% In einem ersten Schritt weise ich den Wert \meta{family} (am besten der Name des Pakets) sowie \meta{prefix} (das Präfix, welches vor jeden Variabelnnamen gesetzt wird) zu. Weitere Informationen können der Dokumentation von |kvoptions| entnommen werden. +% \begin{macrocode} +\SetupKeyvalOptions{ + family=exercises, + prefix=exercises@} +% \end{macrocode} +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% \subsection{Paket-Optionen definieren} +% +% Jetzt definiere und initialisiere ich alle Paket-Optionen. Wenn der Benutzer keine Option wählt, wir der Standard-Wert (in eckigen Klammern) benutzt. Dann benutze ich den Befehl |\ProcessKeyvalOptions| um die Optionen dem Paket |exercises| zugänglich zu machen. +% \begin{macrocode} +\DeclareBoolOption{printsolution} +\DeclareStringOption[2.0ex plus 1.0ex minus 0.5ex]{exercisespaceabove} +\DeclareStringOption[1.5ex plus 1.0ex minus 0.5ex]{exercisespacebelow} +\DeclareStringOption[2.0ex plus 1.0ex minus 0.5ex]{solutionspaceabove} +\DeclareStringOption[1.5ex plus 1.0ex minus 0.5ex]{solutionspacebelow} +\DeclareStringOption[0.25ex]{blockspace} +\DeclareStringOption[0.5em]{inlinespace} +\DeclareStringOption[arabic]{exercisenumberformat} +\DeclareStringOption[aftername]{pointsposition} +\DeclareStringOption[normalsize]{pointsfontsize} +\DeclareStringOption[Pt.]{pointsname} +\DeclareStringOption[Exercise]{exercisename} +\DeclareStringOption[block]{exercisenameposition} +\DeclareStringOption[Solution]{solutionname} +\DeclareStringOption[block]{solutionnameposition} +\DeclareStringOption[Pt.]{totalpointsname} +\DeclareStringOption[round]{braces} +\DeclareBoolOption[false]{starpoints} +\ProcessKeyvalOptions{exercises} +% \end{macrocode} +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% \subsection{Formatierung der Nummerierung} +% +% Ich \DescribeMacro{\exercises@formatnumbers}\ definiere einen Befehl um die Nummerierung der Übungen zu formatieren. +% +% Wird für die Option \meta{exercisenumberformat} \meta{arabic} verwendet, so wird |\exercises@formatnumbers| so definiert, dass die Nummerierung als arabische Ziffern ausgegeben wird. +% \begin{macrocode} +\ifthenelse{\equal{\exercises@exercisenumberformat}{arabic}}% + {\newcommand{\exercises@formatnumbers}[1]{\arabic{#1}}}{}% +% \end{macrocode} +% +% Wird für die Option \meta{exercisenumberformat} \meta{roman} verwendet, so wird |\exercises@formatnumbers| so definiert, dass die Nummerierung als kleine römische Ziffern ausgegeben wird. +% \begin{macrocode} +\ifthenelse{\equal{\exercises@exercisenumberformat}{roman}}% + {\newcommand{\exercises@formatnumbers}[1]{\roman{#1}}}{}% +% \end{macrocode} +% +% Wird für die Option \meta{exercisenumberformat} \meta{Roman} verwendet, so wird |\exercises@formatnumbers| so definiert, dass die Nummerierung als grosse römische Ziffern ausgegeben wird. +% \begin{macrocode} +\ifthenelse{\equal{\exercises@exercisenumberformat}{Roman}}% + {\newcommand{\exercises@formatnumbers}[1]{\Roman{#1}}}{}% +% \end{macrocode} +% +% Wird für die Option \meta{exercisenumberformat} \meta{alph} verwendet, so wird |\exercises@formatnumbers| so definiert, dass die Nummerierung als Buchstaben ausgegeben wird. +% \begin{macrocode} +\ifthenelse{\equal{\exercises@exercisenumberformat}{alph}}% + {\newcommand{\exercises@formatnumbers}[1]{\alph{#1}}}{}% +% \end{macrocode} +% +% Wird für die Option \meta{exercisenumberformat} \meta{Alph} verwendet, so wird |\exercises@formatnumbers| so definiert, dass die Nummerierung als grosse Buchstaben ausgegeben wird. +% \begin{macrocode} +\ifthenelse{\equal{\exercises@exercisenumberformat}{Alph}}% + {\newcommand{\exercises@formatnumbers}[1]{\Alph{#1}}}{}% +% \end{macrocode} +% +% Wird für die Option \meta{exercisenumberformat} weder \meta{arabic} noch \meta{roman} noch \meta{Roman} noch \meta{alph} noch \meta{Alph} verwendet, so wird eine Fehlermeldung ausgegeben und \meta{exercisenumberformat} auf \meta{arabic} gesetzt. +% \begin{macrocode} +\ifthenelse{\not\equal{\exercises@exercisenumberformat}{arabic}% + \and \not\equal{\exercises@exercisenumberformat}{roman}% + \and \not\equal{\exercises@exercisenumberformat}{Roman}% + \and \not\equal{\exercises@exercisenumberformat}{alph}% + \and \not\equal{\exercises@exercisenumberformat}{Alph}}% + {\PackageError{exercises}% + {"\exercises@exercisenumberformat" ist als Option von "exercisenumberformat" nicht erlaubt. % + Stattdessen wurde "arabic" verwendet.}% + {"\exercises@exercisenumberformat" ist als Option von "exercisenumberformat" nicht erlaubt. % + Stattdessen wurde "arabic" verwendet.}% + \newcommand{\exercises@formatnumbers}[1]{\arabic{#1}}}{}% +% \end{macrocode} +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% \subsection{Positionierung der Überschriften} +% +% \begin{macrocode} +\ifthenelse{\equal{\exercises@exercisenameposition}{block}}% + {\newcommand{\exercises@placeexercise}{\noindent\par\vspace{\exercises@blockspace}}}{}% +% \end{macrocode} +% +% +% +% \begin{macrocode} +\ifthenelse{\equal{\exercises@exercisenameposition}{inline}}% + {\newcommand{\exercises@placeexercise}{\hspace{\exercises@inlinespace}}}{}% +% \end{macrocode} +% +% +% +% \begin{macrocode} +\ifthenelse{\not\equal{\exercises@exercisenameposition}{block}% + \and \not\equal{\exercises@exercisenameposition}{inline}}% + {\PackageError{exercises}% + {"\exercises@exercisenameposition" ist als Option von "exercisenameposition" nicht erlaubt. % + Stattdessen wurde "block" verwendet.}% + {"\exercises@exercisenameposition" ist als Option von "exercisenameposition" nicht erlaubt. % + Stattdessen wurde "block" verwendet.} + \newcommand{\exercises@placeexercise}{\noindent\par\vspace{\exercises@blockspace}}}{}% +% \end{macrocode} +% +% +% +% \begin{macrocode} +\ifthenelse{\equal{\exercises@solutionnameposition}{block}}% + {\newcommand{\exercises@placesolution}{\noindent\par\vspace{\exercises@blockspace}}}{}% +% \end{macrocode} +% +% +% +% \begin{macrocode} +\ifthenelse{\equal{\exercises@solutionnameposition}{inline}}% + {\newcommand{\exercises@placesolution}{\hspace{\exercises@inlinespace}}}{}% +% \end{macrocode} +% +% +% +% \begin{macrocode} +\ifthenelse{\not\equal{\exercises@solutionnameposition}{block}% + \and \not\equal{\exercises@solutionnameposition}{inline}}% + {\PackageError{exercises}% + {"\exercises@solutionnameposition" ist als Option von "solutionnameposition" nicht erlaubt. % + Stattdessen wurde "block" verwendet.}% + {"\exercises@solutionnameposition" ist als Option von "solutionnameposition" nicht erlaubt. % + Stattdessen wurde "block" verwendet.}% + \newcommand{\exercises@placesolution}{\noindent\par\vspace{\exercises@blockspace}}}{}% +% \end{macrocode} +% +% +% +% +% +% +% +% +% +% +% +% +% \subsection{Positionierung der Punktzahlen} +% +% Nun\DescribeMacro{\exercises@placepoints}\ werden die Befehle zur Positionierung der Punkte (falls vorhanden) definiert. Falls für die Option \meta{pointsplace} keine der Werte \meta{aftername} (Position der Punkte rechts des Doppelpunktes nach \emph{Exercise}) oder \meta{margin} (am rechten Rand) verwendet wird, gibt das Paket eine Fehlermeldung aus und verwendet die Option \meta{aftername}. +% +% Wird für die Option \meta{aftername} verwendet, so wird |\exercises@placepoints| so definiert, dass lediglich die Punktzahl ausgegeben wird. +% \begin{macrocode} +\ifthenelse{\equal{\exercises@pointsposition}{aftername}}% + {\newcommand{\exercises@placepoints}[1]{ #1}}{}% +% \end{macrocode} +% +% Wird für die Option \meta{margin} verwendet, so wird |\exercises@placepoints| so definiert, dass die Punktzahl mit Hilfe von |\marginnote| am rechten Rand ausgegeben wird. +% \begin{macrocode} +\ifthenelse{\equal{\exercises@pointsposition}{margin}}% + {\newcommand{\exercises@placepoints}[1]% + {\marginnote{#1}}}{}% +% \end{macrocode} +% +% Wird für die Option \meta{pointsposition} weder \meta{aftername} noch \meta{margin} verwendet, so wird eine Fehlermeldung ausgegeben und \meta{pointsposition} auf \meta{aftername} gesetzt. +% \begin{macrocode} +\ifthenelse{\not\equal{\exercises@pointsposition}{aftername}% + \and \not\equal{\exercises@pointsposition}{margin}}% + {\PackageError{exercises}% + {"\exercises@pointsposition" ist als Option von "pointsposition" nicht erlaubt. % + Stattdessen wurde "aftername" verwendet.}% + {"\exercises@pointsposition" ist als Option von "pointsposition" nicht erlaubt. % + Stattdessen wurde "aftername" verwendet.}% + \newcommand{\exercises@placepoints}[1]{ #1}}{}% +% \end{macrocode} +% +% +% +% +% +% +% +% +% + +% +% \subsection{Formatierung der Punktzahlen} +% +% \begin{macrocode} +\ifthenelse{\equal{\exercises@pointsfontsize}{normalsize}}% + {\newcommand{\exercises@formatpoints}[1]{\normalsize #1}}{}% +% \end{macrocode} +% +% \begin{macrocode} +\ifthenelse{\equal{\exercises@pointsfontsize}{footnotesize}}% + {\newcommand{\exercises@formatpoints}[1]{\footnotesize #1 \normalsize}}{}% +% \end{macrocode} +%% +% \begin{macrocode} +\ifthenelse{\not\equal{\exercises@pointsfontsize}{normalsize}% + \and \not\equal{\exercises@pointsfontsize}{footnotesize}}% + {\PackageError{exercises}% + {"\exercises@pointsfontsize" ist als Option von "pointsfontsize" nicht erlaubt. % + Stattdessen wurde "normalsize" verwendet.}% + {"\exercises@pointsfontsize" ist als Option von "pointsfontsize" nicht erlaubt. % + Stattdessen wurde "normalsize" verwendet.}% + \newcommand{\exercises@formatpoints}[1]{\normalsize #1}}{}% +% \end{macrocode} +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% \subsection{Klammern formatieren} +% +% Nun\DescribeMacro{\exercises@braces}\ werden die Befehle zur Ausgabe der Klammern (falls vorhanden) definiert. Falls für die Option \meta{braces} keine der Werte \meta{nobraces}, \meta{round} oder \meta{square} verwendet wird, gibt das Paket eine Fehlermeldung aus und verwendet die Option \meta{round}. +% +% Wird für die Option \meta{braces} \meta{nobraces} verwendet, so wird |\exercises@braces| so definiert, dass keine Klammern ausgegeben werden. +% \begin{macrocode} +\ifthenelse{\equal{\exercises@braces}{nobraces}}% + {\newcommand{\exercises@openbrace}{}% + \newcommand{\exercises@closebrace}{}}{}% +% \end{macrocode} +% +% Wird für die Option \meta{braces} \meta{round} verwendet, so wird |\exercises@braces| so definiert, dass runde Klammern ausgegeben werden. +% \begin{macrocode} +\ifthenelse{\equal{\exercises@braces}{round}}% + {\newcommand{\exercises@openbrace}{(}% + \newcommand{\exercises@closebrace}{)}}{}% +% \end{macrocode} +% +% Wird für die Option \meta{braces} \meta{square} verwendet, so wird |\exercises@braces| so definiert, dass eckige Klammern ausgegeben werden. +% \begin{macrocode} +\ifthenelse{\equal{\exercises@braces}{square}}% + {\newcommand{\exercises@openbrace}{[}% + \newcommand{\exercises@closebrace}{]}}{}% +% \end{macrocode} +% +% Wird für die Option \meta{braces} weder \meta{nobraces} noch \meta{round} noch \meta{square} verwendet, so wird eine Fehlermeldung ausgegeben und \meta{braces} auf \meta{round} gesetzt. +% \begin{macrocode} +\ifthenelse{\not\equal{\exercises@braces}{nobraces}% + \and \not\equal{\exercises@braces}{round}% + \and \not\equal{\exercises@braces}{square}}% + {% + \PackageError{exercises}% + {"\exercises@braces" ist als Option von "braces" nicht erlaubt. % + Stattdessen wurde "round" verwendet.}% + {"\exercises@braces" ist als Option von "braces" nicht erlaubt. % + Stattdessen wurde "round" verwendet.}% + \newcommand{\exercises@openbrace}{(}% + \newcommand{\exercises@closebrace}{)}% + }{}% +% \end{macrocode} +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% \subsection{Definition von Zählern} +% +% Nun werden die Zähler zur Nummerierung der Aufgaben (\meta{exercises@exercisenumber}) und Lösungen (\meta{exercises@solutionnumber}) sowie zur Zählung der Punkte (\meta{exercises@totalpoints} und \meta{exercises@finaltotalpoints}) definiert und initialisiert. +% \begin{macrocode} +\newcounter{exercises@totalpoints} +\setcounter{exercises@totalpoints}{0} +\newcounter{exercises@finaltotalpoints} +\newcounter{exercises@exercisenumber} +\setcounter{exercises@exercisenumber}{1} +\newcounter{exercises@solutionnumber} +\setcounter{exercises@solutionnumber}{1} +\newcounter{i} +\newlength{\exercises@parskipsave} +% \end{macrocode} +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% \subsection{Umgebung \texttt{exercise}} +% +%\begin{macro}{exercise} +% Der eigentliche Code folgt nun. Die Umgebung |exercise| definiert ein optionales Argument (die Punktzahl). +% \begin{macrocode} +\DeclareDocumentEnvironment{exercise}{o}{% +\setlength{\exercises@parskipsave}{0cm} +\setlength{\exercises@parskipsave}{\parskip} +\setlength{\parskip}{0cm} +% \end{macrocode} +% +% Der obere Abstand wird eingefügt. +% \begin{macrocode} + \vspace{\exercises@exercisespaceabove}% +% \end{macrocode} +% +% Ist das optionale Argument leer (|\IfNoValueTF| also wahr), wird lediglich \meta{exercisename} (standarmässig Exercise) sowie \meta{exercisenumber} ausgegeben. +% \begin{macrocode} + \IfNoValueTF{#1}% + {\textbf{\exercises@exercisename\ \exercises@formatnumbers{exercises@exercisenumber}:}\exercises@placeexercise}% +% \end{macrocode} +% +% Ist das optionale Argument vorhanden (|\IfNoValueTF| also nicht wahr), wird zuerst \meta{totalpoints} um die Punktzahel erhöht und anschliessend \meta{exercisename} sowie \meta{exercisenumber} ausgegeben. +% \begin{macrocode} + {\addtocounter{exercises@totalpoints}{#1}% + \textbf{\exercises@exercisename\ \exercises@formatnumbers{exercises@exercisenumber}:}% +% \end{macrocode} +% +% Falls \meta{starpoints} wahr ist, wird eine Schleife zur Ausgabe der Sterne -- entsprechend der Anzahl Punkt -- gestartet. +% \begin{macrocode} + \ifthenelse{\boolean{exercises@starpoints}}% + {\exercises@placepoints{\exercises@openbrace% + \setcounter{i}{0}\whiledo{#1>\thei}{*\stepcounter{i}}% + \exercises@closebrace}}% +% \end{macrocode} +% +% Ist \meta{starpoints} nicht wahr ist, wird die Punktzahl ausgegeben. +% \begin{macrocode} + {\exercises@placepoints{\exercises@formatpoints{\exercises@openbrace#1 \exercises@pointsname\exercises@closebrace}}}\exercises@placeexercise% + }% +\setlength{\parskip}{\exercises@parskipsave}% +}{% +\setlength{\parskip}{0cm}% +% \end{macrocode} +% \end{macro} +% +% Der Zähler \meta{exercisenumber} wird um 1 hochgezählt und der untere Abstand wird eingefügt. +% \begin{macrocode} + \stepcounter{exercises@exercisenumber}% + \vspace{\exercises@exercisespacebelow}% +\setlength{\parskip}{\exercises@parskipsave}% +}% +% \end{macrocode} +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% \subsection{Berechnung und Ausgabe der Gesamtpunktzahl} +% +% \begin{macro}{\totalpoints} +% Der Befehle |\totalpoints| zur Ausgabe der Gesamtpunktzahl im Dokument wird definiert. Es wird eine Referenz auf den Zähler \meta{exercises@finaltotalpoints} erstellt, welcher am Ende des Dokuments mit Hilfe von |\AtEndDocument| in die |aux|-Datei geschrieben wird. +% \begin{macrocode} +\newcommand\totalpoints{\theexercises@finaltotalpoints\ \exercises@totalpointsname}% +% \end{macrocode} +% +% |\immediate\write\@auxout| sorgt dafür, dass der String |\setcounter{exercises@finaltotalpoints}{\theexercises@totalpoints}| in die |aux|-Datei geschrieben wird. So wird dem Zähler \meta{exercises@finaltotalpoints} der Wert von \meta{exercises@totalpoints} übergeben. Die direkte Speicherung von \meta{exercises@totalpoints} in der |aux|-Datei ist nicht möglich, denn dann würde bei einem \LaTeX\-Lauf folgendes passieren: +% \begin{enumerate} +% \item Das Paket |exercises| wird geladen und \meta{exercises@totalpoints} wird mit 0 initialisiert. +% \item Bei |\begin{document}| wird die |aux|-Datei gelesen. Beim ersten Lauf ändert sich \meta{exercises@totalpoints} nicht. +% \item Zu \meta{exercises@totalpoints} werden die Punktzahlen der einzelnen Aufgaben addiert. +% \item Am Ende des Dokumentes wird mit |\AtEndDocument| bzw. |\immediate\write\@auxout| der aktuelle Wert von \meta{exercises@totalpoints} in die |aux|-Datei geschreiben. +% \item Beim zweiten \LaTeX\-Lauf würde wiederum das Paket |exercises| geladen und \meta{exercises@totalpoints} mit 0 initialisiert werden. +% \item Bei |\begin{document}| wird wiederum die |aux|-Datei gelesen. Beim diesem zweiten \LaTeX\-Lauf würde \meta{exercises@totalpoints} nun den Wert der Gesamtpunktzahl aus dem ersten Lauf bekommen. +% \item Zu \meta{exercises@totalpoints} werden die Punktzahlen der einzelnen Aufgaben addiert. +% \item usw. +% \end{enumerate} +% Man erkennt, dass sich so die Gesamtpunktzahl bei jedem \LaTeX\-Lauf verdoppeln, verdreifachen usw. würde. Entsprechend wird \meta{exercises@totalpoints} jeweils am Schluss des Dokuments an \meta{exercises@finaltotalpoints} übergeben. +% \begin{macrocode} +\AtEndDocument{\immediate\write\@auxout% +{\string\setcounter{exercises@finaltotalpoints}{\theexercises@totalpoints}}}% +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% \subsection{Umgebung \texttt{solution}} +% +% \begin{macro}{solution} +% Die Umgebung |solution| definiert ein optionales Argument: der Abstand, welcher freigelassen werden soll, falls die Lösung nicht ausgegeben wird. +% \begin{macrocode} +\DeclareDocumentEnvironment{solution}{o}{% +\setlength{\exercises@parskipsave}{0cm} +\setlength{\exercises@parskipsave}{\parskip} +\setlength{\parskip}{0cm} +% \end{macrocode} +% +% Der obere Abstand wird eingefügt, falls die Lösungen ausgegeben werden. +% \begin{macrocode} +\ifthenelse{\boolean{exercises@printsolution}}% + {\vspace{\exercises@solutionspaceabove}}{}% +% \end{macrocode} +% +% \meta{solutionname} und die Lösungsnummer werden ausgegeben, sofern die Lösungen überhaupt ausgegeben. Andernfalls wird der Leerraum (das optionale Argument) sowie |\comment| ausgegeben. +% \begin{macrocode} +\ifthenelse{\boolean{exercises@printsolution}}% + {\textbf{\exercises@solutionname\ \exercises@formatnumbers{exercises@solutionnumber}:\exercises@placesolution}}% + {\IfNoValueTF{#1}{}{\vspace{#1}}\comment}% +\setlength{\parskip}{\exercises@parskipsave}% +}% +% \end{macrocode} +% Werden die Lösungen ausgegeben, so wird \meta{solutionspacebelow} ausgegeben. Andern falls folgt die Ausgabe von |\endcomment|. Zu guter Letzt wird der Zähler \meta{solutionnumber} eins hochgezählt. +% \begin{macrocode} +{% +\setlength{\parskip}{0cm}% +\ifthenelse{\boolean{exercises@printsolution}}{\vspace{\exercises@solutionspacebelow}}% + {\endcomment}\stepcounter{exercises@solutionnumber}\setlength{\parskip}{\exercises@parskipsave}% +\setlength{\parskip}{\exercises@parskipsave}% +}% +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% \subsection{Befehle für die Seitenumbrüche} +% +% \begin{macro}{\exercisenewpage} +% \begin{macro}{\solutionnewpage} +% Die Befehle |exercisenewpage| und |solutionnewpage| erlauben es, einen Seitenumbruch in abhängigkeit der Lösungsausgabe einzufügen. +% \begin{macrocode} +\newcommand{\exercisenewpage}{\ifthenelse{\boolean{exercises@printsolution}}{}{\newpage}} +% \end{macrocode} +% +% \begin{macrocode} +\newcommand{\solutionnewpage}{\ifthenelse{\boolean{exercises@printsolution}}{\newpage}{}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \Finale +\endinput diff --git a/Master/texmf-dist/source/latex/exercises/exercises.ins b/Master/texmf-dist/source/latex/exercises/exercises.ins new file mode 100644 index 00000000000..355319f2e6c --- /dev/null +++ b/Master/texmf-dist/source/latex/exercises/exercises.ins @@ -0,0 +1,55 @@ +%% +%% Copyright (C) 2015 by Roger Jud +%% +%% This file may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.2 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.2 or later is part of all distributions of LaTeX version +%% 1999/12/01 or later. +%% + +\input docstrip.tex +\keepsilent + +\usedir{tex/latex/exercises} + +\preamble + +This is a generated file. + +Copyright (C) 2015 by Roger Jud + +This file may be distributed and/or modified under the conditions of +the LaTeX Project Public License, either version 1.2 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.2 or later is part of all distributions of LaTeX version +1999/12/01 or later. + +\endpreamble + +\generate{\file{exercises.sty}{\from{exercises.dtx}{package}}} + +\obeyspaces +\Msg{*************************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the following *} +\Msg{* file into a directory searched by TeX: *} +\Msg{* *} +\Msg{* exercises.sty *} +\Msg{* *} +\Msg{* To produce the documentation run the file *} +\Msg{* exercises.dtx through LaTeX. *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{*************************************************************} + +\endbatchfile \ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/exercises/exercises.sty b/Master/texmf-dist/tex/latex/exercises/exercises.sty new file mode 100644 index 00000000000..aca3fede546 --- /dev/null +++ b/Master/texmf-dist/tex/latex/exercises/exercises.sty @@ -0,0 +1,200 @@ +%% +%% This is file `exercises.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% exercises.dtx (with options: `package') +%% +%% This is a generated file. +%% +%% Copyright (C) 2015 by Roger Jud +%% +%% This file may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.2 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.2 or later is part of all distributions of LaTeX version +%% 1999/12/01 or later. +%% +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{exercises}[2015/09/19 v1.0 .dtx exercises file] +\RequirePackage{verbatim} +\RequirePackage{ifthen} +\RequirePackage{kvoptions} +\RequirePackage{xparse} +\RequirePackage{marginnote} +\SetupKeyvalOptions{ + family=exercises, + prefix=exercises@} +\DeclareBoolOption{printsolution} +\DeclareStringOption[2.0ex plus 1.0ex minus 0.5ex]{exercisespaceabove} +\DeclareStringOption[1.5ex plus 1.0ex minus 0.5ex]{exercisespacebelow} +\DeclareStringOption[2.0ex plus 1.0ex minus 0.5ex]{solutionspaceabove} +\DeclareStringOption[1.5ex plus 1.0ex minus 0.5ex]{solutionspacebelow} +\DeclareStringOption[0.25ex]{blockspace} +\DeclareStringOption[0.5em]{inlinespace} +\DeclareStringOption[arabic]{exercisenumberformat} +\DeclareStringOption[aftername]{pointsposition} +\DeclareStringOption[normalsize]{pointsfontsize} +\DeclareStringOption[Pt.]{pointsname} +\DeclareStringOption[Exercise]{exercisename} +\DeclareStringOption[block]{exercisenameposition} +\DeclareStringOption[Solution]{solutionname} +\DeclareStringOption[block]{solutionnameposition} +\DeclareStringOption[Pt.]{totalpointsname} +\DeclareStringOption[round]{braces} +\DeclareBoolOption[false]{starpoints} +\ProcessKeyvalOptions{exercises} +\ifthenelse{\equal{\exercises@exercisenumberformat}{arabic}}% + {\newcommand{\exercises@formatnumbers}[1]{\arabic{#1}}}{}% +\ifthenelse{\equal{\exercises@exercisenumberformat}{roman}}% + {\newcommand{\exercises@formatnumbers}[1]{\roman{#1}}}{}% +\ifthenelse{\equal{\exercises@exercisenumberformat}{Roman}}% + {\newcommand{\exercises@formatnumbers}[1]{\Roman{#1}}}{}% +\ifthenelse{\equal{\exercises@exercisenumberformat}{alph}}% + {\newcommand{\exercises@formatnumbers}[1]{\alph{#1}}}{}% +\ifthenelse{\equal{\exercises@exercisenumberformat}{Alph}}% + {\newcommand{\exercises@formatnumbers}[1]{\Alph{#1}}}{}% +\ifthenelse{\not\equal{\exercises@exercisenumberformat}{arabic}% + \and \not\equal{\exercises@exercisenumberformat}{roman}% + \and \not\equal{\exercises@exercisenumberformat}{Roman}% + \and \not\equal{\exercises@exercisenumberformat}{alph}% + \and \not\equal{\exercises@exercisenumberformat}{Alph}}% + {\PackageError{exercises}% + {"\exercises@exercisenumberformat" ist als Option von "exercisenumberformat" nicht erlaubt. % + Stattdessen wurde "arabic" verwendet.}% + {"\exercises@exercisenumberformat" ist als Option von "exercisenumberformat" nicht erlaubt. % + Stattdessen wurde "arabic" verwendet.}% + \newcommand{\exercises@formatnumbers}[1]{\arabic{#1}}}{}% +\ifthenelse{\equal{\exercises@exercisenameposition}{block}}% + {\newcommand{\exercises@placeexercise}{\noindent\par\vspace{\exercises@blockspace}}}{}% +\ifthenelse{\equal{\exercises@exercisenameposition}{inline}}% + {\newcommand{\exercises@placeexercise}{\hspace{\exercises@inlinespace}}}{}% +\ifthenelse{\not\equal{\exercises@exercisenameposition}{block}% + \and \not\equal{\exercises@exercisenameposition}{inline}}% + {\PackageError{exercises}% + {"\exercises@exercisenameposition" ist als Option von "exercisenameposition" nicht erlaubt. % + Stattdessen wurde "block" verwendet.}% + {"\exercises@exercisenameposition" ist als Option von "exercisenameposition" nicht erlaubt. % + Stattdessen wurde "block" verwendet.} + \newcommand{\exercises@placeexercise}{\noindent\par\vspace{\exercises@blockspace}}}{}% +\ifthenelse{\equal{\exercises@solutionnameposition}{block}}% + {\newcommand{\exercises@placesolution}{\noindent\par\vspace{\exercises@blockspace}}}{}% +\ifthenelse{\equal{\exercises@solutionnameposition}{inline}}% + {\newcommand{\exercises@placesolution}{\hspace{\exercises@inlinespace}}}{}% +\ifthenelse{\not\equal{\exercises@solutionnameposition}{block}% + \and \not\equal{\exercises@solutionnameposition}{inline}}% + {\PackageError{exercises}% + {"\exercises@solutionnameposition" ist als Option von "solutionnameposition" nicht erlaubt. % + Stattdessen wurde "block" verwendet.}% + {"\exercises@solutionnameposition" ist als Option von "solutionnameposition" nicht erlaubt. % + Stattdessen wurde "block" verwendet.}% + \newcommand{\exercises@placesolution}{\noindent\par\vspace{\exercises@blockspace}}}{}% +\ifthenelse{\equal{\exercises@pointsposition}{aftername}}% + {\newcommand{\exercises@placepoints}[1]{ #1}}{}% +\ifthenelse{\equal{\exercises@pointsposition}{margin}}% + {\newcommand{\exercises@placepoints}[1]% + {\marginnote{#1}}}{}% +\ifthenelse{\not\equal{\exercises@pointsposition}{aftername}% + \and \not\equal{\exercises@pointsposition}{margin}}% + {\PackageError{exercises}% + {"\exercises@pointsposition" ist als Option von "pointsposition" nicht erlaubt. % + Stattdessen wurde "aftername" verwendet.}% + {"\exercises@pointsposition" ist als Option von "pointsposition" nicht erlaubt. % + Stattdessen wurde "aftername" verwendet.}% + \newcommand{\exercises@placepoints}[1]{ #1}}{}% + +\ifthenelse{\equal{\exercises@pointsfontsize}{normalsize}}% + {\newcommand{\exercises@formatpoints}[1]{\normalsize #1}}{}% +\ifthenelse{\equal{\exercises@pointsfontsize}{footnotesize}}% + {\newcommand{\exercises@formatpoints}[1]{\footnotesize #1 \normalsize}}{}% +%% +\ifthenelse{\not\equal{\exercises@pointsfontsize}{normalsize}% + \and \not\equal{\exercises@pointsfontsize}{footnotesize}}% + {\PackageError{exercises}% + {"\exercises@pointsfontsize" ist als Option von "pointsfontsize" nicht erlaubt. % + Stattdessen wurde "normalsize" verwendet.}% + {"\exercises@pointsfontsize" ist als Option von "pointsfontsize" nicht erlaubt. % + Stattdessen wurde "normalsize" verwendet.}% + \newcommand{\exercises@formatpoints}[1]{\normalsize #1}}{}% +\ifthenelse{\equal{\exercises@braces}{nobraces}}% + {\newcommand{\exercises@openbrace}{}% + \newcommand{\exercises@closebrace}{}}{}% +\ifthenelse{\equal{\exercises@braces}{round}}% + {\newcommand{\exercises@openbrace}{(}% + \newcommand{\exercises@closebrace}{)}}{}% +\ifthenelse{\equal{\exercises@braces}{square}}% + {\newcommand{\exercises@openbrace}{[}% + \newcommand{\exercises@closebrace}{]}}{}% +\ifthenelse{\not\equal{\exercises@braces}{nobraces}% + \and \not\equal{\exercises@braces}{round}% + \and \not\equal{\exercises@braces}{square}}% + {% + \PackageError{exercises}% + {"\exercises@braces" ist als Option von "braces" nicht erlaubt. % + Stattdessen wurde "round" verwendet.}% + {"\exercises@braces" ist als Option von "braces" nicht erlaubt. % + Stattdessen wurde "round" verwendet.}% + \newcommand{\exercises@openbrace}{(}% + \newcommand{\exercises@closebrace}{)}% + }{}% +\newcounter{exercises@totalpoints} +\setcounter{exercises@totalpoints}{0} +\newcounter{exercises@finaltotalpoints} +\newcounter{exercises@exercisenumber} +\setcounter{exercises@exercisenumber}{1} +\newcounter{exercises@solutionnumber} +\setcounter{exercises@solutionnumber}{1} +\newcounter{i} +\newlength{\exercises@parskipsave} +\DeclareDocumentEnvironment{exercise}{o}{% +\setlength{\exercises@parskipsave}{0cm} +\setlength{\exercises@parskipsave}{\parskip} +\setlength{\parskip}{0cm} + \vspace{\exercises@exercisespaceabove}% + \IfNoValueTF{#1}% + {\textbf{\exercises@exercisename\ \exercises@formatnumbers{exercises@exercisenumber}:}\exercises@placeexercise}% + {\addtocounter{exercises@totalpoints}{#1}% + \textbf{\exercises@exercisename\ \exercises@formatnumbers{exercises@exercisenumber}:}% + \ifthenelse{\boolean{exercises@starpoints}}% + {\exercises@placepoints{\exercises@openbrace% + \setcounter{i}{0}\whiledo{#1>\thei}{*\stepcounter{i}}% + \exercises@closebrace}}% + {\exercises@placepoints{\exercises@formatpoints{\exercises@openbrace#1 \exercises@pointsname\exercises@closebrace}}}\exercises@placeexercise% + }% +\setlength{\parskip}{\exercises@parskipsave}% +}{% +\setlength{\parskip}{0cm}% + \stepcounter{exercises@exercisenumber}% + \vspace{\exercises@exercisespacebelow}% +\setlength{\parskip}{\exercises@parskipsave}% +}% +\newcommand\totalpoints{\theexercises@finaltotalpoints\ \exercises@totalpointsname}% +\AtEndDocument{\immediate\write\@auxout% +{\string\setcounter{exercises@finaltotalpoints}{\theexercises@totalpoints}}}% +\DeclareDocumentEnvironment{solution}{o}{% +\setlength{\exercises@parskipsave}{0cm} +\setlength{\exercises@parskipsave}{\parskip} +\setlength{\parskip}{0cm} +\ifthenelse{\boolean{exercises@printsolution}}% +{\vspace{\exercises@solutionspaceabove}}{}% +\ifthenelse{\boolean{exercises@printsolution}}% + {\textbf{\exercises@solutionname\ \exercises@formatnumbers{exercises@solutionnumber}:\exercises@placesolution}}% + {\IfNoValueTF{#1}{}{\vspace{#1}}\comment}% +\setlength{\parskip}{\exercises@parskipsave}% +}% +{% +\setlength{\parskip}{0cm}% +\ifthenelse{\boolean{exercises@printsolution}}{\vspace{\exercises@solutionspacebelow}}% + {\endcomment}\stepcounter{exercises@solutionnumber}\setlength{\parskip}{\exercises@parskipsave}% +\setlength{\parskip}{\exercises@parskipsave}% +}% +\newcommand{\exercisenewpage}{\ifthenelse{\boolean{exercises@printsolution}}{}{\newpage}} +\newcommand{\solutionnewpage}{\ifthenelse{\boolean{exercises@printsolution}}{\newpage}{}} +\endinput +%% +%% End of file `exercises.sty'. -- cgit v1.2.3