cgnieder / xsim Goto Github PK
View Code? Open in Web Editor NEWeXercise Sheets IMproved
eXercise Sheets IMproved
See also my comments here, sorry if I made them in the wrong place.
To summarize, the issue is that the global variables \ExerciseID
and \ExerciseType
(and also the internal \g_xsim_exercise_id_tl
) are only set whenever entering (any custom type of) the exercise environment. This works when having a flat structure of exercises. But when using a structure similar to Example 30: Exercises and sub-exercises (and which is also commonly used for exams) this behaviour breaks because right before the end of the parent exercise, but already after the end of any child exercises, the current exercise variable will still point to the last child exercise (see the image here, where the last line should read "/ID 1", but actually says "/ID 3"). This is a problem for templates that use this variable after the exercise content, but may also prevent solutions (esp. solutions for the parent exercise) from using the correct exercise ID.
My initial approach to fix this was reverting the changes to the global variables made in \xsim_start_exercise
using a post-hook (or alternatively \xsim_stop_exercise
). This fixed the wrong values in the end part of templates and also yielded a nice way of accessing the hierarchical exercise structure through the container
property. Unfortunately, this made the solution-ID problem worse.
I guess the underlying issue is that there are different views on what the "current exercise" variable should actually point to:
\xsim_start_exercise
and is not changed when an exercise ends. This means that the previously used exercise is still available as "current" even after it ended, which allows for the correct linking with the respective solution (and also allows all the property accessor commands to function outside of - or more precisely after - an exercise environment within the remaining document). Unfortunately, this also leads to this exact bug when nesting exercises.\xsim_start_exercise
and revert to the parent value in \xsim_stop_exercise
, which is empty for root-level exercises. Outside of any exercise this value must be empty, as otherwise some form of nesting would be implied. This is the behaviour my code implements.So maybe this one variable should be split into multiple one up to cater the different needs:
\ExerciseID
variable for end-users with mostly the same semantics as now, but a fix for using it after nested child exercises@cgnieder what do you think about this proposal? If it sounds good to you, I can try to implement this and open a PR. Alternatively, this functionality could be implemented in an opt-in fashion, but I'm unsure how to realize this. Maybe this could be done by adding hooks that don't interfere with other hooks set by the user (if that is possible) and using XSIM modules?
It's nice that xsim
emits a warning when the user needs to rerun latex, but would be even better if the message followed the standard (message starting the line exactly with: Package xsim Warning:
), so that editors can easily catch the message. \PackageWarning
macro would work.
Having to deal with custom message for each single package isn't particularly fun :-)
I've previously used the exsheets
package and now want to migrate to xsim
. I've installed The MacTeX-2017 Distribution which comes with xsim
. According to my .log
file I'm using version 0.8a
of xsim
and I note that the latest version of xsim
is 0.11
.
Note: It may be that my problem goes away if I manage to upgrade xsim
to version 0.11
, something I'm currently don't know how to do.
From the xsim
manual section 13.2 Templates Provided by the Package:
default
, runin
and margin
.runin
and margin
layouts are "Available through the style file layouts".How do I activate the runin
or margin
layouts?
I've found the definitions of runin
and margin
in xsim.style.layouts.code.tex
If I try:
\loadxsimstyle{runin}
, I get the following error.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! xsim error: "module-missing"
!
! You've requested the xsim module `runin' but it appears to be missing on
! your system. Maybe you've misspelled the name? Loading the module will abort
! on line 5
!
! See the xsim documentation for further information.
!
! Type <return> to continue.
!...............................................
l.5 \loadxsimstyle{runin}
Do I have to manually create the style files or inline the template definitions listed in the following sections?
Or, do I need to upgrade to xsim
version 0.11
?
Trying to give a hidden folder (i.e., a folder whose name starts with a .
on Linux systems) as a "path" results in error. I.e., even if the folder ".cache" exists, the following won't compile:
\documentclass{article}
\usepackage{xsim}
\xsimsetup{path = {.cache}}
\begin{document}
\begin{exercise}
Hello
\end{exercise}
\end{document}
While, of course, having the folder named "cache" (without the dot) and setting the path accordingly would work.
Is that a feature? A bug? I think it would be convenient to be able to store the aux files in a hidden file.
xsim
is not compatible to beamer
. Both packages defines the environment solution
. But even after undefinind the beamer
one, there are issues:
\documentclass{beamer}
% Beamer already has a solution environment which will be renamed here
\makeatletter
\@ifclassloaded{beamer}{%
%%% save beamer's `solution' environment as `beamersolution':
\let\beamersolution\solution
\let\endbeamersolution\endsolution
%%% "delete" the `solution' environment:
\let\solution\relax
\let\endsolution\relax
}{%
}%
\makeatother
\usepackage[verbose]{xsim}
\begin{document}
\begin{frame}
\frametitle{Testing \emph{xsim}}
\begin{itemize}
\item First item.
\item An exercise:
\begin{exercise}
This is an exercise.
\end{exercise}
\end{itemize}
\end{frame}
\end{document}
Compilation:
$ pdflatex xsim-beamer.tex
[...]
No file xsim-beamer.nav.
(/alt/texlive/2017-NixOS/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/alt/texlive/2017-NixOS/texmf-dist/tex/latex/amsfonts/umsb.fd)
! Missing number, treated as zero.
<to be read again>
\c@paragraph
l.29 \end{frame}
?
Please, make xsim
usable with beamer
.
What does the mean of ?There are eight commands in all. I do not understand them. And who can tell me how to use these eight commands and give me some examples of these eight commands.
Thanks.
1. exercise/pre-hook={code}, (initially empty)
2. exercise/begin-hook={code}, (initially empty)
3. exercise/end-hook={code}, (initially empty)
4. exercise/post-hook={code}, (initially empty)
5. solution/pre-hook={code}, (initially empty)
6. solution/begin-hook={code}, (initially empty)
7. solution/end-hook={code}, (initially empty)
8. solution/post-hook={code}, (initially empty)
After updating my texlive packages, I get an error using xsimverb
standalone.
Compiling
\documentclass{article}
\usepackage{xsimverb}
\begin{document}
Bla
\end{document}
produces the following error:
! Undefined control sequence.
<argument> \g_xsim_use_aux_bool
l.69 \xsim_if_use_aux:F
Using \usepackage{xsim}
(instead of \usepackage{xsimverb}
) causes no error.
If printsolution is used in the document, the following error is displayed with the current version of l3kernel:
! LaTeX3 Error: File '' not found.
If you continue compiling, the solution will be displayed correctly in the result document.
I have a problem with xsim.
I didn´t change anything on my file using xsim. If I build the texfile, all my exercises and solutions are empty (not displaying any content). I recently updated on Mactex 2019.
If I switch back to Mactex 2018, everything works fine.
I tested switching to an older version of xsim in Mactex 2019, but that didn´t solve the problem, so the problem isn´t in xsim itself. There has to be a side effect with the new Mactex. Can anybody give me a hint where the problem can be found?
Here is my code:
\documentclass[a4paper,oneside, 12pt]{scrartcl}
\usepackage{xsim}
\begin{document}
Text 1
\begin{exercise}
Text 2
\end{exercise}
Text 3
\end{document}
and the result:
Text 1
Exercise 1
Text 3
Thanks in advance,
Mirko
As can be seen from my question here, I inadvertently attempted to redefine the solution
environment and got an error for it. An immediate workaround was to use other words, such as solutions
(with an s), hints
, discussion
, answer
. But since I was not using the default exercise
environment with its solution
environment, it seemed like a shame to have that most venerable word wasted. So I'm wondering if it would be possible to have an option to not load the default environments, such that the keywords solution
and related could be used for customized environments.
And before signing off, a big cheers for a wonderful package.
Hello,
I have a problem with the latest version of xsim 0.18.
At some point, I use
\SetExpandedExerciseProperty{points}{\theexpoints}
multiple times in an exercise to generate "Teilleistungen" as subparts of solutions with individual points that are summed up to the exercise points at the end of the exercise.
Maybe this solution is not the best or easiest way to achive this, but it worked fine up to version 0.16.
Today I updated to 0.18 and it doesn´t work anymore. The exercise points sum is always 0.
After the downgrade to 0.16 it works again. I didn´t check 0.17.
Is this an error or is my workaround to implement "Teilleistungen" not supported any more?
Thanks,
Mirko
I love the feature, that I can collect exercises, that way I can create 2 groups of tests in one file, without needing to copy paste everything.
One thing though, the \gradingtable
includes all the exercises, even those that aren't printed. Would it be possible to get something similar to \printsolutions*
which only includes the exercises, that will be printed. Like \gradingtable*
On a side node, I would love to rename the points again, that was possible in exsheets
but got lost in xsim
.
Thanks!
Ideas for xsim:
autopoints:
can xsim sum the points (set with addpoints) automatic? After a first look, i think it's possible with a small change of the syntax, right?
Use \addpoints in solution:
When i create a exam then i write down my solution and set points afterwards. With the help of the autopoints exsheets print the points automatic. But i have to set the addpoints in the question env. It's possible to make \addpoints usable in a solution env and xsim prints the sumpoints in the exercise env?
Variations of an Exam:
the exsheet's \SetVariations function is missing. For me it's a useful function. In "Future Plans" have you mentioned it.
I like the "Collecting Exercises" feature! 👍
Now i convert my exsheets template to a xsim template.
Please see the minimal example below:
\documentclass[oneside, 11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}
\usepackage[verbose]{xsim}
\DeclareExerciseTranslation{exercise}{spanish}{ejercicio}
\DeclareExerciseTranslation{solution}{spanish}{solución}
% The alernative way of declaring translations works OK:
%\DeclareExerciseTranslations{exercise}{
% Fallback = exercise,
% English = exercise,
% Spanish = ejercicio
%}
%\DeclareExerciseTranslations{solution}{
% Fallback = solution,
% English = solution,
% Spanish = solución
%}
\xsimsetup{
solution/print = true
}
\begin{document}
\begin{exercise}
Primer ejercicio
\end{exercise}
\begin{solution}
La solución al primer ejercicio
\end{solution}
\end{document}
I tried to use xsim for a (tufte-)book, since I need verbatim in the solutions, but couldn't compile. Here is a minimal version.
\documentclass{book}
\usepackage{xsim}
\begin{document}
\chapter{xyz}
\begin{exercise}
jk
\end{exercise}
\end{document}
It gives ! File ended while scanning use of ^^M.
System info:
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./bug.tex
LaTeX2e <2017/01/01> patch level 3
It has no effect when you set the \gradingtable
options with \xsimsetup
.
\documentclass{article}
\usepackage{xsim}
\xsimsetup{
grading-table/template = default*,
}
\begin{document}
\begin{exercise}[points=4]
\end{exercise}
\begin{exercise}[points=4,bonus-points=10]
\end{exercise}
\gradingtable[type = exercise]
\end{document}
The grading table uses the default template and not the default*
BTW: grading-table/type = exercise
has no effect, too.
Greets
Make \TotalExerciseGoal[s]
and maybe \TotalExerciseTypeGoal[s]
expandable to use the number in other commands. See here.
For instance I calculate percentages of different goals of the total sum of the points.
Thanks! (also for this package)
I quite often see, and myself create, exercises which consist of multiple subexercises or parts, like this:
# Exercise 1
Two cars are traveling in opposite directions.
They are 2.7km apart, driving 50km/h and 65km/h, respectively.
a) Write the equations of motion for the two cars.
b) Find the time t at which the two cars will meet.
c) Find the distance traveled by the cars when they meet.
As far as I can see, this is not a feature directly provided by the xsim
package. Any recommendations on how to achieve this by other means?
A solution with the enumerate
or itemize
environment works, but maybe there are other ways.
\begin{exercise}
Two cars travel ....
\begin{enumerate}
\item Write the equations ...
\item Find the time ...
\item Find the distance ...
\end{enumerate}
\end{exercise}
Enable a syntax like the following?
\printsolutions[chapter=2,section=2-4]
Just out of curiosity I've been going through the xsim.ideas
file and I've realized that maybe in the future there is xsim-exam
(which would be great). Let me explain a little, the xsim
package is powerful when it comes to writing well a text related to problems and solutions, it covers all requirements, but sometimes you need something a little simpler (simpler is relative).
In my usual work (and that of many teachers in my country) I occupy lists of exercises very similar to the ones that straggled me in the practices in my years of university, of the type:
Instruction: Solve ALL ...and only a large list of problems and exercises numbered from 1 to 30.
In my country this is the literal translation of "eXercise Sheets", yes, without further instructions and hopefully the answers to the odd exercises, nothing much explained as a solution, just a short answer x=1
and ready.
The second and quite common are the multiple selection tests (they are actually single selection, but that's how they're known). Where the alternatives are of the type
A. A) (A) a. a) (a)
and other variants, where the official one is A)
in the national tests.
In both cases the design is almost always delegated to the good enumitem
package, the difficulty is in being able to keep the keys of the alternatives and the answers.
An image to be better understood:
This is where my proposal comes into play, for xsim-exam
probably, I read in one of your comments that you want to keep xsim
as simple as possible. With the following code:
\documentclass{article}
\usepackage{xparse,letltxmacro,enumitem,multicol} % need
\usepackage[margin=1in,noheadfoot,papersize={8.5in,13in}]{geometry} % for mwe
\ExplSyntaxOn
\LetLtxMacro{\oldenum}{\enumerate}
\LetLtxMacro{\oldendenum}{\endenumerate}
\tl_new:N \l_keyans_columns_tl
\tl_new:N \l_keyans_enumitem_tl
\tl_new:N \l_keyans_name_seq_tl
\bool_new:N \l_keyans_save_ans_bool
\bool_new:N \l_keyans_save_key_bool
\RenewDocumentEnvironment{enumerate}{ O{} }
{
\tl_clear:N \l_keyans_enumitem_tl
\keys_set:nn { keyans } { columns = 1, #1 }
\_keyans_beginenum:V \l_keyans_enumitem_tl
\int_compare:nT { \l_keyans_columns_tl > 1 }
{
\setlength{ \columnsep }{ \l_keyans_colsep_dim }
\raggedcolumns\begin{multicols}{ \l_keyans_columns_tl }
}
}
{
\int_compare:nT { \l_keyans_columns_tl > 1 }
{ \end{multicols} }
\oldendenum
\bool_if:NT \l_keyans_save_ans_bool
{ \end{saveanswer} }
\bool_if:NT \l_keyans_save_key_bool
{ \end{savekeyans} }
}
\cs_new_protected:Npn \_keyans_beginenum:n #1
{
\bool_if:NT \l_keyans_save_ans_bool
{
\__keyans_store_current_id:n{ \l_keyans_name_seq_tl }
\begin{saveanswer}{ \l_keyans_name_seq_tl }
}
\bool_if:NT \l_keyans_save_key_bool
{
\__keyans_store_current_id:n{ \l_keyans_name_seq_tl }
\begin{savekeyans}{ \l_keyans_name_seq_tl }
}
\oldenum[#1]
}
\cs_generate_variant:Nn \_keyans_beginenum:n {V}
\keys_define:nn { keyans }
{
col-sep .dim_set:N = \l_keyans_colsep_dim,
col-sep .initial:n = 15pt,
columns .tl_set:N = \l_keyans_columns_tl,
columns .initial:n = 1,
save-ans .code:n = {
\bool_set_true:N \l_keyans_save_ans_bool
\tl_set:Nn \l_keyans_name_seq_tl { #1 }
},
save-key .code:n = {
\bool_set_true:N \l_keyans_save_key_bool
\tl_set:Nn \l_keyans_name_seq_tl { #1 }
},
unknown .code:n = \tl_put_right:Nx \l_keyans_enumitem_tl
{ \l_keys_key_tl \tl_if_empty:nF { #1 } { = \exp_not:n { #1 } } , }
}
\prop_new:N \g_keyans_admin_prop
\cs_new_protected:Npn \__keyans_store_current_id:n #1
{ \prop_gput:Nnn \g_keyans_admin_prop {current-id} {#1} }
\cs_new_protected:Npn \__keyans_retrieve_current_id:n
{ \prop_item:Nn \g_keyans_admin_prop {current-id} }
\NewDocumentEnvironment{saveanswer}{ m }
{
\setlist[enumerate,1]{left=0pt, labelsep=5pt, noitemsep, nosep, label=\small\arabic*.}
\setlist[enumerate,2]{before={\__keyans_step_down_level:},after={\__keyans_step_up_level:},%
leftmargin=16pt,nosep,itemsep=0pt,label=(\alph*)}
\setlist[enumerate,3]{before={\__keyans_step_down_level:},after={\__keyans_step_up_level:},%
leftmargin=20pt,nosep,itemsep=0pt,label=\Roman*.}
\seq_if_exist:cF { g_keyans_saved_#1_seq }{ \seq_new:c { g_keyans_saved_#1_seq }}%
}{}
\NewDocumentCommand{\answer}{ +m }
{
\seq_gput_right:cn { g_keyans_saved_ \__keyans_retrieve_current_id:n _seq } { \item #1 }
\par
}
\NewDocumentEnvironment{savekeyans}{ m }
{
\setlist[enumerate,1]{left=0pt,labelsep=5pt,itemsep=1pt,label=\arabic*.}
\setlist[enumerate,2]{leftmargin=16pt,nosep,label=\Alph*)}
\seq_if_exist:cF { g_keyans_saved_#1_seq }{ \seq_new:c { g_keyans_saved_#1_seq }}
}{}
\NewDocumentCommand{\keyans}{ !o }
{
\IfNoValueTF{ #1 }
{
\tl_set:Nn \l_tmpa_tl { \protect\item }
\tl_put_right:Nx \l_tmpa_tl { \protect\space \Alph{enumii} }
\seq_gput_right:cV { g_keyans_saved_ \__keyans_retrieve_current_id:n _seq }{ \l_tmpa_tl }
\par
}
{
\seq_gput_right:cn { g_keyans_saved_ \__keyans_retrieve_current_id:n _seq }{ \item #1 }
\par
}
}
% \__keyans_step_down_level: and \__keyans_step_up_level: for save in nested enumerate
\cs_new_protected:Nn \__keyans_step_down_level:
{
\seq_gput_right:cn { g_keyans_saved_ \__keyans_retrieve_current_id:n _seq }
{ \item \begin{enumerate} }
}
\cs_new_protected:Nn \__keyans_step_up_level:
{
\seq_gput_right:cn { g_keyans_saved_ \__keyans_retrieve_current_id:n _seq }
{ \end{enumerate} }
}
% Display \answer{...} and \keyans[...] saved in list by id
\cs_new_protected:Npn \__keyans_print_anskey:nn #1#2
{
\seq_if_empty:cF { g_keyans_saved_#1_seq }
{
\begin{enumerate}[#2]
\seq_map_inline:cn { g_keyans_saved_#1_seq } { ##1 }
\end{enumerate}
}
}
\NewDocumentCommand{ \printkeyans }{ O{columns=2} +m }
{
\setlist[enumerate,1]{left=0pt, labelsep=5pt, noitemsep, nosep, label=\small\arabic*.}
\setlist[enumerate,2]{leftmargin=16pt,nosep,itemsep=0pt,label=(\alph*)}
\setlist[enumerate,3]{leftmargin=20pt,nosep,itemsep=0pt,label=\Roman*.}
\small
\__keyans_print_anskey:nn {#2}{#1}
}
\ExplSyntaxOff
\pagestyle{empty}
\begin{document}
\section{List of exercises}
Solve and answer the following exercises.
\begin{enumerate}[save-ans=Worksheet,left=0pt,labelsep=5pt,nosep,label=\arabic*.,columns=2]
\item Factor $x^{2}-2x+1$ \answer{$\left(x-1\right)^{2}$}
\item Factor $3x+3y+3z$ \answer{$3(x+y+z)$}
\item True False
\begin{enumerate}
\item $\alpha > \delta$ \answer{False}
\item \LaTeX2e\ is cool? \answer{Very True!}
\end{enumerate}
\item Related to Linux
\begin{enumerate}
\item You use linux? \answer{Yes}
\item Usually uses the package manager? \answer{Yes}
\item Rate the following package and class
\begin{enumerate}
\item xsim-exam \answer{doesn't exist for now :(}
\item xsim \answer{very good}
\item exsheets \answer{obsolete}
\end{enumerate}
\end{enumerate}
\end{enumerate}
\subsection{Response to exercises}
\printkeyans{Worksheet}
\section{Single alternative selection test}
Mark only one of the alternatives in each question.
\begin{enumerate}[save-key=choices,left=0pt,columns=2]
\item First type of questions
\begin{enumerate}
\item value
\item value
\item value
\item correct \keyans
\item value
\end{enumerate}
\item Second type of questions
\begin{enumerate}[leftmargin=2pc,label=\Roman*.]
\item $2\alpha+2\delta=90^{\circ}$
\item $\alpha=\delta$
\item $\angle EDF=45^{\circ}$
\end{enumerate}
\begin{enumerate}[columns=2,col-sep=10pt]%
\item I only
\item II only \keyans
\item I and II only
\item I and III only
\item I, II, and III
\end{enumerate}
\item Third type of questions
\begin{enumerate}[leftmargin=2pc,label=(\arabic*)]
\item $2\alpha+2\delta=90^{\circ}$
\item $\angle EDF=45^{\circ}$
\end{enumerate}
\begin{enumerate}
\item Alternativa A
\item Alternativa B
\item Alternativa C \keyans
\item Alternativa D
\item Alternativa E
\end{enumerate}
\item Fourth type of question, a problem with numerical response \keyans[$\sqrt{2}$]
\end{enumerate}
\subsection{Keys and Answers for test}
\printkeyans[columns=4]{choices}
\end{document}
I can save the answers and keys of the tests in a sequence (expl3), it is not a silver bullet and it is not written at the level of xsim
:(. To have a functionality of this style (I think) that would be an addition to this great project.
Greetings and thanks for the great contribution.
Pablo
I'm getting an error when I compile documents where an exercise subtitle contains the pipe |
character. Here's a MWE:
% test.tex
\documentclass{article}
\usepackage{xsim}
\begin{document}
\begin{exercise}[subtitle={$|w|$}]
Hello, world!
\end{exercise}
\end{document}
When I run pdflatex test.tex
twice, the second run throws an error:
Runaway argument?
$\q_stop \tl_set_rescan:Nnx \l__xsim_tmpc_tl {}{\l__xsim_tmpc_str }\__xsim_set_
property:VVnV \ETC.
! File ended while scanning use of \__xsim_extract_property_list_entry:NNNwww.
<inserted text>
\par
<*> test.tex
(Although, looking at the generated PDF, the document appears OK. But it makes me nervous.)
Hello,
I am using two exercise types, the generic exercise and a custom defined one.
Both are using the same template for the exercise and the solution part.
The main function of my exercise-template:
Printing the question, leaving empty space below if solution exists AND solution/print is false or alternatively using the same space to show the solution in tcolorbox.
This works perfectly for the exercise-environment. However, in the self-defined question environment this does not work. The template produces empty spaces and the headings are correct, but the body of the solution is not printed. It seems like \IfInsideSolutionTF
is not detecting the solution environment.
MWE:
\documentclass[]{article}
\usepackage{lipsum,tcolorbox,needspace,xsim}
% XSIM Settings
\xsimsetup{
path=cache,
file-extension=aux,
blank/blank-style={#1},
blank/filled-style=\textcolor{blue}{#1},
blank/line-minimum-length=2cm,
solution/print=true
}
\SetExerciseParameters{exercise}{
exercise-name = \XSIMtranslate{exercise},
exercise-template = exercise,
solution-template = exercise,
counter = section,
counter-within = chapter
}
\DeclareExerciseType{question}{
exercise-env = question,
solution-env = answer,
exercise-name = \XSIMtranslate{question},
solution-name = \XSIMtranslate{solution},
exercise-template = exercise,
solution-template = exercise
}
\newlength{\defaultsolutionspace}
\setlength{\defaultsolutionspace}{2cm}
\newlength{\solutionspace}
\setlength{\solutionspace}{\defaultsolutionspace}
\DeclareExerciseProperty{solutionspace}
\DeclareExerciseEnvironmentTemplate{exercise}{%
\IfExercisePropertySetTF{solutionspace}{
\setlength{\solutionspace}{\GetExerciseProperty{solutionspace}}
}{\setlength{\solutionspace}{\defaultsolutionspace}}
\IfInsideSolutionTF{
\tcolorbox[
detach title,
title = \XSIMtranslate{solution},
before upper = {\tcbtitle\par} ,
fonttitle = \bfseries,
fontupper = \normalsize,
valign = top,
colframe = black!20!white,
colback = black!3!white,
coltext = black,
coltitle = black,
height = \solutionspace,
boxrule = 0.5pt,
width = \linewidth,
left = 2mm,
sharp corners
]
}{
\needspace{\solutionspace}
\subsection*{%
\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}
\GetExercisePropertyT{subtitle}{~\normalfont\itshape\PropertyValue}%
\GetExercisePropertyT{points}{~\normalfont(\PropertyValue~P)}
\GetExercisePropertyT{ID}{\label{ex:\PropertyValue}}
}
}
}{
\IfInsideSolutionTF{\endtcolorbox}{
% fill out template
\IfSolutionPrintF{
\IfExistSolutionT{
\tcolorbox[
detach title,
fonttitle = \bfseries,
fontupper = \normalsize,
valign = top,
colframe = white,
colback = white,
coltext = blue,
coltitle = black,
height = \solutionspace,
boxrule = 0.5pt,
width = \linewidth,
left = 2mm,
sharp corners
]
\endtcolorbox
}
}
}
}
\begin{document}
\begin{question}[points=2,solutionspace=3cm]
\lipsum[2]
\end{question}
\begin{answer}
\lipsum[2]
\end{answer}
\begin{exercise}[points=2,solutionspace=5cm]
\lipsum[2]
\end{exercise}
\begin{solution}
\lipsum[2]
\end{solution}
\end{document}
Any ideas?
\documentclass{article}
\usepackage{xsim}
\DeclareExerciseCollection{test}
\xsimsetup{print-solutions/headings=false}
\begin{filecontents*}{testproblems.tex}
\begin{exercise}[ID=one]
Exercise one.
\end{exercise}
\begin{solution}
Answer one.
\end{solution}
\begin{exercise}[ID=two]
Exercise two.
\end{exercise}
\begin{solution}
Answer two.
\end{solution}
\begin{exercise}[ID=three]
Exercise three.
\end{exercise}
\begin{solution}
Answer three.
\end{solution}
\end{filecontents*}
\begin{document}
\collectexercises{test}
\input{testproblems.tex}
\collectexercisesstop{test}
\printrandomexercises[collection=test,exclude=two]{3}
\printsolutions
\end{document}
Hello, the following file does not compile after updating TeXLive today:
\documentclass{article}
\usepackage{xsim}
\usepackage{unicode-math}
\begin{document}
$a+b$
\end{document}
show
Package filehook Warning: Macro \InputIfFileExists got redefined after 'filehoo
k' was loaded.
Certain file hooks might now be dysfunctional! on input line 4.
This is related to another of your packages (https://tex.stackexchange.com/q/512189/7832). Any particular reason not to use the package directly filehook
package?.
Saludos
I've got a document with exercises and lots of images which I'm externalising with TikZ to speed up compilation times. Due to some conflict between how externalize
works and XSIM, my images directory is getting filled up with multiple copies of all the exercises—one set of all of them for each externalised image.
I've attached a working example to demonstrate; it's more of a maximal working example as I just made a subset of the aforementioned document.
The TikZ external system call expects a directory called tikz
to exist in the same folder as the github-xsim-bug.tex
, and to compile it you'll need to call lualatex
once, followed by make -f github-xsim-bug.makefile
, followed by a second lualatex
invocation. The main file does compile with plain pdflatex
, but the externalisation itself uses luatex
. Once it's all compiled, you should get the main document, a set of images in tikz/
, and a set of every exercise/solution pair for every image.
The TikZ external/mode=list and make
is easier on my system's memory—and much quicker to compile—but commenting out line 43 will revert to the usual forking method using -shell-escape
or -write18
. Both methods still cause XSIM to spit out lots of additional files that are never actually used.
github-xsim-bug.txt
(Github wouldn't let me upload *.tex
so I renamed it *.txt
.)
@cgnieder
Hello professor.
When I was studying the manual in the Section7.4 on page 16&17.
In the above example on page 16 , Command \xsimsetup{tags/ingore-untagged=false}
use "ingore".
However, "ignore" is used in the introduction of option tags/ignore-untagged = true|false
andtopics/ignore-untagged = true|false
on page 17.
But "ingore" is not in English.The n and g in the word "ignore" are inverted.
The correct word is "ignore", but the correct compilation can be made using "ingore" in the macro package.
Ignore or ingore?
In addition,I am a user is trying to study this macro package, but almost no one around me to learn or use this macro package, so I am in the process of learning to produce a lot of confusion, but I sometimes don't solve these questions, so only here to ask you for help. And my English is not high, so some sentences or grammar is not smooth, hope your understanding. Hope get your more help and guidance. Thank you very much.
My MWE.
\documentclass{article}
\usepackage{xsim}
\ProvideExerciseTagging{tags}
\ProvideExerciseTagging{topics}
\DeclareExerciseTagging{diff}
\xsimsetup{%
diff={easy,medium}
}
\xsimsetup{%
tags/ingore-untagged=true ,
%If <ingore> is used correctly, <ignore> is used incorrectly
topics/ingore-untagged=true%
}
\begin{document}
%1
\begin{exercise}[diff=easy,tags=A01]
My exercise1
\end{exercise}
\begin{solution}
My Answer1
\end{solution}
%2
\begin{exercise}[diff=medium,tags=A02]
My exercise2
\end{exercise}
\begin{solution}
My Answer2
\end{solution}
%3
\begin{exercise}[tags=A02 ,topics=AAA]
My exercise3
\end{exercise}
\begin{solution}
My Answer3
\end{solution}
\end{document}
Hi Clemens, you could add a grid and oval (using l3draw :), something like this:
Useful for writing high school exams.
\documentclass{article}
\usepackage{l3draw}
\begin{document}
\ExplSyntaxOn
% grid
\draw_begin:
\draw_linewidth:n { 0.5pt }
\draw_color:n { yellow!80!black } % OK
\draw_path_grid:nnnn
{ 0.5cm } { 0.5cm } { 0cm , 0cm } { \linewidth , 2cm }
\draw_path_use_clear:n { stroke }
\draw_end:
\ExplSyntaxOff
\par
\ExplSyntaxOn
% oval
\draw_begin:
\draw_path_corner_arc:nn { 1mm } { 1mm }
\draw_path_rectangle_corners:nn
{ 0cm , 0cm } { \linewidth , 2cm }
\draw_path_use_clear:n { stroke }
\draw_end:
\ExplSyntaxOff
\end{document}
Saludos
What does the mean of <addto*goal>s in the section 7 on page 14 of the Manual ? There are four commands in all . I tried a lot of things, but they all went wrong . I can't figure out where to put them ? And how to use these commands ? Do you need to match other commands ? Please give me some examples of these eight commands .
Thanks a lot .
This is my MWE.
\documentclass{article}
\usepackage{xsim}
\begin{document}
\begin{exercise}[points=1]
First.
\end{exercise}
\begin{exercise}[points=2]
Second.
\end{exercise}
\begin{exercise}[points=3]
Third.
\end{exercise}
%\AddtoExerciseGoal{points}{2}
%\AddtoExerciseTypeGoal{exercise}{points}{3}
%\AddtoExerciseTypeGoalPrint{points}{4}{\,\XSIMtranslate{point}}{\,\XSIMtranslate{points}}
%\AddtoExerciseTypeGoalPrint{exercise}{points}{5}{\,\XSIMtranslate{point}}{\,\XSIMtranslate{points}}
\end{document}
I generally use
\xsimsetup{
path=xsim-temp
}
so that xsim
writes its files to a subdirectory.
Would it be possible for xsim
to automatically create such directories?
And of course: Thanks for this package. I'm really excited about using verbatim
and pythontex
environments directly in the exercises.
In my exams I use multiplechoice questions. The example in the xsim
doc is working, but the in \gradingtable
the multiplechoice questions are printed after the “normal” exercises. This is logical, because the \gradingtable
distinguishes between the types.
My question is: is it possible to declare a multiplechoice exercise type with the printed order of the questions in the \gradingtable
?
\documentclass{scrartcl}
\usepackage[clear-aux]{xsim}
\usepackage{enumitem,amssymb,fmtcount}
\newlist{choices}{itemize}{1}
\setlist[choices]{label=$\Box$}
\newcommand*\choice{\item}
\DeclareExerciseProperty{choices}
\DeclareExerciseProperty*{multiple}
\DeclareExerciseEnvironmentTemplate{mc}
{%
\UseExerciseTemplate{begin}{default}%
\IfExerciseBooleanPropertyTF{multiple}
{Select one or more correct answers}
{%
\GetExercisePropertyT{choices}
{Select \numberstringnum{#1} correct answer\ifnum#1>1 s\fi.}%
}%
\begin{choices}
}
{%
\end{choices}
\UseExerciseTemplate{end}{default}%
}
\DeclareExerciseType{mc}{
exercise-env = multiplechoice ,
solution-env = correctchoices ,
exercise-name = mc-Question ,
solution-name = mc-Solution ,
exercise-template = mc ,
solution-template = mc ,
counter = exercise
}
\xsimsetup{
exercise/name = Question ,
solution/name = Solution
}
\begin{document}
\section{Questions}
\begin{multiplechoice}[choices=1,points=1]
\choice one
\choice two
\choice three
\choice four
\end{multiplechoice}
\begin{exercise}[points=5]
Answer this question on a separate sheet.
\end{exercise}
\begin{multiplechoice}[multiple,points=3]
\choice one
\choice two
\choice three
\choice four
\end{multiplechoice}
\begin{exercise}[points=9]
Answer this question on a separate sheet.
\end{exercise}
\gradingtable[template = default*]
\end{document}
As a workaround I used the multiplechoice task
environment of the tasks
package and use a normal exercise
environment.
I created thís issue to clean the discussion. So in #1 i mentioned the function of autopoints. I would specify a little bit.
So
\begin{exercise}
\begin{tasks}
\task task1
\task task2
\end{tasks}
\end{exercise}
\begin{solution}
\begin{tasks}
\task solution if task1 \subpoints{3}
\end{tasks}
\begin{tasks}[resume]
\task solution if task2 \subpoints{2}
\end{tasks}
\end{solution}
would prints
Exercise 1 5points
a) task1 (3points)
b) task2 (2points)
More like a limitation. The following worked:
\newcommand*{\mytoprule}{\IfInsideSolutionF{0pt}\IfInsideSolutionT{2pt}}
\DeclareExerciseEnvironmentTemplate{tcb}{toprule = \mytoprule}
but the following resulted in ! Missing = inserted for \ifdim.
error:
\DeclareExerciseEnvironmentTemplate{tcb}{toprule = \IfInsideSolutionF{0pt}\IfInsideSolutionT{2pt}}
I expected the above to work because the following does work:
\DeclareExerciseEnvironmentTemplate{tcb}{coltext = \IfInsideSolutionF{black}\IfInsideSolutionT{red}}
It seems that all the color
options work with that construct, while the rule
options fail (boxrule
, titlerule
, etc).
\documentclass{article}
\usepackage{xsim}
\DeclareExerciseCollection{foo}
\usepackage{filecontents,lipsum}
\begin{filecontents*}{foo.tex}
\begin{exercise}[points=1]
foo one \lipsum[4]
\end{exercise}
\begin{solution}
foo one \lipsum[4]
\end{solution}
\begin{exercise}[points=2]
foo two \lipsum[4]
\end{exercise}
\begin{solution}
foo two \lipsum[4]
\end{solution}
\begin{exercise}[points=3]
foo three \lipsum[4]
\end{exercise}
\begin{solution}
foo three \lipsum[4]
\end{solution}
\end{filecontents*}
\begin{document}
\collectexercises{foo}
\input{foo.tex}
\collectexercisesstop{foo}
\printrandomexercises[collection=foo]{1}
% prints 6 instead of either 1, 2, or 3:
Total: \printtotalpoints
\end{document}
Hello, by adding in xsim.collections.tex
\RequirePackage[enable-debug]{expl3}
\ExplSyntaxOn
\debug_on:n { check-declarations , deprecation }
\ExplSyntaxOff
\usepackage{xsim}
Displays a number of errors, for example:
Runaway definition?
#1->\tl_set:Nx \l_tmpa_tl {\tl_trim_spaces:n {#1}}
! Forbidden control sequence found while scanning definition of \xsim_load_modu
le:n.
<inserted text>
}
l.69 \str_if_eq_x:nnTF
{ \l_tmpa_tl } {modules}
?
! Undefined control sequence.
<argument> \LaTeX3 error:
'\str_if_eq_x:nnTF' deprecated on 2020-01-01. Use '\str_if_eq:e
l.69 \str_if_eq_x:nnTF
{ \l_tmpa_tl } {modules}
I don't know if it's a false positive or maybe it needs some maintenance.
Greetings
Pablo
Hello,
I'm converting all my exsheets exercises to xsim, so far it works really well. I found out that if the document is compiled with synctex one can only jump to the files named:
*-exercise-body.tex
Is there a way to jump directly to the source code and not to the *-body.tex files?
synctex is a very very convinent way to work with - especially for long documents...
Regards
Thorsten
Hello, thank you for the package!
I'm currently porting our exercises from exsheets to xsim, and noticed a strange behaviour. Up to now, we used the following structure for crossreferencing:
\begin{exTask}[name=Verarbeitung]\label{checksum}
...
\end{exTask}
However, with xsim, the label is not correctly set afterwards. However, it works when the \label
command is placed on a new line. The problem seems to be that any content that is on the same line as the start of the environment is acutally emitted before the environment is started.
MWE:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{xsim,lipsum,xcolor}
\begin{document}
\begin{exercise}[subtitle=lipsum] ASDF
\lipsum[1]
\end{exercise}
\end{document}
Thank your for your effort!
The package xsim
uses the macro NewExpandableDocumentCommand
added in the 2017-03-07 release of xparse
. What about an error message to inform the users when xparse
is too old ?
With \loadxsimstyle{schule-default}
and file named xsim.style.schule-default.code.tex
(Manual page 49) I get:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! xsim error: "module-missing"
!
! You've requested the xsim module `schule-default' but it appears to be
! missing on your system. Maybe you've misspelled the name? Loading the module
! will abort on line 59
!
! See the xsim documentation for further information.
!
! Type <return> to continue.
!...............................................
l.59 \loadxsimstyle{schule-default}
If file named xsim.schule-default.code.tex
(until v0.10), I get:
! Argument of \ProvidesFile has an extra }.
<inserted text>
\par
l.3 \xsimstyle{schule-default}
I am looking for a solution to use the content of an exercise directly in the solution. With the multiplechoice example from the package Task, the following should be possible:
\begin{mcExercise}
\begin{multiplechoice}
\choice First choice
\choice Second choice
\choice[\correct] Third choice
\end{multiplechoice}
\end{mcExercise}
instead of:
\begin{exercise}
\begin{multiplechoice}
\choice First choice
\choice Second choice
\choice[\correct] Third choice
\end{multiplechoice}
\end{exercise}
\begin{solution}
\begin{multiplechoice}
\choice First choice
\choice Second choice
\choice[\correct] Third choice
\end{multiplechoice}
\end{solution}
\documentclass{article}
\usepackage{xsim}
\begin{document}
\begin{exercise}[points=50] % hello world
\end{exercise}
\end{document}
The commented line % hello world
is shown in the output document.
We use some scripts which compile every tex-file and add the tex-file and the generated PDF-file to a website. The *-exercise-body.tex
files create errors in this context: This tex
-files are not a standalone document and can not compile to a pdf-File and should not be part of the website.
Is it possible to use another file extension instead of tex
? For example, xsim
or xex
could be used.
I can't use xsimverb
standalone anymore. The example 3 (code-and-output) also doen't work anymore:
! Undefined control sequence.<argument> \g_xsim_final_bool \begin{example}
Using \usepackage{xsim}
(instead of \usepackage{xsimverb}
) causes no error.
Hello, first of all, grateful for the great work with xsim
, I have a suggestion (or idea) that I can maybe implement in xsim
, I know that writing external files is necessary because of verbatim
can not be used as an argument in macros, but, in some replies on tex.sx:
and pythontex
package, they manage not to use external files and save verbatim
material using scantokens
. Could you implement this in xsim
?
Saludos
I'm currently working on migrating a collection of exercises to XSIM. Thanks for this cool package and its large number of features!
In my case, all exercises are collected in a separate "database" tex file and then only some of them are used in separate tex files, one for each exercise sheet. The exercises are selected based on their title string, which was implemented using \csname
:
% master.tex
\newcommand{\defex}[2]{%
\expandafter\newcommand\csname exercise#1\endcsname{#2}%
}
\newcommand{\useex}[1]{ %
\section{#1} %
\csname exercise#1\endcsname
}
% database.tex
\defex{The $P=NP$ Problem}{Prove that $P=NP$.}
% sheet1.tex
\useex{The $P=NP$ Problem}
I tried to mimic this approach with XSIM by defining a new property title
, and then finding the right exercises using \GetExerciseIdForProperty
and printing them via \printexercise
:
\DeclareExerciseProperty!{title}
\newcommand{\printexercisewithtitle}[1]{%
\edef\foundid{\GetExerciseIdForProperty{title}{#1}}%
\ifthenelse{\equal{\foundid}{}}{%
No exercise with title ''#1'' found!\\
}{%
\printexercise{exercise}{\foundid}%
}%
}
A mwe can be found here.
Unfortunately, the indirection via \GetExerciseIdForProperty
doesn't work with \printexercise
, as for all exercises included using this macro, the counter is not incremented (all show up as Exercise 1) and not all properties are accessible (e.g. the fourth one doesn't show a subtitle):
Only the second one, which is included by directly passing its ID
2 to \printexercise
shows up correctly. The cause of this can be found in the aux-file, where e.g. the values for counter
are recorded as follows:
\XSIM {counter}{exercise-\foundid =={1}||exercise-2=={1}}
So this is probably caused by some problems with expansion of the macro. Unfortunately, throwing in \XSIMexpandcode
in various places didn't help. I was only able to partialy fix this problem by introducing a further level of indirection with the following macros (see also the linked mwe):
\newcommand{\printexercisewithtitle}[1]{%
\printexercisewithtitleproxy
{#1}
{\GetExerciseIdForProperty{title}{#1}}%
}
\newcommand{\printexercisewithtitleproxy}[2]{%
\ifthenelse{\equal{#2}{}}{%
No exercise with title "#1" found!\\
}{%
\printexercise{exercise}{#2}%
}%
}
Now at least the counter is displayed correctly, even though it's recorded keys are still wrong (but at least they are unique):
\XSIM {counter}{exercise-\GetExerciseIdForProperty {title}{Erste}=={1}||exercise-\GetExerciseIdForProperty {title}{W\"eird ßt$u$ff}=={3}||exercise-\GetExerciseIdForProperty {title}{Vierte}=={4}||exercise-\GetExerciseIdForProperty {title}{Letzte}=={5}||exercise-2=={1}}
The (sub-)titles to be displayed in the heading are still broken:
They seem to be recorded correctly, but they are probably looked up using exercise-\GetExerciseIdForProperty {title}{Erste}
as key instead of their actual ID
.
\XSIM {subtitle}{exercise-2=={Zweite}||exercise-4=={Die Vierte}}
\XSIM {title}{exercise-1=={Erste}||exercise-3=={W\"eird ßt$u$ff}||exercise-4=={Vierte}||exercise-5=={Letzte}||exercise-6=={Letzte}}
My question is now how to define \printexercisewithtitle
properly to ensure the right amount of enpasion for the looked-up ID
s.
If you \printsolution while on the german version, The title is "Lösung zu den Aufgabeen", which is one E to many.
In some contexts we have included in the schule package not only exercises and solutions but also tips on the exercises. This is used for example at http://ddi.uni-wuppertal.de/material/materialsammlung/oberstufe/automaten/leitprogramm_automaten.pdf.
We want to have this in the new version of the schule package, which now fully relies on xsim. It would be possible to integrate these tips directly into the schule package. But I see it more in xsim. I would therefore also offer to support this enlargement.
I have some exercises with ID,and I want to use these commands \printrandomexercises[exclude = {D}]{2}
and \printrandomexercises[exclude = {5}]{2}
and \printrandomexercises[exclude = {D,5}]{2}
to output two exercises.But the system didn`t compile and reported an error:
! Undefined control sequence.
\__clist_map_1:w ...:nn {ID}{#1}}\tl_if_blank:NTF
\l__xsim_tmpa_tl {\seq_put...
l.67 \printrandomexercises[exclude = {D}]{2}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
I can't get the result. How can I modify it to compile correctly?
This is my code:
\documentclass{article}
\usepackage[clear-aux]{xsim}
\DeclareExerciseCollection{foo}
\usepackage{filecontents}
\begin{filecontents}{random.tex}
\begin{exercise}[ID=A]
exercise A
\end{exercise}
\begin{solution}
solution A
\end{solution}
\begin{exercise}[ID=B]
exercise B
\end{exercise}
\begin{solution}
solution B
\end{solution}
\begin{exercise}[ID=C]
exercise C
\end{exercise}
\begin{solution}
solution C
\end{solution}
\begin{exercise}[ID=D]
exercise D
\end{exercise}
\begin{solution}
solution D
\end{solution}
\begin{exercise}[ID=E]
exercise E
\end{exercise}
\begin{solution}
solution E
\end{solution}
\begin{exercise}[ID=F]
exercise F
\end{exercise}
\begin{solution}
solution F
\end{solution}
\end{filecontents}
\begin{document}
\collectexercises{foo}
\input{random.tex}
\collectexercisesstop{foo}
\section*{Exercises}
\printrandomexercises[exclude = {D}]{2}
\printrandomexercises[exclude = {5}]{2}
\printrandomexercises[exclude = {D,5}]{2}
\end{document}
Sorry. My English is little.Please forgive me if there is any wrong expression.
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{xsim}
\begin{document}
\begin{exercise}
foo
\end{exercise}
\begin{solution}
foo
\end{solution}
\printsolutions
\end{document}
prints Lösungen zu den Exerciseen
First of all, great work, thank you.
What would be an approach to have multiple columns of short exercises, like in the image below? It seems like a waste of space to have one whole line for 5 symbols, but it would also be nice to have them numbered and handled by the xsim package.
Is it a a \begin{exercise}...\end{exercise}
for each of the many small exercises, or is it one exercise environment containing another enumerative environment?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.