I have some exercises with ID.
\documentclass{report} \usepackage[paperwidth=17cm, paperheight=24cm, left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry} \usepackage{fouriernc} \usepackage{xsim,pgffor} \usepackage{needspace} \DeclareExerciseEnvironmentTemplate{runin} {% \par\vspace{\baselineskip} \Needspace * {2\baselineskip} \noindent \textbf{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}}% \GetExercisePropertyT{subtitle}{ \textit{#1}} % \GetExercisePropertyT{points}{% \marginpar{% \PropertyValue \GetExercisePropertyT{bonus-points}{+\PropertyValue}% \,\IfExerciseGoalSingularTF{points} {\XSIMtranslate{point}} {\XSIMtranslate{points}}% }% }% } {} \xsimsetup{ exercise/within=section , exercise/template=runin, solution/template=runin, solution/print = true, exercise/the-counter = \thesection.\arabic{exercise}.} \DeclareExerciseCollection{exam} \begin{document} \chapter{AAA} \section{BBB} \collectexercises{exam} \begin{exercise}[ID=q1] 1 \end{exercise} \begin{solution} 1 \end{solution} \begin{exercise}[ID=q2] 2 \end{exercise} \begin{solution} 2 \end{solution} \begin{exercise}[ID=q3] 3 \end{exercise} \begin{solution} 3 \end{solution} \begin{exercise}[ID=q4] 4 \end{exercise} \begin{exercise}[ID=q5] 5 \end{exercise} \begin{exercise}[ID=q6] 6 \end{exercise} \begin{exercise}[ID=q7] 7 \end{exercise} \begin{exercise}[ID=q8] 8 \end{exercise} \begin{exercise}[ID=q9] 9 \end{exercise} \begin{exercise}[ID=q10] 10 \end{exercise} \printcollection{all exercises} \section{Print with ID} \printexercise{exercise}{q3} \section{Answers} \printsolutions \end{document} Now I want to print one (or some) exercise. I tried
\printexercise{exercise}{q3} or
\printexercise{exercise}{q1,q3,q5} But I can't get the result. How can I get it?

\printexercise{exercise}{q1,q3,q5}can't work. It doesn't even match the description of the\printexercise... you're missing that there are two different types of id:idandID.\XSIMexpandcode{\printexercise{exercise}{\GetExerciseIdForProperty{ID}{q3}}}should work… (it would probably best to define a wrapper macro\newcommand\insertexercise[1]{\XSIMexpandcode{\printexercise{exercise}{\GetExerciseIdForProperty{ID}{#1}}}})\begin{document}?\collectexercisesstop{exam}