| 1 |
% floating exercises: |
| 2 |
\documentclass{article} |
| 3 |
\usepackage{xsim,newfloat,caption,lipsum} |
| 4 |
|
| 5 |
\DeclareFloatingEnvironment[ |
| 6 |
fileext=loe, |
| 7 |
listname={List of Exercises}, |
| 8 |
name=Exercise, |
| 9 |
placement=htp, |
| 10 |
]{ex} |
| 11 |
|
| 12 |
\DeclareExerciseEnvironmentTemplate{float} |
| 13 |
{% |
| 14 |
\ex |
| 15 |
\captionsetup{labelformat=empty,singlelinecheck=false,listformat=empty} |
| 16 |
\IfExercisePropertySetTF{subtitle}{% |
| 17 |
\XSIMexpandcode{% |
| 18 |
\noexpand\caption{% |
| 19 |
\noexpand\textbf{% |
| 20 |
\XSIMmixedcase{\GetExerciseName}\nobreakspace |
| 21 |
\GetExerciseProperty{counter}% |
| 22 |
}: \GetExerciseProperty{subtitle}% |
| 23 |
}% |
| 24 |
}% |
| 25 |
}{% |
| 26 |
\caption{% |
| 27 |
\textbf{% |
| 28 |
\XSIMmixedcase{\GetExerciseName}\nobreakspace |
| 29 |
\GetExerciseProperty{counter}% |
| 30 |
}% |
| 31 |
}% |
| 32 |
}% |
| 33 |
} |
| 34 |
{\endex} |
| 35 |
|
| 36 |
\xsimsetup{exercise/template = float} |
| 37 |
|
| 38 |
\begin{document} |
| 39 |
|
| 40 |
\listofexs |
| 41 |
|
| 42 |
\begin{exercise} |
| 43 |
\lipsum[4] |
| 44 |
\end{exercise} |
| 45 |
|
| 46 |
\begin{exercise}[subtitle=Let's have a look] |
| 47 |
\lipsum[4] |
| 48 |
\end{exercise} |
| 49 |
|
| 50 |
\end{document} |