cgnieder/xsim

commands in setup

blacheref opened this issue · 3 comments

Hi,
Does it exist a way to use commands in \xsimsetup ? I would like to achieve things like presented in the following code, because I reuse the \semester commands in other places.

\newcommand{\semester}{202109}
\newcommand{\printSolutions}{true}
\xsimsetup{
    solution/print = \PrintSolutions,
    tags={\semester},
}

Thanks by advance.

You can try fully expanding the key-val list before passing it to \xsimsetup.

\documentclass{article}
\usepackage{xsim}

\newcommand{\semester}{202109}
\newcommand{\PrintSolutions}{true}

\expandafter\xsimsetup\expanded{{
  solution/print = \PrintSolutions,
  tags={\semester},
}}

\begin{document}
content
\end{document}

This is working nicely, thanks !

Be careful that not every key-val pair (mostly the value) is fully expandable. So you might need to write two \xsimsetups.