Skip to content
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

\GetExercideBody{solution} does not work as expected #90

Closed
mw88-personal opened this issue Sep 27, 2021 · 4 comments
Closed

\GetExercideBody{solution} does not work as expected #90

mw88-personal opened this issue Sep 27, 2021 · 4 comments

Comments

@mw88-personal
Copy link

mw88-personal commented Sep 27, 2021

I try to use \GetExerciseBody{solution} inside an exercise environment. However, it only outputs the body of the exercise. See the following MWE attached:

\documentclass[]{article}
\usepackage{xsim}
\usepackage{framed}

% XSIM Settings
\xsimsetup{
    solution/print=true
}


\SetExerciseParameters{exercise}{
    exercise-name = \XSIMtranslate{exercise},
    exercise-template = exercise,
    solution-template = solution,
    counter = section,
}



\DeclareExerciseEnvironmentTemplate{solution}{%
    \subsection{Solution}
    \begin{framed}
}{
    \end{framed}

    \subsubsection{\textbackslash GetExerciseBody\{solution\} inside solution template:}
    \begin{framed}
    \GetExerciseBody{solution}
\end{framed}
    \subsubsection{\textbackslash GetExerciseBody\{exercise\} inside solution template:}
    \begin{framed}
    \GetExerciseBody{exercise}
\end{framed}
}

\DeclareExerciseEnvironmentTemplate{exercise}{%
    \subsection{Exercise}
    \begin{framed}
}{
    \end{framed}

    \subsubsection{\textbackslash GetExerciseBody\{solution\} inside exercise template:}
    \begin{framed}
    \GetExerciseBody{solution}
\end{framed}
    \subsubsection{\textbackslash GetExerciseBody\{exercise\} inside exercise template:}
    \begin{framed}
    \GetExerciseBody{exercise}
\end{framed}
}





\begin{document}
\begin{exercise}%[points=2]
    This is exercise 1.
\end{exercise}


\begin{solution}
    This is solution 1.\\
    It is long\\
    and \\
    it needs to be\\
    to check inconsistencies.
\end{solution}

\end{document}

mwe.pdf

Instead, I expect to be able to access both, exercise and solution, from inside both templates, i.e. the box under 1.1.1 should be equal to 1.2.1.
This seems like a bug to me.

I'm using texlive, lualatex and xsim 2021/02/03 v0.20c

@muzimuzhi
Copy link

It seems xsim v0.20 uses a print immediately new scheme, which is not the case with v0.19b (you can test with v0.19b on overleaf.com, texlive 2020).

For a workaround, collecting then printing all the material works. The required changes are:

  • Change \xsimsetup{solution/print=true} to \xsimsetup{collect=true} and
  • Add \printcollection[print=both]{all exercises} just before \end{document}.

If your exercise/solution body ever contains verbatim material, you'll need the use-files package option.

@mw88-personal
Copy link
Author

At first glance, your proposed workaround seems to work in my MWE. I'll try and implement it in my lecture notes to see if the first impression holds. Thank you.

However, it still is (for me as a beginner with xsim) not intuitive to use your workaround, so I believe this should still be considered a bug

@muzimuzhi
Copy link

[...] so I believe this should still be considered a bug

I think so. Getting exercise body from \getExerciseBody{solution} used in an environment template without any warnings/errors is clearly a bug.

cgnieder added a commit that referenced this issue Jan 5, 2022
@cgnieder
Copy link
Owner

cgnieder commented Jan 5, 2022

This is an error in \__xsim_save_environment_body:nnnn and is now fixed.

@cgnieder cgnieder closed this as completed Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants