I can do the following:
\begin{samepage}
\begin{exercise}
Long text question or maybe a table and some stuff etc.
\end{exercise}
\end{samepage}
But I would prefer to have this automated (since I feel like this would be possible).
I have tried declaring a new exercise environment. Trying to follow the \tcolorbox
example in the xsim
package manual but this does not work.
\documentclass[]{article}
\usepackage{xsim}
\usepackage{lipsum}
\DeclareExerciseEnvironmentTemplate{customex}
{%
\begin{samepage}
\subsection*
{%
{
\XSIMmixedcase{\GetExerciseName}%
\IfInsideSolutionTF
{
%\GetExerciseParameter{exercise-name}%
~\GetExerciseProperty{counter}.%
}
{%
~\GetExerciseProperty{counter}
\GetExercisePropertyT{subtitle}
{ {\normalfont\itshape\PropertyValue}}%
}%
}
}
}
{\end{samepage}}
\xsimsetup{exercise/template = customex}
\begin{document}
\begin{exercise}
\lipsum[1-4]
\end{exercise}
\begin{exercise}
\lipsum[1]
\end{exercise}
\end{document}
The result is Exercise 1 being broken across 2 pages, instead of the desired Exercise 1 on page 1 and Exercise 2 on page 2.