# Replicaing some exsheets features in xsim

My exsheets templates no longer compile after a recent LaTeX update and so I thought that rather than downgrading TeX, it might be better just upgrade my templates. Unfortunately, I'm struggling to extract the information I want from the manual.

I have two things I am trying to achieve.

1. What is the new version of the \PrintSolutionsF{} command? I use this to have hand-in-dates on homework which I hand out, but not on the model solutions. I would have guess that \IfSolutionPrintF{} is the follow up, but this only seems to work inside template environments and not inside normal text.
2. I want my questions to be numbered, but not the solutions, because I place each solution immediately after its corresponding question. The code in exsheets for this was:

\DeclareInstance{exsheets-heading}{block-no-nr}{default}{
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
}
}
\RenewQuSolPair


What would be the corresponding code for xsim?

Edit: The following ought to be a minimal working example of my old exsheets templates, but I can't confirm this, because I can no longer compile my exsheets files. I cannot provide compilable code for xsim, because I that is what I'm seeking help for.

\documentclass{article}
\usepackage{exsheets}

% Questions numbered but solutions not numbered
attach = {
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
}
}
\RenewQuSolPair

% True to show solutions or comment out/false to hide solutions
\SetupExSheets{solution/print=true}

\begin{document}
%%%Title. Shows due date when not showing solutions%%%%%%%
\hrule\vspace{1mm}
{\bf \PrintSolutionsF{Exercise Sheet No X}
\PrintSolutionsT{Model Solutions Sheet No X} for
XXXX \PrintSolutionsF{\ \\Due XX.XX.XXXX}}
\hrule
\vspace{5mm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{question}
This is a sample numbered question.
\end{question}

\begin{solution}
This is an unnumbered sample solution.
\end{solution}

\end{document}

• please make your code fully compilable. – naphaneal Sep 30 at 9:59
• @naphaneal I've attempted to give a minimal working example of my old exsheets code. – Gonneman Sep 30 at 11:12
• @clemens Thank you for improving the presentation of my question. – Gonneman Sep 30 at 11:13
• The question actually was clear even without a MWE… I added my answer before the edit – clemens Sep 30 at 11:13

There is no predefined test if the solutions are printed because xsim allows different kind of exercise types each with their own set of solutions. But it is possible to define a command which checks the default type (called exercise):

\ExplSyntaxOn
\newcommand \ifprintsolution [2]
{ \xsim_if_solution_print:nTF {exercise} {#1} {#2} }
\ExplSyntaxOff


In order to have unnumbered solutions you need to define a template first. This would do:

\DeclareExerciseEnvironmentTemplate{no-number}
{\subsection*{\XSIMmixedcase{\GetExerciseName}}}
{}


You can now use it with \xsimsetup{solution/template = no-number}.

A complete example:

\documentclass{article}
\usepackage{xsim}

\ExplSyntaxOn
\newcommand \ifprintsolution [2]
{ \xsim_if_solution_print:nTF {exercise} {#1} {#2} }
\ExplSyntaxOff

\newcommand\handindate[1]{%
\ifprintsolution{}{This homework is due #1.}%
}

\DeclareExerciseEnvironmentTemplate{no-number}
{\subsection*{\XSIMmixedcase{\GetExerciseName}}}
{}

\xsimsetup{
solution/template = no-number ,
% uncomment to see the unnumbered solution (and have the hand-in date
% disappear):
% solution/print = true
}

\begin{document}

\handindate{6.\@ of December 2019}

\begin{exercise}
some exercise
\end{exercise}
\begin{solution}
the solution
\end{solution}

\end{document}


Without...

... or with solutions

• @clements This works! Thank you very much! – Gonneman Sep 30 at 11:16