<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass{article}

\usepackage{tcolorbox}
\usepackage{xsim}    
\usepackage{needspace}

\DeclareExerciseEnvironmentTemplate{custom}
  {%
    \Needspace*{5\baselineskip}
    \begin{tcolorbox}
      \textbf{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}.}%
      \GetExercisePropertyT{subtitle}{ \textit{#1}}%
    \end{tcolorbox}
    \noindent
  }
  {\vspace{\baselineskip}}

\xsimsetup{exercise/template = custom}

\usepackage{lipsum}

\begin{document}

\begin{exercise}[subtitle=Foo bar baz]
  \lipsum[1]
\end{exercise}

\lipsum[2]

\end{document}
</pre></body></html>