4

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}]
    Tell me your mood
% Those lines would *not* be printed if solution/print is set to true.
\blank[width=4.8\linewidth,linespread=1.5]{} 
\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
  • 1
    @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
4

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}]
  Tell me your mood
  \IfSolutionPrintT{\par\blank[width=4.8\linewidth,linespread=1.5]{} }
\end{exercise}

\end{document}
  • Just out of curiosity... Is there any conditional similar to \IfSolutionPrintTF that works outside of an exercise? E.g. something like "\IfSolutionPrintF{\pagenumbering{gobble}}" right after \begin{document}... – TeoFed89 Jun 24 '18 at 18:25
  • @TeoFed89 I can't remember and have to check, but doesn't \IfSolutionPrint(TF) work outside? – clemens Jun 25 '18 at 7:45
  • I always get an error message when I try that precise command within \AtBeginDocument. I patched this by creating a boolean switch that, when true, sets "solution/print=true" AND does some other things. It would be curious though to understand why it didn't work on the first try... from what I read in the documentation I thought that \IfSolutionPrint(TF) only works within an exercise template. – TeoFed89 Jun 26 '18 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.