-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using \printexercise with a macro breaks the index in the .aux file #54
Comments
Please, can you reduce this into one compilable file (maybe with a |
There is one: test1.tex in the linked gist is independently compileable, no need for additional files or If you need an example that is really as minimal as it can get, use this one and ignore everything said above 😉 \documentclass{article}
\usepackage{xsim}
\DeclareExerciseProperty!{title}
\newcommand{\printexercisewithtitle}[1]{%
\edef\foundid{\GetExerciseIdForProperty{title}{#1}}%
\printexercise{exercise}{\foundid}%
}
\DeclareExerciseCollection{foo}
\begin{document}
\collectexercises{foo}
\begin{exercise}[title={Erste},subtitle={Die Erste}]
The first exercise is added to the collection `foo'.
\end{exercise}
\begin{exercise}[title={Zweite},subtitle={Die Zweite}]
The second exercise is also added to the collection `foo'.
\end{exercise}
\collectexercisesstop{foo}
\printexercisewithtitle{Erste}
\printexercisewithtitle{Zweite}
\printexercise{exercise}{1}
\printexercise{exercise}{2}
\end{document} The output looks like this: |
The issue seems to be similar to what you explained here on stackexchange. |
You are right, this is the same issue. I'll add |
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
: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
: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 forcounter
are recorded as follows: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):Now at least the counter is displayed correctly, even though it's recorded keys are still wrong (but at least they are unique):
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 actualID
.My question is now how to define
\printexercisewithtitle
properly to ensure the right amount of enpasion for the looked-upID
s.The text was updated successfully, but these errors were encountered: