cgnieder / xsim

eXercise Sheets IMproved
65 stars 20 forks source link

commands in setup #86

Closed blacheref closed 3 years ago

blacheref commented 3 years ago

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.

muzimuzhi commented 3 years ago

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}
blacheref commented 3 years ago

This is working nicely, thanks !

muzimuzhi commented 3 years ago

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