diff options
author | Karl Berry <karl@freefriends.org> | 2017-09-20 22:36:23 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-09-20 22:36:23 +0000 |
commit | baaddc3c242540fcc6eef178a4576c34df84c339 (patch) | |
tree | 3dd7e8072b95be228ebfff3acb9f40f0e7823b88 /Master/texmf-dist | |
parent | 6fdb207f55c75b496f116c760eab2e1640de2b88 (diff) |
xsim (20sep17)
git-svn-id: svn://tug.org/texlive/trunk@45355 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
40 files changed, 968 insertions, 279 deletions
diff --git a/Master/texmf-dist/doc/latex/xsim/README b/Master/texmf-dist/doc/latex/xsim/README index b8da799ff7d..5f1ba9fa6e0 100644 --- a/Master/texmf-dist/doc/latex/xsim/README +++ b/Master/texmf-dist/doc/latex/xsim/README @@ -1,5 +1,5 @@ -------------------------------------------------------------------------- -XSIM 2017/05/19 v0.8a +XSIM 2017/09/19 v0.10 eXercise Sheets IMproved @@ -34,6 +34,7 @@ The xsim package consists of the code files: xsim.goals.code.tex xsim.grades.code.tex xsim.interface.code.tex + xsim.layouts.code.tex xsim.modules.code.tex xsim.properties.code.tex xsim.random.code.tex @@ -60,19 +61,26 @@ The xsim package consists of the example files: xsim.difficulties.tex, xsim.difficulties.pdf xsim.floating.tex, xsim.floating.pdf xsim.grade-distribution.tex, xsim.grade-distribution.pdf + xsim.hints.tex, xsim.hints.pdf xsim.listings.tex, xsim.listings.pdf xsim.multiplechoice.tex, xsim.multiplechoice.pdf + xsim.listofexercises.tex, xsim.listofexercises.pdf xsim.pointsums.tex, xsim.pointsums.pdf xsim.randomexercises.tex, xsim.randomexercises.pdf xsim.various.tex, xsim.various.pdf + xsim.texsx-13635.tex, xsim.texsx-13635.pdf + xsim.texsx-155630.tex, xsim.texsx-155630.pdf xsim.texsx-199360.tex, xsim.texsx-199360.pdf xsim.texsx-299534.tex, xsim.texsx-299534.pdf xsim.texsx-305110.tex, xsim.texsx-305110.pdf + xsim.texsx-308883.tex, xsim.texsx-308883.pdf xsim.texsx-338165.tex, xsim.texsx-338165.pdf xsim.texsx-350028.tex, xsim.texsx-350028.pdf xsim.texsx-369065.tex, xsim.texsx-369065.pdf xsim.texsx-369803.tex, xsim.texsx-369803.pdf xsim.texsx-369686.tex, xsim.texsx-369686.pdf + xsim.texsx-370642.tex, xsim.texsx-370642.pdf + xsim.texsx-391530.tex, xsim.texsx-391530.pdf xsim.texwelt-6698.tex, xsim.texwelt-6698.pdf xsim.texwelt-15093.tex, xsim.texwelt-15093.pdf xsim.golatex-16824.tex, xsim.golatex-16824.pdf diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.pdf b/Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.pdf Binary files differnew file mode 100644 index 00000000000..6a6dab99cca --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.pdf diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.tex b/Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.tex new file mode 100644 index 00000000000..5fa3ed4ec8f --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.hints.tex @@ -0,0 +1,59 @@ +% https://tex.stackexchange.com/q/224408/ +\documentclass{article} +\usepackage{xsim} + +\usepackage{needspace} + +\DeclareExerciseProperty{hint} + +% we'll use a description list for the hints: +\newcommand\printhints{% + \begin{description} + \ForEachUsedExerciseByType{% + \def\ExerciseType{##1}% + \def\ExerciseID{##2}% + \GetExercisePropertyT{hint} + {% + \item[\XSIMmixedcase{\GetExerciseName}~##3] + ####1% + }% + }% + \end{description} +} + +\newcommand\hint[1]{\SetExerciseProperty{\ExerciseType}{\ExerciseID}{hint}{#1}} + +\begin{document} + +\section{Problems} +% set hint through option: +\begin{exercise}[subtitle=Pythagoras,hint=This is a hint to the first problem.] + This is the first problem. +\end{exercise} +\begin{solution} + This is the solution to the first problem. +\end{solution} + +\begin{exercise}[subtitle=Another Problem] + This is the second problem. +\end{exercise} +\begin{solution} + This is the solution to the second problem. +\end{solution} + +% set hint with custom command: +\begin{exercise}[subtitle=Yet Another Problem] + This is the third problem. + \hint{This is a hint to the third problem.} +\end{exercise} +\begin{solution} + This is the solution to the third problem. +\end{solution} + +\section{Hints} +\printhints + +\section{Solutions} +\printsolutions[headings=false] + +\end{document} diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.listofexercises.pdf b/Master/texmf-dist/doc/latex/xsim/examples/xsim.listofexercises.pdf Binary files differnew file mode 100644 index 00000000000..8050ee8f90a --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.listofexercises.pdf diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.listofexercises.tex b/Master/texmf-dist/doc/latex/xsim/examples/xsim.listofexercises.tex new file mode 100644 index 00000000000..c2a9a3fe362 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.listofexercises.tex @@ -0,0 +1,81 @@ +% https://tex.stackexchange.com/q/94766/ +\documentclass[a4paper,10pt]{book} +\usepackage[utf8]{inputenc} + +\usepackage{xsim} +\xsimsetup{ + exercise/within=chapter, + exercise/template=theorem , + exercise/the-counter=\thechapter.\arabic{exercise} +} + +\DeclareExerciseEnvironmentTemplate{theorem} + {% + \par\addvspace{\baselineskip} + \noindent + \XSIMexpandcode{\noexpand\label{\ExerciseType:\ExerciseID}} + \Large\textbf{% + \space\GetExerciseProperty{counter}% + \GetExercisePropertyT{subtitle}{ (\PropertyValue)}% + } \normalsize\itshape + } + {\par\addvspace{\baselineskip}} + +\usepackage{multicol} + +\newcommand\listofexercises{ + \chapter*{List of Exercises} + \def\CurrentExerciseChapter{}% + \ForEachPrintedExerciseByType{ + \global\let\LastExerciseChapter\CurrentExerciseChapter + \xdef\CurrentExerciseChapter{\ExercisePropertyGet{##1}{##2}{chapter}}% + \XSIMifeqF{\LastExerciseChapter}{\CurrentExerciseChapter} + { + \XSIMifblankF{\LastExerciseChapter}{\end{multicols}} + \begin{multicols}{2}% + [\contentsline{chapter}{Chapter \CurrentExerciseChapter}{}{}] + } + \contentsline + {section} + {% + Exercise \ExercisePropertyGet{##1}{##2}{counter}% + \XSIMifblankF{##4}{ (##4)}% + } + {\pageref{##1:##2}}{}% + } + \end{multicols} +} + +% \usepackage{hyperref} +% \newcommand\theHexercise{\thechapter.\arabic{exercise}} + +\begin{document} + +\chapter{kinetic} +\begin{exercise} + 435-1 +\end{exercise} +\begin{exercise}[subtitle=Foo Bar] + 435-2 +\end{exercise} +\begin{exercise} + 435-3 +\end{exercise} + +\chapter{momentum} +\begin{exercise} + 436-1 +\end{exercise} +\begin{exercise} + 436-2 +\end{exercise} +\begin{exercise} + 436-3 +\end{exercise} +\begin{exercise} + 436-4 +\end{exercise} + +\listofexercises + +\end{document} diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-13635.pdf b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-13635.pdf Binary files differnew file mode 100644 index 00000000000..af889a6709f --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-13635.pdf diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-13635.tex b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-13635.tex new file mode 100644 index 00000000000..3b52ce46b24 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-13635.tex @@ -0,0 +1,70 @@ +% https://tex.stackexchange.com/q/13635/ +\documentclass{article} +\usepackage{xsim} + +\DeclareExerciseEnvironmentTemplate{theorem:remark} + { + \par\addvspace{\baselineskip} + \noindent + \textit{% + \IfInsideSolutionF{\XSIMmixedcase{\GetExerciseName}~}% + \GetExerciseProperty{counter}}% + \GetExercisePropertyT{subtitle}{ \textup{(#1)}}% + . % + } + {\par\addvspace{\baselineskip}} + +\DeclareExerciseHeadingTemplate{exercises}{\subsection*{Exercises}} + +\xsimsetup{ + exercise/template = theorem:remark , + exercise/within = section , + exercise/the-counter = \thesection.\arabic{exercise} , + print-collection/headings = true , + print-collection/headings-template = exercises +} + +\DeclareExerciseCollection{prime numbers} +\DeclareExerciseCollection{Zeta function} + +\begin{document} + +\collectexercises{prime numbers} +\section{Prime Numbers} + +A \emph{prime number} is a positive integer other than $1$ that is only +divisible by $1$ and itself. + +\begin{exercise}[subtitle=Euclid's Theorem] + \label{ex:euclid} + Show that there are infinitely many prime numbers. +\end{exercise} + +As you will show in Exercise \ref{ex:euclid}, there are infinitely many +primes. The number of primes that are smaller than a given natural number $n$ +is denoted $\pi(n)$. + +\begin{exercise} + Find an asymptotic formula for $\pi(n)$. \emph{Hint:} You might find + Exercise \ref{ex:zeta} helpful. +\end{exercise} +\collectexercisesstop{prime numbers} + +\printcollection{prime numbers} + +\collectexercises{Zeta function} +\section{Zeta function} + +The zeta function is given by $\zeta(s) = \sum_{n=1}^\infty n^{-s}$, where $s$ +is a complex number with real part bigger than $1$. +\begin{exercise}\label{ex:zeta} + Extend $\zeta$ as far as possible and find all zeros + of the function. +\end{exercise} +For example $\zeta(2) = \frac{\pi^2}{6}$. + +\collectexercisesstop{Zeta function} + +\printcollection{Zeta function} + +\end{document} diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-155630.pdf b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-155630.pdf Binary files differnew file mode 100644 index 00000000000..6c9fc4482af --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-155630.pdf diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-155630.tex b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-155630.tex new file mode 100644 index 00000000000..2edb7bfdad2 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-155630.tex @@ -0,0 +1,26 @@ +% https://tex.stackexchange.com/q/155630/ +\documentclass{article} +\usepackage{xsim} + +\DeclareExerciseCollection{foo} + +\begin{document} + +\collectexercises{foo} +\begin{exercise} + foo +\end{exercise} +\begin{exercise} + bar +\end{exercise} +\begin{exercise} + baz +\end{exercise} +\collectexercisesstop{foo} + +% shuffle around for a different version: +\printexercise{exercise}{1} +\printexercise{exercise}{3} +\printexercise{exercise}{2} + +\end{document} diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-308883.pdf b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-308883.pdf Binary files differnew file mode 100644 index 00000000000..eb27dce140c --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-308883.pdf diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-308883.tex b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-308883.tex new file mode 100644 index 00000000000..74e762fa08b --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-308883.tex @@ -0,0 +1,13 @@ +% https://tex.stackexchange.com/q/308883/ +\documentclass{article} +\usepackage{xsim,siunitx} +\xsimsetup{goal-print={\num{#1}}} +\sisetup{output-decimal-marker={,}} + +\begin{document} + +\begin{exercise}[points=2.5] + foo +\end{exercise} + +\end{document} diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-370642.pdf b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-370642.pdf Binary files differnew file mode 100644 index 00000000000..13933e80c3b --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-370642.pdf diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-370642.tex b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-370642.tex new file mode 100644 index 00000000000..99b300c4a01 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-370642.tex @@ -0,0 +1,25 @@ +% https://tex.stackexchange.com/q/370642/ +\documentclass[a4paper,12pt]{article} +\usepackage{xsim} + +\DeclareExerciseEnvironmentTemplate{simple} + {\par\noindent\textbf{\GetExerciseProperty{counter}}. } + {\par} +\xsimsetup{exercise/template=simple} + +\begin{document} + +\begin{exercise}\label{eq1} + Let $X$ be such that\dots +\end{exercise} + +\begin{exercise} + In this exercise consider $Y=2$ \dots +\end{exercise} + +\begin{exercise} + Consider $X$ as in exercise~\ref{eq1} (I would like to see the issue + number~1) +\end{exercise} + +\end{document} diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-391530.pdf b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-391530.pdf Binary files differnew file mode 100644 index 00000000000..137c8587693 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-391530.pdf diff --git a/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-391530.tex b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-391530.tex new file mode 100644 index 00000000000..48bf94cd6eb --- /dev/null +++ b/Master/texmf-dist/doc/latex/xsim/examples/xsim.texsx-391530.tex @@ -0,0 +1,66 @@ +\documentclass{article} +\usepackage{xsim} + +\DeclareExerciseType{subquestion}{ + exercise-env = question , + solution-env = answer , + exercise-name = Question , + solution-name = Answer , + exercise-template = item , + solution-template = item +} + +\DeclareExerciseProperty{title} + +\makeatletter +\DeclareExerciseEnvironmentTemplate{named} + {% + \subsection*{% + \GetExercisePropertyTF{title} + {#1} + {??\@latex@warning{Please give an exercise title}}% + }% + } + {} +\makeatother + +\DeclareExerciseEnvironmentTemplate{item} + {\item} + {} + +\DeclareExerciseCollection{exercise-pool} + +\xsimsetup{ + exercise/template = named +} + +\begin{filecontents*}{\jobname-exercises.tex} +\begin{question} + Who is the Defence Minister? +\end{question} +\begin{question} + Who is the Home Minister? +\end{question} +\begin{question} + Who is the Finance Minister? +\end{question} +\begin{question} + Who is the External Affairs Minister? +\end{question} +\end{filecontents*} + +\begin{document} + +\collectexercises{exercise-pool} +\input{\jobname-exercises.tex} +\collectexercisesstop{exercise-pool} + +\begin{exercise}[title=Answer the following in one sentence:] + \begin{enumerate} + \item Who is the President? + \item Who is the Prime Minister? + \printrandomexercises[collection=exercise-pool]{2} + \end{enumerate} +\end{exercise} + +\end{document} diff --git a/Master/texmf-dist/doc/latex/xsim/xsim.history b/Master/texmf-dist/doc/latex/xsim/xsim.history index 895e7a47a3b..9c3ab5498e5 100644 --- a/Master/texmf-dist/doc/latex/xsim/xsim.history +++ b/Master/texmf-dist/doc/latex/xsim/xsim.history @@ -79,3 +79,23 @@ HISTORY: - new parameter `solution-counter' in order to avoid possible conflicts with existing counters v0.8a 2017/05/19 - \IfPrintSolutionTF + v0.8b 2017/05/23 - use \printgoal in default environment template + - \xsim_print_goal:nnn now expands input to a number + v0.9 2017/06/20 - \xsimstyle's behaviour now matches the description in + the manual + - add style file `layouts' which at the moment provides the + two exercise templates `runin' and `margin' + - \printforexercises , \xsim_print_type_code:nnnnn + - \IfExerciseParameterSetTF + - \GetExerciseParameterTF + - change syntax of \SetExerciseProperty + - \SetExpandedExerciseProperty + - \ExerciseSetProperty, \ExerciseSetExpandedProperty + - property `sectioning' + - \IfExistSolutionTF + v0.10 2017/09/19 - \xsim_input:nnn + - \GetExerciseBody + - option `blank/fill' + - bug fix in \xsim_start_collection:nn + - added further examples to package + - new option `file-extension' diff --git a/Master/texmf-dist/doc/latex/xsim/xsim_manual.pdf b/Master/texmf-dist/doc/latex/xsim/xsim_manual.pdf Binary files differindex 3a0fa539656..e38a1654029 100644 --- a/Master/texmf-dist/doc/latex/xsim/xsim_manual.pdf +++ b/Master/texmf-dist/doc/latex/xsim/xsim_manual.pdf diff --git a/Master/texmf-dist/doc/latex/xsim/xsim_manual.tex b/Master/texmf-dist/doc/latex/xsim/xsim_manual.tex index 2e351c7a64e..96a6613159a 100644 --- a/Master/texmf-dist/doc/latex/xsim/xsim_manual.tex +++ b/Master/texmf-dist/doc/latex/xsim/xsim_manual.tex @@ -1,8 +1,8 @@ -% !arara: pdflatex: { action: nonstopmode } -% !arara: biber % arara: pdflatex: { action: nonstopmode } +% !arara: biber % arara: pdflatex: { action: nonstopmode } % arara: pdflatex: { action: nonstopmode } +% !arara: pdflatex: { action: nonstopmode } % ---------------------------------------------------------------------------- % the XSIM package % @@ -282,8 +282,20 @@ order to deal with this somehow \xsim\ offers the following option: given. Exercises will be written to and included from this path. \emph{The path must exist on your system before you can use it!} This document uses \keyis{path}{exercises}. + \keyval{file-extension}{string}\Default{\code{tex}} + \sinceversion{0.10}This option let's you choose the extension of the + auxiliary files. \end{options} +Another thing to keep in mind: the environment in many ways works the same way +as the \env{filecontents}. \emph{This also means that you \emph{cannot} have + comments on the first line of the environments:} +\begin{sourcecode} + \begin{exercise}[points=2] % this will cause trouble + Lorem ipsum + \end{exercise} +\end{sourcecode} + \begin{bewareofthedog} \xsim\ writes a lot of stuff to the auxfile for re-using information on subsequent compilations. If you add exercises, change properties \etc\ it @@ -486,17 +498,18 @@ others can be set using the optional argument of the exercise environment. \command{DeclareExerciseProperty}[\barg\sarg\narg\marg{property}] Declares the property \meta{property}. - If used with the optional \barg\ star a unique property is defined which - means that each exercise must have a property value distinct from all - other exercises (all means all -- \emph{independent from the exercise type}). - - If used with the optional \sarg\ a boolean property is defined which - means that it only should get the values \code{true} or \code{false} and - if used without value it gets the value \code{true} instead of an empty - value. If any other value is used the property is set to - \code{false}. A boolean option obviously cannot be unique. The optional - \sarg\ takes precedence over the optional \barg, \ie, if both are present - the property is boolean \emph{but not} unique. + If used with the optional \barg\ a \textbf{unique property} is defined + which means that each exercise must have a property value distinct from + all other exercises (all means all -- \emph{independent from the exercise + type}). + + If used with the optional \sarg\ a \textbf{boolean property} is defined + which means that it only should get the values \code{true} or \code{false} + and if used without value it gets the value \code{true} instead of an + empty value. If any other value is used the property is set to + \code{false}. A boolean property obviously cannot be unique. The + optional \sarg\ takes precedence over the optional \barg, \ie, if both are + present the property is boolean \emph{but not} unique. If used with the optional \narg\ a property is defined which won't get updated through subsequent compilation runs but is only set when the @@ -527,7 +540,7 @@ This is better demonstrated with an example: The power of properties will get more clear when reading section~\vref{sec:styl-exerc-templ} about templates. -\subsection{A Special Kind of Property: Exercise Goals}\label{sec:goals} +\subsection[Exercise Goals]{A Special Kind of Property: Exercise Goals}\label{sec:goals} Exercise goals are a generic concept in \xsim\ for exercise properties like \property{points} or \property{bonus-points}. Those are properties which can @@ -652,7 +665,7 @@ Here is how you could mimick the command \cs*{totalpoints} from \end{sourcecode} -\subsection{A Special Kind of Property: Exercise Tags}\label{sec:tags} +\subsection[Exercise Tags]{A Special Kind of Property: Exercise Tags}\label{sec:tags} Exercise tags are a generic concept in \xsim\ for exercise properties like \property{tags} or \property{topics}. Those are properties which can (only) @@ -679,13 +692,13 @@ This means that these options are available: \keyval{tags}{csv list of tags} Choose the set of tags whose associated exercises should be printed. \keyval{topics}{csv list of topics} - Choose the set of tags whose associated exercises should be printed. - \keybool{ignore-tagging}\Module{tags}\Default{false} + Choose the set of topics whose associated exercises should be printed. + \keybool{ignore-untagged}\Module{tags}\Default{false} If set to true exercises with no tags will be printed even if tags have been chosen with the option \option{tags}. - \keybool{ignore-tagging}\Module{topics}\Default{true} - If set to true exercises with no topics will be printed even if tags have - been chosen with the option \option{topics}. + \keybool{ignore-untagged}\Module{topics}\Default{true} + If set to true exercises with no topics will be printed even if topics + have been chosen with the option \option{topics}. \end{options} It may happen that you choose certain tags for printing and want one or two @@ -978,7 +991,7 @@ At last now an example using external files, collections and tags: once and only \emph{after it has been collected}. No guaranties are given that properties are set correctly if you use the collection before. You usually also will make sure that the exercises in a collection are unique, - \ie, that an exercises is not part of several collections -- at least not if + \ie, that an exercise is not part of several collections -- at least not if both collections are printed in the same document. \end{bewareofthedog} @@ -1014,10 +1027,10 @@ Valid options for this command are: \printrandomexercises[collection=foo]{2} \end{example} -The example above of course doesn't make much sense but if have a collection -which collects exercises from an external file and the exercise haven't been -printed in the document before then you will get a list of subsequently -numbered exercises. +The example above of course doesn't make much sense but if you have a +collection which collects exercises from an external file and the exercises +haven't been printed in the document before then you will get a list of +subsequently numbered exercises. \section{Printing Solutions}\label{sec:printing-solutions} @@ -1044,12 +1057,12 @@ There are different commands for printing the solutions to exercises: \printsolutionstype{exercise} \end{example} -The options can be diveded into two groups. The ones in the first group +The options can be divided into two groups. The ones in the first group modify the layout. \begin{options} - \keybool{headings}\Default{true} + \keybool{headings}\Module{print-solutions}\Default{true} If true a heading for each exercise type is inserted. - \keyval{headings-template}{template}\Default{default} + \keyval{headings-template}{template}\Module{print-solutions}\Default{default} The heading template used when \keyis{headings}{true}. \end{options} @@ -1057,15 +1070,18 @@ The ones in the second group set conditions selecting which solutions are printed. If you combine those conditions a solution is printed if it meets either of the conditions. \begin{options} - \keychoice{section}{\default{true},false,\meta{integer}}\Default{false} + \keychoice{section}{\default{true},false,\meta{integer}}\Module{print-solutions}% + \Default{false} If you set \keyis{section}{true} only solutions of exercises of the current section are printed. If you set \keyis{section}{4} only solutions of exercises in a section with number~$4$ are printed. - \keychoice{chapter}{\default{true},false,\meta{integer}}\Default{false} + \keychoice{chapter}{\default{true},false,\meta{integer}}\Module{print-solutions}% + \Default{false} If you set \keyis{chapter}{true} only solutions of exercises of the current chapter are printed. If you set \keyis{chapter}{4} only solutions of exercises in a chapter with number~$4$ are printed. - \keychoice{collection}{false,\meta{collection name}}\Default{false} + \keychoice{collection}{false,\meta{collection name}}\Module{print-solutions}% + \Default{false} If used only solutions of exercises belonging to collection \meta{collection name} are printed. \end{options} @@ -1169,6 +1185,34 @@ yourself in order to achieve certain layouts\footnote{I plan to incorporate section~\vref{sec:template-examples} but at the time of writing this is still up in the air.}. +\subsection{Templates Provided by the Package} +\xsim\ comes with a few predefined layouts: +\begin{description} + \item[\code{default}] The template activated per default and the only one + available without further action. + \item[\code{runin}] A layout rather similar to the one by package + \pkg{exsheets}, see section~\vref{sec:runin-template}. Available through + the style file \code{layouts} (see section~\vref{sec:style-files} for more + information on style files\index{style file}). + \item[\code{margin}] A layout rather similar to the one by package + \pkg{exsheets}, see section~\ref{sec:margin-template}. Available through + the style file \code{layouts} (see section~\vref{sec:style-files} for more + information on style files\index{style file}). +\end{description} + +\collectexercises{layouts} +\begin{exercise}[subtitle=The Subtitle,points=2.5,ID=showlayout] + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, + vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum + gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, + magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique + senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras + viverra metus rhoncus sem. +\end{exercise} +\collectexercisesstop{layouts} + +\listlayouts + \subsection{Commands for Usage in Template Definitions} \subsubsection{Goals} \begin{commands} @@ -1213,7 +1257,11 @@ yourself in order to achieve certain layouts\footnote{I plan to incorporate current exercise. Inside the \meta{true} branch you can refer to the retrieved value either with \code{\#1} or with \cs{PropertyValue}. \emph{This command expands its contents inside a group.} - \command{GetExerciseIdForProperty}[\marg{property}\marg{value}] + \command{GetExerciseBody}[\Marg{exercise\textnormal{|}solution}] + \sinceversion{0.10}Retrieves the environment body of either the + \code{exercise} or the corresponding \code{solution} of the current + exercise. + \expandable\command{GetExerciseIdForProperty}[\marg{property}\marg{value}] Retrieves the property \property{id} of the exercise where the property \meta{property} has the value \meta{value}. \emph{This only works for \emph{unique} properties!} @@ -1221,9 +1269,19 @@ yourself in order to achieve certain layouts\footnote{I plan to incorporate Retrieves the property \property{type} of the exercise where the property \meta{property} has the value \meta{value}. \emph{This only works for \emph{unique} properties!} - \command{SetExerciseProperty}[\marg{type}\marg{id}\marg{property}\marg{value}] - Set the property \meta{property} of exercise of type \meta{type} and id - \meta{id} to \meta{value}. + \command{SetExerciseProperty}[\marg{property}\marg{value}] + \changedversion{0.9}Set the property \meta{property} of the current + exercise to \meta{value}. + \command{SetExpandedExerciseProperty}[\marg{property}\marg{value}] + \sinceversion{0.9}Expand \meta{value} \cs*{edef}-like and set the property + \meta{property} of the current exercise to the result of the expansion. + \command{ExerciseSetProperty}[\marg{type}\marg{id}\marg{property}\marg{value}] + \sinceversion{0.9}Set the property \meta{property} of the exercise of type + \meta{type} and id \meta{id} to \meta{value}. + \command{ExerciseSetExpandedProperty}[\marg{type}\marg{id}\marg{property}\marg{value}] + \sinceversion{0.9}Expand \meta{value} \cs*{edef}-like and set the property + \meta{property} of the exercise of type \meta{type} and id \meta{id} to + the result of the expansion. \expandable\command{IfExerciseBooleanProperty\TF}[\marg{property}% \marg{true}\marg{false}] Checks wether the boolean property \meta{property} has value \code{true} @@ -1259,14 +1317,28 @@ yourself in order to achieve certain layouts\footnote{I plan to incorporate \subsubsection{Parameters} \begin{commands} \expandable\command{GetExerciseParameter}[\marg{parameter}] - Retrieves the value of the parameter \meta{paramater} for the current exercise. + Retrieves the value of the parameter \meta{paramater} for the current + exercise type. + \command{GetExerciseParameter\TF}[\marg{parameter}\marg{true}\marg{false}] + \sinceversion{0.9}Retrieves the value of the parameter \meta{paramater} + for the current exercise type. Inside the \meta{true} branch you can refer + to the retrieved value either with \code{\#1} or with \cs{ParameterValue}. + \emph{This command expands its contents inside a group.} \expandable\command{GetExerciseName} Retrieves the value of the parameter \parameter{exercise-name} for the current exercise or of the parameter \parameter{solution-name} for the current solution. - \expandable\command{ExerciseParameterGet}[\marg{type}\marg{id}\marg{parameter}] + \expandable\command{ExerciseParameterGet}[\marg{type}\marg{parameter}] Retrieves the value of the parameter \meta{parameter} for the exercise of type \meta{type} with id \meta{id}. + \expandable\command{IfExerciseParameterSet\TF}[\marg{parameter}% + \marg{true}\marg{false}] + \sinceversion{0.9}Test if the parameter \meta{parameter} has been set for + the current exercise type. + \expandable\command{ExerciseParameterIfSet\TF}[\marg{type}\marg{parameter}% + \marg{true}\marg{false}] + \sinceversion{0.9}Test if the parameter \meta{parameter} has been set for + the exercise type \meta{type}. \end{commands} \subsubsection{Tags} @@ -1288,6 +1360,10 @@ yourself in order to achieve certain layouts\footnote{I plan to incorporate \subsubsection{Further Commands for Usage in Template Definitions} \begin{commands} + \command{UseExerciseTemplate}[\marg{type}\marg{name}] + Retrieve template \meta{name} of type \meta{type}. This can be useful if + you want to define a template which just adds some code to an existing + template (an automated \cs*{label}, say). \expandable\command{ExerciseType} Can be used to refer to the current exercise type. \expandable\command{ExerciseID} @@ -1306,6 +1382,8 @@ yourself in order to achieve certain layouts\footnote{I plan to incorporate \expandable\command{IfPrintSolution\TF}[\marg{true}\marg{false}] Tests if the option \option{print} for the solutions of the current \cs{ExerciseType} is set to \code{true} or \code{false}. + \command{IfExistSolution\TF}[\marg{true}\marg{false}] + \sinceversion{0.9}Tests if a solution for the current exercise exists. \command{ForEachPrintedExerciseByType}[\marg{code}] Loops over each \emph{printed} exercise ordered by the exercise types and within each type by id. Inside \meta{code} you can refer to several @@ -1459,8 +1537,8 @@ Below the definition of the \code{default} exercise template provided by \marginpar {% \IfInsideSolutionF{\rule{1.2cm}{1pt}\slash}% - \PropertyValue - \GetExercisePropertyT{bonus-points}{~(+\PropertyValue)}% + \printgoal{\PropertyValue} + \GetExercisePropertyT{bonus-points}{~(+\printgoal{\PropertyValue})}% ~\XSIMtranslate {point-abbr}% }% }% @@ -1493,7 +1571,7 @@ problems in this manual have been defined: \IfInsideSolutionF{% \GetExercisePropertyT{points}{ % notice the space (% - \PropertyValue + \printgoal{\PropertyValue} \IfExerciseGoalSingularTF{points} {\XSIMtranslate{point}} {\XSIMtranslate{points}}% @@ -1525,6 +1603,7 @@ See it in action: \end{example} \subsubsection{Mimicking \pkg*{exsheets}' \code{runin} Template} +\label{sec:runin-template} The following example shows how you could mimick \pkg*{exsheets}' \code{runin} template. The outcome isn't exactly the same since \pkg{exsheets} doesn't use @@ -1539,69 +1618,51 @@ would use a real sectioning command for the title. \Needspace*{2\baselineskip} \noindent \textbf{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}}% - \GetExercisePropertyT{subtitle}{ \textit{#1}} % - \GetExercisePropertyT{points}{% - \marginpar{% - \PropertyValue - \GetExercisePropertyT{bonus-points}{+\PropertyValue}% - \,\IfExerciseGoalSingularTF{points} - {\XSIMtranslate{point}} - {\XSIMtranslate{points}}% + \GetExercisePropertyT{subtitle}{ \textit{#1}} % <<< notice the space + \IfInsideSolutionF{% + \GetExercisePropertyT{points}{% + \marginpar{% + \printgoal{\PropertyValue}% + \GetExercisePropertyT{bonus-points}{+\printgoal{\PropertyValue}}% + \,\IfExerciseGoalSingularTF{points} + {\XSIMtranslate{point}} + {\XSIMtranslate{points}}% + }% }% }% } {} \end{sourcecode} -See it in action: -\begin{example} - \xsimsetup{exercise/template=runin} - \renewcommand*\theexercise{\arabic{exercise}.} - \begin{exercise}[subtitle=exsheets' runin,points=2.5] - \lipsum[4] - \end{exercise} -\end{example} - \subsubsection{Mimicking \pkg*{exsheets}' \code{margin} Template} +\label{sec:margin-template} The following example shows how you could mimick \pkg*{exsheets}' \code{margin} template. \begin{sourcecode} - \usepackage{needspace} \DeclareExerciseEnvironmentTemplate{margin} {% - \par\vspace{\baselineskip} - \Needspace*{2\baselineskip} - \noindent - \llap{% + \trivlist + \item[\llap{% \smash{% \tabular[t]{@{}r@{}} \textbf{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}} \IfExercisePropertySetT{points}{% \tabularnewline (% - \GetExerciseProperty{points}% - \GetExercisePropertyT{bonus-points}{+#1}% + \printgoal{\GetExerciseProperty{points}}% + \GetExercisePropertyT{bonus-points}{+\printgoal{#1}}% \,\XSIMtranslate{point-abbr}% )% }% \endtabular - } % notice the space - }% + }% + }]\relax } - {} + {\endtrivlist} \end{sourcecode} -See it in action: -\begin{example} - \xsimsetup{exercise/template=margin} - \renewcommand*\theexercise{\arabic{exercise}.} - \begin{exercise}[subtitle=exsheets' margin,points=2.5] - \lipsum[4] - \end{exercise} -\end{example} - \subsubsection{The Headings Templates}\label{sec:headings-templates} \xsim\ defines four heading templates which only differ by which text they output: @@ -1758,7 +1819,7 @@ exercise type or to \meta{code}. \section{Exercise Translations}\label{sec:exerc-transl} \begin{commands} - \command{DeclareExerciseTranslation}[\marg{keyword}\marg{language}\marg{translation}] + \command{DeclareExerciseTranslation}[\marg{language}\marg{keyword}\marg{translation}] Declare the translation of \meta{keyword} for language \meta{language}. \command{DeclareExerciseTranslations}[\marg{keyword}\marg{translations}] Declare the translations of \meta{keyword} for several languages at once. @@ -1936,11 +1997,11 @@ resolve your problems. \subsection{\code{! TeX capacity exceeded, sorry [text input levels=15].} Why?} Did you try to use an exercise or solution in a macro of some sort? This -generally will fail\footnote{The reasons are not entirely clear to me.}. But -there should never be the need to hide the environments inside of a macro, -anyway. +generally will fail\footnote{The reasons are similar to the ones given here: + \url{https://tex.stackexchange.com/a/295422/}.}. But there should never be +the need to hide the environments inside of a macro, anyway. -\subsection{\code{Runaway argument? !File ended while scanning use of \^\^M.} Why?} +\subsection{\code{Runaway argument? !File ended while scanning use of \^{}\^{}M.} Why?} Did you try to use an exercise or solution in a macro of some sort? This generally will fail. But there should never be the need to hide the environments inside of a macro, anyway. @@ -1993,7 +2054,8 @@ The usage is now as follows: \end{exercise} \end{example} -\subsection{\dots Create and Use \xsim\ Style Files?} +\subsection{\dots Create and Use \xsim\ Style Files?}\label{sec:style-files} +\index{style file|(} \xsim\ offers you the possibility to create own \emph{style files}. Let's say you want to have a style called \code{math-exam}. Then you need to save all @@ -2044,6 +2106,8 @@ The formal description of the commands: additional features. \end{bewareofthedog} +\index{style file|)} + \subsection{\dots Print All Solutions Grouped by Section?} Here is an idea how to get a list of all solutions grouped by the section the corresponding exercises are appearing in. diff --git a/Master/texmf-dist/tex/latex/xsim/xsim-manual.cls b/Master/texmf-dist/tex/latex/xsim/xsim-manual.cls index 56121054dd8..23fb8db3f24 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim-manual.cls +++ b/Master/texmf-dist/tex/latex/xsim/xsim-manual.cls @@ -29,7 +29,7 @@ % please ignore the contents of this file -- it is not a good example for % coding... % -\ProvidesClass{xsim-manual}[2017/04/14] +\ProvidesClass{xsim-manual}[2017/09/18] \LoadClass[load-preamble,add-index]{cnltx-doc} \RequirePackage{imakeidx} @@ -185,6 +185,7 @@ DeclareFloatingEnvironment , enddescription , endtcolorbox , + hint , hoehe , iflist , IfNoValueTF , @@ -202,12 +203,14 @@ pkg , pointsandbonus , printA, printC, printE , + printhints , printcompletepoints , printsumofpointsandbonus , setlist , settasks , tcbuselibrary , tcolorbox , + thechapter , thesection , toprule , whileboolexpr , @@ -222,6 +225,21 @@ module-sep = {\texttt{/}}% } + +\RequirePackage[en-US]{datetime2} +\newrobustcmd*\xsim@add@version[2]{\csdef{xsimversion#1}{\DTMdate{#2}}} +\renewrobustcmd*\sinceversion[1]{% + \cnltx@version@note{\GetTranslation{cnltx-introduced}~#1 (\csuse{xsimversion#1})}% +} +\renewrobustcmd*\changedversion[1]{% + \cnltx@version@note{\GetTranslation{cnltx-changed}~#1 (\csuse{xsimversion#1})}% +} + +\newnote*\sincechanged[2]{\GetTranslation{cnltx-introduced}~#1 + (\csuse{xsimversion#1}), changed with version~#2 (\csuse{xsimversion#2})} + +\renewcommand*\versionnoteformat{\scriptsize\sffamily\RaggedRight} + \renewcommand*\cnltx@module@text[2]{% \begingroup \reversemarginpar @@ -569,6 +587,7 @@ } \DeclareExerciseCollection{foo} +\DeclareExerciseCollection{layouts} \newrobustcmd*\TF{% \colorlet{outside}{.}% @@ -582,6 +601,9 @@ \renewrobustcmd*\code[1]{\begingroup\codefont\let\^\textasciicircum#1\endgroup} +% ---------------------------------------------------------------------------- +\loadxsimstyle{layouts} + \DeclareExerciseEnvironmentTemplate{tcolorbox} {% \tcolorbox[ @@ -603,7 +625,7 @@ \IfInsideSolutionF{% \GetExercisePropertyT{points} { % notice the space - (\PropertyValue + (\printgoal{\PropertyValue} \IfExerciseGoalSingularTF{points} {\XSIMtranslate{point}} {\XSIMtranslate{points}})% @@ -613,50 +635,6 @@ } {\endtcolorbox} -\RequirePackage{needspace} - -\DeclareExerciseEnvironmentTemplate{runin} - {% - \par\vspace{\baselineskip} - \Needspace*{2\baselineskip} - \noindent - \textbf{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}}% - \GetExercisePropertyT{subtitle}{ \textit{#1}} % - \GetExercisePropertyT{points}{% - \marginpar{% - \PropertyValue - \GetExercisePropertyT{bonus-points}{+\PropertyValue}% - \,\IfExerciseGoalSingularTF{points} - {\XSIMtranslate{point}} - {\XSIMtranslate{points}}% - }% - }% - } - {} - -\DeclareExerciseEnvironmentTemplate{margin} - {% - \par\vspace{\baselineskip} - \Needspace*{2\baselineskip} - \noindent - \llap{% - \smash{% - \tabular[t]{@{}r@{}} - \textbf{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}} - \IfExercisePropertySetT{points}{% - \tabularnewline - (% - \GetExerciseProperty{points}% - \GetExercisePropertyT{bonus-points}{+#1}% - \,\XSIMtranslate{point-abbr}% - )% - }% - \endtabular - } % notice the space - }% - } - {} - \DeclareExerciseProperty*{bonus} \DeclareExerciseEnvironmentTemplate{bonus} {% @@ -685,6 +663,8 @@ } {} +% ---------------------------------------------------------------------------- + \DeclareExerciseType{problem}{ exercise-env = problem , solution-env = answer , @@ -696,6 +676,8 @@ \RequirePackage{hyperref,bookmark} +% ---------------------------------------------------------------------------- + \newcounter{examplefile} \newcounter{examplefiles} \newcommand*\xsim@add@example[1]{% @@ -703,22 +685,25 @@ \stepcounter{examplefiles}% } \newcommand*\listexamplefiles{% + \def\xsim@example@texfile@path##1{./examples/xsim.##1.tex}% + \def\xsim@example@pdffile@path##1{./examples/{xsim.##1}.pdf}% \def\do##1{% - \stepcounter{examplefile}% \begin{cnltxcode}[ + step and label={examplefile}{example:##1} , sidebyside align=top seam,sidebyside, righthand width=\linewidth/4, sidebyside gap=0pt, lower separated=false, - title=Example~\theexamplefile\ \enquote{##1} - \href{../examples/xsim.##1.tex}{\color{white}[\TeX]} - \href{../examples/xsim.##1.pdf}{\color{white}[PDF]}% + title=Example~\theexamplefile\ \enquote{\texttt{##1}} + \href{\xsim@example@texfile@path{##1}}{\color{white}[\TeX]} + \href{\xsim@example@pdffile@path{##1}}{\color{white}[PDF]}% ] - \lstinputlisting[style=cnltx,lastline=10]{../examples/xsim.##1.tex} + \bookmark[level=2,dest=examplefile.\arabic{examplefile}]{Example~\theexamplefile\ (##1)}% + \lstinputlisting[style=cnltx,lastline=10]{\xsim@example@texfile@path{##1}} \tcblower \fbox{% - \href{../examples/xsim.##1.pdf}{% - \includegraphics[width=.8\linewidth]{../examples/{xsim.##1}.pdf}}}% + \href{\xsim@example@pdffile@path{##1}}{% + \includegraphics[width=.8\linewidth]{\xsim@example@pdffile@path{##1}}}}% \end{cnltxcode} }% \dolistloop\xsim@examplefiles @@ -732,24 +717,65 @@ \xsim@add@example{description-list} \xsim@add@example{different-point-types} \xsim@add@example{difficulties} +\xsim@add@example{hints} \xsim@add@example{floating} \xsim@add@example{grade-distribution} \xsim@add@example{listings} \xsim@add@example{multiplechoice} +\xsim@add@example{listofexercises} \xsim@add@example{pointsums} \xsim@add@example{randomexercises} \xsim@add@example{various} +\xsim@add@example{texsx-13635} +\xsim@add@example{texsx-155630} \xsim@add@example{texsx-199360} \xsim@add@example{texsx-299534} \xsim@add@example{texsx-305110} +\xsim@add@example{texsx-308883} \xsim@add@example{texsx-338165} \xsim@add@example{texsx-350028} \xsim@add@example{texsx-369065} \xsim@add@example{texsx-369636} \xsim@add@example{texsx-369803} +\xsim@add@example{texsx-370642} +\xsim@add@example{texsx-391530} \xsim@add@example{texwelt-6698} \xsim@add@example{texwelt-15093} \xsim@add@example{golatex-16824} \xsim@add@example{golatex-18844} +% ---------------------------------------------------------------------------- + +\newcommand*\listlayouts{% + \def\do##1{% + \begin{cnltxcode}[{title=Layout \enquote{\texttt{##1}}}] + \ifcsdef{xsim@layout@extra@##1} + {\csuse{xsim@layout@extra@##1}} + {}% + \xsimsetup{exercise/template={##1}} + \let\marginpar\marginnote + \XSIMexpandcode{% + \printexercise{exercise}{\GetExerciseIdForProperty{ID}{showlayout}} + }% + \end{cnltxcode} + }% + \dolistloop\xsim@layouts +} + +\NewDocumentCommand\xsim@add@layout{mo}{% + \listadd\xsim@layouts{#1}% + \IfNoValueF{#2}{\csdef{xsim@layout@extra@#1}{#2}}% +} + +\xsim@add@layout{default} +\xsim@add@layout{runin}[\renewcommand*\theexercise{\arabic{exercise}.}] +\xsim@add@layout{margin}[\renewcommand*\theexercise{\arabic{exercise}.}] + +\xsim@add@version{0.8} {2017-05-18} +\xsim@add@version{0.8a} {2017-05-19} +\xsim@add@version{0.8b} {2017-05-23} +\xsim@add@version{0.9} {2017-06-20} +\xsim@add@version{0.10} {2017-09-19} + +% ---------------------------------------------------------------------------- \endinput diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.auxfile.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.auxfile.code.tex index 2a0f95846f3..2959a910915 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.auxfile.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.auxfile.code.tex @@ -179,4 +179,4 @@ { \seq_item:cn {g__xsim_list_recorded_#1_seq} {#2} } % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.base.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.base.code.tex index 30be8b9d18f..abec4de0501 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.base.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.base.code.tex @@ -166,4 +166,4 @@ { \keys_set:nn {xsim} {#1} } % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.blanks.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.blanks.code.tex index 323b7bd52f9..55b1db7cf45 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.blanks.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.blanks.code.tex @@ -29,6 +29,7 @@ \bool_new:N \l__xsim_blank_width_bool \bool_new:N \l__xsim_blank_linespread_bool +\bool_new:N \l__xsim_fill_blank_bool \tl_new:N \l__xsim_blank_linespread_tl \tl_new:N \l__xsim_blank_scale_tl \dim_new:N \l__xsim_blank_dim @@ -41,32 +42,34 @@ \keys_define:nn {xsim/blank} { - blank-style .code:n = + blank-style .code:n = \cs_set_protected:Npn \xsim_write_cloze_blank:n ##1 {#1} , - blank-style .initial:n = \underline {#1} , - filled-style .code:n = + blank-style .initial:n = \underline {#1} , + filled-style .code:n = \cs_set_protected:Npn \xsim_write_cloze_filled:n ##1 {#1} , - filled-style .initial:n = \underline {#1} , - style .meta:n = + filled-style .initial:n = \underline {#1} , + style .meta:n = { blank-style = #1 , filled-style = #1 } , - scale .tl_set:N = \l__xsim_blank_scale_tl , - scale .initial:n = 1 , - width .code:n = + fill .bool_set:N = \l__xsim_fill_blank_bool , + fill .initial:n = false , + scale .tl_set:N = \l__xsim_blank_scale_tl , + scale .initial:n = 1 , + width .code:n = { \bool_set_true:N \l__xsim_blank_width_bool \dim_set:Nn \l__xsim_blank_dim {#1} } , - linespread .code:n = + linespread .code:n = \bool_set_true:N \l__xsim_blank_linespread_bool \tl_set:Nn \l__xsim_blank_linespread_tl {#1} , - linespread .initial:n = 1 , - line-increment .dim_set:N = \l__xsim_blank_line_increment_dim , - line-increment .initial:n = 1pt , - line-minimum-length .dim_set:N = \l__xsim_blank_line_minimum_length_dim , - line-minimum-length .initial:n = 2em + linespread .initial:n = 1 , + line-increment .dim_set:N = \l__xsim_blank_line_increment_dim , + line-increment .initial:n = 1pt , + line-minimum-length .dim_set:N = \l__xsim_blank_line_minimum_length_dim , + line-minimum-length .initial:n = 2em } \cs_new_protected:Npn \xsim_blank:n #1 @@ -75,7 +78,8 @@ \mode_if_math:TF { \hbox_set:Nn \l__xsim_blank_box { $ \m@th \mathpalette{}{#1} $ } } { \hbox_set:Nn \l__xsim_blank_box {#1} } - \xsim_if_inside_solution:TF + \bool_if:nTF + { \xsim_if_inside_solution_p: || \l__xsim_fill_blank_bool } { \xsim_write_cloze_filled:n {#1} } { \bool_if:NTF \l__xsim_blank_width_bool @@ -103,9 +107,9 @@ { % I wonder what the correct l3 way would be -- if there is % one, yet: - \tex_hfil:D + % \tex_hfil:D \tex_penalty:D \hyphenpenalty - \tex_hfilneg:D + % \tex_hfilneg:D \dim_compare:nTF { \l__xsim_tmpa_dim < \l__xsim_blank_line_increment_dim } { \xsim_write_cloze_blank:n { \skip_horizontal:N \l__xsim_tmpa_dim } } @@ -117,12 +121,15 @@ } } } - { \xsim_write_cloze_blank:n { \skip_horizontal:N \l__xsim_tmpa_dim } } + { + \xsim_write_cloze_blank:n + { \skip_horizontal:N \l__xsim_blank_line_minimum_length_dim } + } } \cs_generate_variant:Nn \__xsim_blank_skip:n { V } % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: the following code from Heiko Oberdieck in d.c.t.t served as inspiration and basis for the \blank command: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.collections.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.collections.code.tex index 8bf0c0bc705..e3945e86a43 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.collections.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.collections.code.tex @@ -127,8 +127,9 @@ \xsim_if_collection_exists:nF {#1} { \msg_error:nnn {xsim} {unknown-collection} {#1} } \xsim_activate_collection:nn {#1} {#2} - \xsim_setup:n { #2/print = false } + \xsim_setup:x { \xsim_get_parameter:nn {#2} {exercise-env} /print = false } } +\cs_generate_variant:Nn \xsim_setup:n {x} % start collection for all exercise types: % #1: collection name @@ -139,7 +140,7 @@ { \msg_error:nnn {xsim} {unknown-collection} {#1} } \xsim_activate_collection:n {#1} \xsim_foreach_exercise_type:n - { \xsim_setup:n { ##1/print = false } } + { \xsim_setup:x { \xsim_get_parameter:nn {##1} {exercise-env} /print = false } } } % stop collection: @@ -392,4 +393,4 @@ } % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.definitions.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.definitions.code.tex index a30c44a76fc..824da2241ea 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.definitions.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.definitions.code.tex @@ -58,6 +58,7 @@ } \DeclareExerciseProperty {section-value} \DeclareExerciseProperty {section} +\DeclareExerciseProperty {sectioning} % those are additional and wouldn't *need* to be present except for % pre-defined templates which make use of them: @@ -183,9 +184,9 @@ \marginpar { \IfInsideSolutionF { \rule {1.2cm} {1pt} \slash } - \PropertyValue + \printgoal {\PropertyValue} \GetExercisePropertyT {bonus-points} - { \nobreakspace ( + \PropertyValue ) } + { \nobreakspace ( + \printgoal {\PropertyValue} ) } \nobreakspace\XSIMtranslate {point-abbr} } } @@ -427,4 +428,4 @@ } % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.environments.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.environments.code.tex index 43a46ab6146..aa89ce5ee2c 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.environments.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.environments.code.tex @@ -33,13 +33,29 @@ \tl_new:N \l__xsim_file_path_tl \tl_new:N \l__xsim_file_path_and_name_tl \tl_new:N \l__xsim_file_name_tl +\tl_new:N \l__xsim_file_extension_tl \bool_new:N \l__xsim_options_given_bool \bool_new:N \l__xsim_insert_mode_bool +\tl_new:N \ExerciseText +\tl_set:Nn \ExerciseText { \msg_error:nn {xsim} {only-in-solution} } + +% ---------------------------------------------------------------------------- + +\msg_new:nnn {xsim} {only-in-solution} + { + You~ can't~ use~ \token_to_str:N \ExerciseText \c_space_tl inside~ an~ + exercise.~ It~ is~ only~ allowed~ inside~ solution~ environments! + } + % ---------------------------------------------------------------------------- \keys_define:nn {xsim} - { path .tl_set:N = \l__xsim_file_path_tl } + { + path .tl_set:N = \l__xsim_file_path_tl , + file-extension .tl_set:N = \l__xsim_file_extension_tl , + file-extension .initial:n = tex + } % ---------------------------------------------------------------------------- @@ -68,7 +84,7 @@ \cs_generate_variant:Nn \__xsim_set_file_signature:nnn {nx,nV} \tl_set:Nn \l__xsim_file_name_tl - { \c_sys_jobname_str - \l__xsim_file_name_signature_tl -body.tex } + { \c_sys_jobname_str - \l__xsim_file_name_signature_tl -body . \l__xsim_file_extension_tl } \tl_set:Nn \l__xsim_file_path_and_name_tl { @@ -276,6 +292,13 @@ \xsim_set_properties:nnn {#1} {#2} { print=true , used=true } } + \str_if_eq:nnT {#4} {solution} + { + \__xsim_set_file_signature:nnn {#1} {#2} {exercise} + \tl_set_from_file:Nnn \ExerciseText {} + {\l__xsim_file_path_and_name_tl} + \tl_trim_spaces:N \ExerciseText + } \use:x { \xsim_use_hook:nnn {#1} {#4} {pre} @@ -283,7 +306,7 @@ {begin} { \xsim_get_parameter:nn {#1} {#4-template} } \xsim_use_hook:nnn {#1} {#4} {begin} - \file_input:n { \exp_not:V \l__xsim_file_path_and_name_tl } + \xsim_input:nnn {#1} {#2} {#4} \xsim_use_hook:nnn {#1} {#4} {end} \xsim_use_template:nn {end} @@ -293,12 +316,24 @@ \group_end: } { - \xsim_verbose:n + \xsim_verbose:x { File~ `\l__xsim_file_path_and_name_tl'~ doesn't~ exist. } } } \cs_generate_variant:Nn \xsim_insert:nnnn {nV,VV,nnnV} +% #1: type +% #2: id +% #3: exercise|solution +\cs_new_protected:Npn \xsim_input:nnn #1#2#3 + { + \group_begin: + \__xsim_set_file_signature:nnn {#1} {#2} {#3} + \file_input:n { \l__xsim_file_path_and_name_tl } + \group_end: + } +\cs_generate_variant:Nn \xsim_input:nnn {oo} + \prg_new_conditional:Npnn \xsim_if_insert_mode: {T,F,TF} { \bool_if:NTF \l__xsim_insert_mode_bool @@ -342,4 +377,4 @@ } % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.exercises.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.exercises.code.tex index 59434ec3071..185544564f5 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.exercises.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.exercises.code.tex @@ -65,6 +65,13 @@ exercise~ type~ `#2'. } +\msg_new:nnn {xsim} {unknown-parameter} + { + You~ tried~ to~ retrieve~ the~ parameter~ `#1'~ \msg_line_context: . \\ + This~ parameter~ does~ not~ exist.~ Check~ for~ a~ typo~ or~ \\ + define~ the~ parameter~ yourself. + } + % ---------------------------------------------------------------------------- \xsim_new_list:n {types} @@ -126,7 +133,7 @@ { \seq_map_inline:Nn \l__xsim_mandatory_parameters_seq { - \xsim_if_parameter:nnF {#1} {##1} + \xsim_if_parameter_set:nnF {#1} {##1} { \msg_error:nnnn {xsim} {mandatory-parameter} {##1} {#1} } } } @@ -148,7 +155,7 @@ { \xsim_if_parameter_fixed:nTF {#1} { - \xsim_if_parameter:nnTF {#1} {#2} + \xsim_if_parameter_set:nnTF {#1} {#2} { \msg_warning:nnnn {xsim} {parameter-fixed} {#1} {#2} \xsim_verbose:n @@ -178,13 +185,41 @@ { \prop_item:cn {l__xsim_#1_type_parameters_prop} {#2} } \cs_generate_variant:Nn \xsim_get_parameter:nn {o} -\prg_new_conditional:Npnn \xsim_if_parameter:nn #1#2 {p,T,F,TF} +\prg_new_conditional:Npnn \xsim_if_parameter_set:nn #1#2 {p,T,F,TF} { \prop_if_in:cnTF {l__xsim_#1_type_parameters_prop} {#2} { \prg_return_true: } { \prg_return_false: } } +\cs_new:Npn \__xsim_get_parameter_tmp:n #1 {} +\cs_generate_variant:Nn \__xsim_get_parameter_tmp:n {V} + +% #1: type +% #2: parameter +\cs_new_protected:Npn \xsim_get_parameter_if_set:nnTF #1#2#3#4 + { + \group_begin: + \xsim_if_parameter_exist:nTF {#2} + { + \xsim_if_parameter_set:nnTF {#1} {#2} + { + \tl_set:Nx \ParameterValue + { \xsim_get_parameter:nn {#1} {#2} } + \cs_set:Npn \__xsim_get_parameter_tmp:n ##1 {#3} + \__xsim_get_parameter_tmp:V \ParameterValue + } + {#4} + } + { \msg_error:nnn {xsim} {unknown-parameter} {#2} } + \group_end: + } +\cs_new_protected:Npn \xsim_get_parameter_if_set:nnT #1#2#3 + { \xsim_get_parameter_if_set:nnTF {#1} {#2} {#3} {} } +\cs_new_protected:Npn \xsim_get_parameter_if_set:nnF #1#2#3 + { \xsim_get_parameter_if_set:nnTF {#1} {#2} {} {#3} } +\cs_generate_variant:Nn \xsim_get_parameter_if_set:nnTF {o} + % ---------------------------------------------------------------------------- % inside the argument `#1' refers to the type \cs_new_protected:Npn \xsim_foreach_exercise_type:n #1 @@ -282,12 +317,12 @@ \xsim_set_parameter:nnx {#1} {number} { number of \xsim_get_parameter:nn {#1} {exercise-env} s } \xsim_check_mandatory_parameters:n {#1} - \xsim_if_parameter:nnF {#1} {counter} + \xsim_if_parameter_set:nnF {#1} {counter} { \xsim_set_parameters:nx {#1} { counter = \xsim_get_parameter:nn {#1} {exercise-env} } } - \xsim_if_parameter:nnF {#1} {solution-counter} + \xsim_if_parameter_set:nnF {#1} {solution-counter} { \xsim_set_parameters:nx {#1} { solution-counter = \xsim_get_parameter:nn {#1} {solution-env} } @@ -355,6 +390,12 @@ section-value = \arabic{section} , section = \thesection , page-value = \arabic{page} , + sectioning = + { \cs_if_exist:NTF \chapter { \arabic{chapter} } {0} } + { \arabic {section} } + { \arabic {subsection} } + { \arabic {subsubsection} } + { \arabic {paragraph} } , page = \thepage , used = false } @@ -512,4 +553,4 @@ } % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.goals.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.goals.code.tex index 8a881eb22ad..d537754fa72 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.goals.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.goals.code.tex @@ -139,7 +139,7 @@ % #3: value != 1 \cs_new_protected:Npn \xsim_print_goal:nnn #1#2#3 { - \__xsim_print_goal:n { \fp_to_decimal:n {#1} } + \__xsim_print_goal:x { \fp_to_decimal:n {#1} } \fp_compare:nTF { (#1) = 1 } {#2} {#3} } @@ -304,4 +304,4 @@ } % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.grades.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.grades.code.tex index 0fe0d162db5..141aaa3da3f 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.grades.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.grades.code.tex @@ -150,4 +150,4 @@ } % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.interface.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.interface.code.tex index b1006f49356..2c9f0c56449 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.interface.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.interface.code.tex @@ -53,6 +53,15 @@ % ---------------------------------------------------------------------------- +\ProvideDocumentCommand \IfExistSolutionTF {+m+m} + { \xsim_if_solution_exists:ooTF {\ExerciseType} {\ExerciseID} {#1} {#2} } + +\NewDocumentCommand \IfExistSolutionT {+m} + { \IfExistSolutionTF {#1} {} } + +\NewDocumentCommand \IfExistSolutionF {+m} + { \IfExistSolutionTF {} {#1} } + \NewExpandableDocumentCommand \IfInsideSolutionTF {+m+m} { \xsim_if_inside_solution:TF {#1} {#2} } @@ -138,8 +147,17 @@ \@onlypreamble \DeclareExercisePropertyAlias \NewDocumentCommand \SetExerciseProperty {mmm+m} + { \xsim_set_property:xxnn {\ExerciseType} {\ExerciseID} {#3} {#4} } + +\NewDocumentCommand \SetExpandedExerciseProperty {mmm+m} + { \xsim_set_property:xxnx {\ExerciseType} {\ExerciseID} {#3} {#4} } + +\NewDocumentCommand \ExerciseSetProperty {mmm+m} { \xsim_set_property:nnnn {#1} {#2} {#3} {#4} } +\NewDocumentCommand \ExerciseSetExpandedProperty {mmm+m} + { \xsim_set_property:nnnx {#1} {#2} {#3} {#4} } + \NewExpandableDocumentCommand \IfExercisePropertyExistTF {+m+m+m} { \xsim_if_property_exist:nTF {#1} {#2} {#3} } @@ -238,6 +256,36 @@ { \GetExerciseParameter {exercise-name} } } +\NewDocumentCommand \GetExerciseBody {m} + { \xsim_input:oon { \ExerciseType } { \ExerciseID } {#1} } + +\NewExpandableDocumentCommand \IfExerciseParameterSetTF {+m+m+m} + { \xsim_if_parameter_set:nnTF {\ExerciseType} {#1} {#2} {#3} } + +\NewExpandableDocumentCommand \IfExerciseParameterSetT {+m+m} + { \IfExerciseParameterSetTF {#1} {#2} {} } + +\NewExpandableDocumentCommand \IfExerciseParameterSetF {+m+m} + { \IfExerciseParameterSetTF {#1} {} {#2} } + +\NewExpandableDocumentCommand \ExerciseParameterIfSetTF {+m+m+m+m} + { \xsim_if_parameter_set:nnTF {#1} {#2} {#3} {#4} } + +\NewExpandableDocumentCommand \ExerciseParameterIfSetT {+m+m+m} + { \ExerciseParameterIfSetTF {#1} {#2} {#3} {} } + +\NewExpandableDocumentCommand \ExerciseParameterIfSetF {+m+m+m} + { \ExerciseParameterIfSetTF {#1} {#2} {} {#3} } + +\NewDocumentCommand \GetExerciseParameterTF {m+m+m} + { \xsim_get_parameter_if_set:onTF {\ExerciseType} {#1} {#2} {#3} } + +\NewDocumentCommand \GetExerciseParameterT {m+m} + { \GetExerciseParameterTF {#1} {#2} {} } + +\NewDocumentCommand \GetExerciseParameterF {m+m+m} + { \GetExerciseParameterTF {#1} {} {#2} } + % ---------------------------------------------------------------------------- \NewDocumentCommand \ExercisePropertyIfSetTF {mmm+m+m} @@ -548,6 +596,21 @@ % ---------------------------------------------------------------------------- +\NewDocumentCommand \printforexercises {sO{}+mO{}} + { + \IfBooleanTF {#1} + { + \xsim_foreach_exercise_type:n + { \xsim_print_type_code:nnnnn { \c_true_bool } {#2} {#4} {##1} {#3} } + } + { + \xsim_foreach_exercise_type:n + { \xsim_print_type_code:nnnnn { \c_false_bool } {#2} {#4} {##1} {#3} } + } + } + +% ---------------------------------------------------------------------------- + \NewDocumentCommand \xsimsetup {m} { \xsim_setup:n {#1} } @@ -562,4 +625,4 @@ { \xsim_if_chapter:F {#1} } % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.layouts.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.layouts.code.tex new file mode 100644 index 00000000000..3b94b6cc518 --- /dev/null +++ b/Master/texmf-dist/tex/latex/xsim/xsim.layouts.code.tex @@ -0,0 +1,77 @@ +% ---------------------------------------------------------------------------- +% the XSIM package - layouts style +% +% eXercise Sheets IMproved +% +% ---------------------------------------------------------------------------- +% Clemens Niederberger +% Web: https://github.com/cgnieder/xsim +% E-Mail: contact@mychemistry.eu +% ---------------------------------------------------------------------------- +% Copyright 2017 Clemens Niederberger +% +% This work 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. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Clemens Niederberger. +% ---------------------------------------------------------------------------- +% If you have any ideas, questions, suggestions or bugs to report, please +% feel free to contact me. +% ---------------------------------------------------------------------------- +\xsimstyle{layouts}[2017/09/14] + +\RequirePackage{needspace} + +\DeclareExerciseEnvironmentTemplate{runin} + {% + \par\vspace{\baselineskip} + \Needspace*{2\baselineskip} + \noindent + \textbf{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}}% + \GetExercisePropertyT{subtitle}{ \textit{#1}} % <<< notice the space + \IfInsideSolutionF{% + \GetExercisePropertyT{points}{% + \marginpar{% + \printgoal{\PropertyValue}% + \GetExercisePropertyT{bonus-points}{+\printgoal{\PropertyValue}}% + \,\IfExerciseGoalSingularTF{points} + {\XSIMtranslate{point}} + {\XSIMtranslate{points}}% + }% + }% + }% + } + {} + +\RequirePackage{array} + +\DeclareExerciseEnvironmentTemplate{margin} + {% + \trivlist + \item[\llap{% + \smash{% + \tabular[t]{@{}r@{}} + \textbf{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}} + \IfExercisePropertySetT{points}{% + \tabularnewline + (% + \printgoal{\GetExerciseProperty{points}}% + \GetExercisePropertyT{bonus-points}{+\printgoal{#1}}% + \,\XSIMtranslate{point-abbr}% + )% + }% + \endtabular + }% + }]\relax + } + {\endtrivlist} + +% ---------------------------------------------------------------------------- +\endinput diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.modules.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.modules.code.tex index 1e5d7d5cfa1..a2913f4ad80 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.modules.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.modules.code.tex @@ -191,21 +191,21 @@ % define a xsim module: % #1: name % #2: description -\NewDocumentCommand \XSIMmodule {mm} { \__xsim_module:nn {#1} {#2} -\ExplSyntaxOn } +\NewDocumentCommand \XSIMmodule {mm} + { \__xsim_module:nn {#1} {#2} \ExplSyntaxOn } % -------------------------------------------------------------------------- % style files -\NewDocumentCommand \xsimstyle {sm} +\NewDocumentCommand \xsimstyle {smO{}} { - \__xsim_module:nn {#2} {} - \IfBooleanF {#1} { \ExplSyntaxOn } + \__xsim_module:nn {#2} {#3} + \IfBooleanT {#1} { \ExplSyntaxOn } } \cs_new_protected:Npn \xsim_style_options:nn #1#2 { \keys_define:nn {xsim/#1} {#2} } -\NewDocumentCommand \loadxsimstyle {m} { \xsim_load_module:n {#1} } +\NewDocumentCommand \loadxsimstyle {m} { \xsim_load_modules:n {#1} } % -------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.properties.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.properties.code.tex index ec88d1be00a..a932faf4472 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.properties.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.properties.code.tex @@ -178,7 +178,7 @@ } { \msg_error:nnn {xsim} {unknown-property} {#3} } } -\cs_generate_variant:Nn \xsim_set_property:nnnn {nnxx,nnnV,nV,nVnx,nnnx} +\cs_generate_variant:Nn \xsim_set_property:nnnn {nnxx,nnnV,nV,nVnx,nnnx,xx,xxnx} \cs_new_protected:Npn \__xsim_set_boolean_property:nnnn #1#2#3#4 { @@ -416,9 +416,6 @@ { \prop_item:Nn \g__xsim_properties_prop { #2 ! #1 ! #3 } } \cs_generate_variant:Nn \xsim_get_property:nnn {nx,xx,oo,no,nnf,nf,oof,nV} -\cs_new:Npn \__xsim_get_property_tmp:n #1 {} -\cs_generate_variant:Nn \__xsim_get_property_tmp:n {V} - % #1: property % #2: value \cs_new:Npn \xsim_get_id_for_property:nn #1#2 @@ -430,6 +427,9 @@ { \prop_item:cn {g__xsim_property_#1_type_prop} {#2} } \cs_generate_variant:Nn \xsim_get_type_for_property:nn {nV} +\cs_new:Npn \__xsim_get_property_tmp:n #1 {} +\cs_generate_variant:Nn \__xsim_get_property_tmp:n {V} + % #1: type % #2: id % #3: property @@ -467,7 +467,8 @@ { \xsim_if_property_set:nnnTF {#1} {#2} {#3} { - \bool_if:cTF { c_ \xsim_get_property:nnn {#1} {#2} {#3} _bool} + \bool_if:cTF + {c_ \xsim_get_property:nnn {#1} {#2} {#3} _bool} { \prg_return_true: } { \prg_return_false: } } @@ -492,4 +493,4 @@ \cs_generate_variant:Nn \xsim_gsave_property:nnnN {nx,xx} % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.random.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.random.code.tex index 3120c800bd8..0730d04d454 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.random.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.random.code.tex @@ -304,4 +304,4 @@ % \xsim_get_id_for_property:nn {ID} {} % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.solutions.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.solutions.code.tex index 101c19aa23c..6855f635968 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.solutions.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.solutions.code.tex @@ -30,6 +30,7 @@ \xsim_load_modules:n {tags,properties} \bool_new:N \l_xsim_inside_solution_bool +\bool_new:N \l__xsim_include_question_bool \bool_new:N \l__xsim_printsolutions_headings_bool \bool_new:N \l__xsim_printsolutions_conditions_bool \bool_new:N \l____xsim_this_condition_bool @@ -79,14 +80,15 @@ % #1: type % #2: id -\prg_new_conditional:Npnn \xsim_if_solution_exists:nn #1#2 {T,F,TF} +\prg_new_protected_conditional:Npnn \xsim_if_solution_exists:nn #1#2 {T,F,TF} { \__xsim_set_file_signature:nnn {#1} {#2} {solution} \file_if_exist:VTF \l__xsim_file_path_and_name_tl { \prg_return_true: } { \prg_return_false: } } -\cs_generate_variant:Nn \xsim_if_solution_exists:nnT {VV} +\cs_generate_variant:Nn \xsim_if_solution_exists:nnT {VV,oo} +\cs_generate_variant:Nn \xsim_if_solution_exists:nnTF {oo} % #1: type % #2: options @@ -101,84 +103,65 @@ % ---------------------------------------------------------------------------- -% per section condition: -% #1: type -% #2: id -% #3: boolean property -\prg_new_protected_conditional:Npnn - \__xsim_if_solutions_per_section:nnn #1#2#3 {T,F,TF} +% #1: conditional base function (three n args)% #2: name +% #3: code (refer to type and id with `#1' and `#2'), #3 refers to the boolean +% properties use/print +\cs_new_protected:Npn \xsim_new_solutions_condition:Nnn #1#2#3 { - \xsim_if_in_list:nnTF {#3} {#1-#2=={true}} + \prg_new_protected_conditional:Npnn #1 ##1##2##3 {T,F,TF} { - \__xsim_printsolutions_if_condition:nTF {per-section} + \xsim_if_in_list:nnTF {##3} {##1-##2=={true}} { - \__xsim_printsolutions_condition_true: - \xsim_if_in_list:nxTF {section-value} - { #1-#2 == { \int_use:N \l_xsim_printsolutions_section_int } } - { - \tl_set:Nx \ExerciseSection - { \xsim_get_property:nnn {#1} {#2} {section} } - \prg_return_true: - } + \__xsim_printsolutions_if_condition:nTF {#2} + { \__xsim_printsolutions_condition_true: #3 } { \prg_return_false: } } { \prg_return_false: } } + } + +% per section condition: +\xsim_new_solutions_condition:Nnn \__xsim_if_solutions_per_section:nnn + {per-section} + { + \xsim_if_in_list:nxTF {section-value} + { #1-#2 == { \int_use:N \l_xsim_printsolutions_section_int } } + { + \tl_set:Nx \ExerciseSection + { \xsim_get_property:nnn {#1} {#2} {section} } + \prg_return_true: + } { \prg_return_false: } } % per chapter condition: -% #1: type -% #2: id -% #3: boolean property -\prg_new_protected_conditional:Npnn - \__xsim_if_solutions_per_chapter:nnn #1#2#3 {T,F,TF} +\xsim_new_solutions_condition:Nnn \__xsim_if_solutions_per_chapter:nnn + {per-chapter} { - \xsim_if_in_list:nnTF {#3} {#1-#2=={true}} + \xsim_if_in_list:nxTF {chapter-value} + { #1-#2 == { \int_use:N \l_xsim_printsolutions_chapter_int } } { - \__xsim_printsolutions_if_condition:nTF {per-chapter} - { - \__xsim_printsolutions_condition_true: - \xsim_if_in_list:nxTF {chapter-value} - { #1-#2 == { \int_use:N \l_xsim_printsolutions_chapter_int } } - { - \tl_set:Nx \ExerciseChapter - { \xsim_get_property:nnn {#1} {#2} {chapter} } - \prg_return_true: - } - { \prg_return_false: } - } - { \prg_return_false: } + \tl_set:Nx \ExerciseChapter + { \xsim_get_property:nnn {#1} {#2} {chapter} } + \prg_return_true: } { \prg_return_false: } } % per collection condition: -% #1: type -% #2: id -% #3: boolean property -\prg_new_protected_conditional:Npnn - \__xsim_if_solutions_in_collection:nnn #1#2#3 {T,F,TF} +\xsim_new_solutions_condition:Nnn \__xsim_if_solutions_in_collection:nnn + {per-collection} { - \xsim_if_in_list:nnTF {#3} {#1-#2=={true}} + \tl_if_blank:VTF \l__xsim_printsolutions_collection_tl + { \prg_return_false: } { - \__xsim_printsolutions_if_condition:nTF {per-collection} - { - \__xsim_printsolutions_condition_true: - \tl_if_blank:VTF \l__xsim_printsolutions_collection_tl - { \prg_return_false: } - { - \xsim_if_in_collection:VnnTF - \l__xsim_printsolutions_collection_tl - {#1} - {#2} - { \prg_return_true: } - { \prg_return_false: } - } - } + \xsim_if_in_collection:VnnTF + \l__xsim_printsolutions_collection_tl + {#1} + {#2} + { \prg_return_true: } { \prg_return_false: } } - { \prg_return_false: } } % ---------------------------------------------------------------------------- @@ -206,7 +189,7 @@ % #1: name % #2: condition -\cs_new_protected:Npn \__xsim_declare_printsolutions_condition:nn #1#2 +\cs_new_protected:Npn \xsim_declare_printsolutions_condition:nn #1#2 { \bool_new:c {l__xsim_printsolutions_#1_condition_bool} \prop_put:Nnn \l__xsim_printsolutions_conditions_prop {#1} {#2} @@ -270,25 +253,26 @@ % ---------------------------------------------------------------------------- % #1: boolean -- if true only the solutions of printed exercises will be % output -% #2: options -% #3: type -\cs_new_protected:Npn \xsim_print_type_solutions:nnn #1#2#3 +% #2: pre +% #3: post +% #4: type +% #5: code (refer to type with #1 and id with #2) +\cs_new_protected:Npn \xsim_print_type_code:nnnnn #1#2#3#4#5 { - \xsim_verbose:n - { Printing~ solutions~ for~ exercise~ type~ `#3'. } \group_begin: - \keys_set:nn {xsim/print-solutions} {#2} + \cs_set_protected:Npn \__xsim_print_entry:nn ##1##2 {#5} + #2 \bool_set_false:N \l__xsim_tmpa_bool \bool_if:nTF {#1} { - \xsim_if_solutions_do:nnn {#3} {print} + \xsim_if_solutions_do:nnn {#4} {print} { \bool_set_true:N \l__xsim_tmpa_bool } } { - \xsim_if_solutions_do:nnn {#3} {use} + \xsim_if_solutions_do:nnn {#4} {use} { \bool_set_true:N \l__xsim_tmpa_bool } } - \tl_set:Nn \ExerciseType {#3} + \tl_set:Nn \ExerciseType {#4} \bool_if:NT \l__xsim_tmpa_bool { \bool_if:NT \l__xsim_printsolutions_headings_bool @@ -300,19 +284,38 @@ } \bool_if:nTF {#1} { - \xsim_if_solutions_do:nnn {#3} {print} - { \xsim_insert:nnnn {#3} {##2} {} {solution} } + \xsim_if_solutions_do:nnn {#4} {print} + { \__xsim_print_entry:nn {#4} {##2} } } { - \xsim_if_solutions_do:nnn {#3} {use} - { \xsim_insert:nnnn {#3} {##2} {} {solution} } + \xsim_if_solutions_do:nnn {#4} {use} + { \__xsim_print_entry:nn {#4} {##2} } } + #3 \group_end: } % #1: boolean -- if true only the solutions of printed exercises will be % output % #2: options +% #3: type +\cs_new_protected:Npn \xsim_print_type_solutions:nnn #1#2#3 + { + \xsim_print_type_code:nnnnn + {#1} + { + \xsim_verbose:n + { Printing~ solutions~ for~ exercise~ type~ `#3'. } + \keys_set:nn {xsim/print-solutions} {#2} + } + {} + {#3} + { \xsim_insert:nnnn {##1} {##2} {} {solution} } + } + +% #1: boolean -- if true only the solutions of printed exercises will be +% output +% #2: options \cs_new_protected:Npn \xsim_print_all_solutions_per_type:nn #1#2 { \xsim_foreach_exercise_type:n @@ -348,11 +351,11 @@ % ---------------------------------------------------------------------------- -\__xsim_declare_printsolutions_condition:nn {per-section} +\xsim_declare_printsolutions_condition:nn {per-section} { \__xsim_if_solutions_per_section:nnnTF } -\__xsim_declare_printsolutions_condition:nn {per-chapter} +\xsim_declare_printsolutions_condition:nn {per-chapter} { \__xsim_if_solutions_per_chapter:nnnTF } -\__xsim_declare_printsolutions_condition:nn {per-collection} +\xsim_declare_printsolutions_condition:nn {per-collection} { \__xsim_if_solutions_in_collection:nnnTF } % ---------------------------------------------------------------------------- @@ -363,6 +366,8 @@ headings .initial:n = true , headings-template .tl_set:N = \l__xsim_printsolutions_headings_template_tl , headings-template .initial:n = default , + include-exercise .bool_set:N = \l__xsim_include_question_bool , + include-exercise .initial:n = false , section .choice: , section/true .code:n = \__xsim_printsolutions_condition:nn {per-section} {true} @@ -399,4 +404,4 @@ % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.sty b/Master/texmf-dist/tex/latex/xsim/xsim.sty index 7bc7248c47e..b7ce1cf4b3f 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.sty +++ b/Master/texmf-dist/tex/latex/xsim/xsim.sty @@ -29,10 +29,10 @@ \ExplSyntaxOn -\tl_const:Nn \c_xsim_date_tl {2017/05/19} +\tl_const:Nn \c_xsim_date_tl {2017/09/19} \tl_const:Nn \c_xsim_version_major_number_tl {0} -\tl_const:Nn \c_xsim_version_minor_number_tl {8} -\tl_const:Nn \c_xsim_version_subrelease_tl {a} +\tl_const:Nn \c_xsim_version_minor_number_tl {10} +\tl_const:Nn \c_xsim_version_subrelease_tl {} \tl_const:Nx \c_xsim_version_number_tl { \c_xsim_version_major_number_tl . @@ -106,4 +106,4 @@ \AtEndDocument { \xsim_do_rerun: } -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.tags.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.tags.code.tex index b438afb203e..57e0dfd38bf 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.tags.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.tags.code.tex @@ -61,7 +61,7 @@ { \c_false_bool } { \c_false_bool } {#1} - \__xsim_declare_printsolutions_condition:nn {#1} + \xsim_declare_printsolutions_condition:nn {#1} { \__xsim_printsolutions_if_tagged:nnnnTF {#1} } \keys_define:nn {xsim/print-solutions} { @@ -89,7 +89,6 @@ \__xsim_printsolutions_if_condition:nTF {#1} { \__xsim_printsolutions_condition_true: - % TODO: doesn't return anything \xsim_if_tagged:nnnTF {#2} {#3} {#1} { \prg_return_true: } { \prg_return_false: } @@ -192,4 +191,4 @@ \cs_generate_variant:Nn \xsim_exercise_tags_use:nnnnnn {oo} % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.templates.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.templates.code.tex index f08ff904b4c..fa62e3f96c4 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.templates.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.templates.code.tex @@ -169,4 +169,4 @@ \cs_generate_variant:Nn \xsim_use_template:nn {nx,nV} % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.translations.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.translations.code.tex index a52d3708632..83feaf8169d 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.translations.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.translations.code.tex @@ -143,4 +143,4 @@ } % ---------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.verbwrite.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.verbwrite.code.tex index ae0338463b1..748550657d5 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.verbwrite.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.verbwrite.code.tex @@ -189,7 +189,7 @@ \NewDocumentCommand \XSIMfilewritestart {sm} { \IfBooleanTF {#1} - { \xsim_file_write_start:nn { \c_false_bool } {#2} } + { \xsim_file_write_start:nn { \c_false_bool } {#2} } { \xsim_file_write_start:nn { \c_true_bool } {#2} } } @@ -206,3 +206,4 @@ { \int_set:Nn \l_xsim_line_gobble_int {#1} } % ---------------------------------------------------------------------------- +\file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsimverb.sty b/Master/texmf-dist/tex/latex/xsim/xsimverb.sty index da6ab48c9ee..ec5fbd14dde 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsimverb.sty +++ b/Master/texmf-dist/tex/latex/xsim/xsimverb.sty @@ -63,4 +63,4 @@ \xsim_load_module:n {verbwrite} % -------------------------------------------------------------------------- -\tex_endinput:D +\file_input_stop: |