# xsim and “conditional” printing

I'd like to know if the following is possible with the xsim package:

• Could the space created by commands like \blank[width=4.8\linewidth,linespread=1.5]{} (as given in the manual) not be printed if solution/print is set to true?
• Could a part of the document that is not a question be printed only if a particular tag is selected?

In other words, I'd like to achieve the following:

\documentclass{article}
\usepackage{xsim}
\xsimsetup{
solution/print = true,
tags = A
}

\begin{document}

% This part would be printed only if the tag A was selected.
\somecommand{Instruction for A}

\begin{exercise}[tags={A, B}]
% Those lines would *not* be printed if solution/print is set to true.
\end{exercise}

\end{document}


I've read the documentation but can't figure out whenever this is possible or not.

• Do you mean just using the user-interface of this package? A page reference would be appreciated - the manual is 71 pages. – cfr Feb 2 '18 at 5:07
• It would be nice to have this feature provided by the package, indeed, but I don't think this is the case. Section 11 is about "Printing Solutions", but doesn't say anything about triggering other commands with the print toggles. The same goes for tags, exposed in 7.4. The section 13.3. "Commands for Usage in Template Definitions" is rich in additional commands , but I don't see any command being able to trigger something outside a solution or question environment. – Clément Feb 2 '18 at 5:14
• @Clément a lot of the kind of commands you are looking for are described in the section about creating exercise templates – clemens Feb 2 '18 at 10:43

There is currently no user command which checks if a tag has been set but it is easy to add one. I'll add something to the next release.

If you want to check if solutions are printed then use \IfSolutionPrintTF or one of its cousins:

\documentclass{article}
\usepackage{xsim}

\xsimsetup{
solution/print = true,
tags = A
}

\ExplSyntaxOn
% v0.11 will contain some command like this:
\NewDocumentCommand \IfTagSetTF {m+m+m}
{ \seq_if_in:NnTF \l__xsim_chosen_tags_tags_seq {#1} {#2} {#3} }
\NewDocumentCommand \IfTagSetT {m+m}
{ \IfTagSetTF {#1} {#2} {} }
\NewDocumentCommand \IfTagSetF {m+m}
{ \IfTagSetTF {#1} {} {#2} }
\ExplSyntaxOff

\begin{document}

\IfTagSetT{A}{Instruction for A}

\begin{exercise}[tags={A, B}]

• @TeoFed89 I can't remember and have to check, but doesn't \IfSolutionPrint(TF) work outside? – clemens Jun 25 '18 at 7:45