summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xsim/examples/xsim.floating.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/xsim/examples/xsim.floating.tex')
-rw-r--r--macros/latex/contrib/xsim/examples/xsim.floating.tex50
1 files changed, 50 insertions, 0 deletions
diff --git a/macros/latex/contrib/xsim/examples/xsim.floating.tex b/macros/latex/contrib/xsim/examples/xsim.floating.tex
new file mode 100644
index 0000000000..08448df35a
--- /dev/null
+++ b/macros/latex/contrib/xsim/examples/xsim.floating.tex
@@ -0,0 +1,50 @@
+% floating exercises:
+\documentclass{article}
+\usepackage{xsim,newfloat,caption,lipsum}
+
+\DeclareFloatingEnvironment[
+ fileext=loe,
+ listname={List of Exercises},
+ name=Exercise,
+ placement=htp,
+]{ex}
+
+\DeclareExerciseEnvironmentTemplate{float}
+ {%
+ \ex
+ \captionsetup{labelformat=empty,singlelinecheck=false,listformat=empty}
+ \IfExercisePropertySetTF{subtitle}{%
+ \XSIMexpandcode{%
+ \noexpand\caption{%
+ \noexpand\textbf{%
+ \XSIMmixedcase{\GetExerciseName}\nobreakspace
+ \GetExerciseProperty{counter}%
+ }: \GetExerciseProperty{subtitle}%
+ }%
+ }%
+ }{%
+ \caption{%
+ \textbf{%
+ \XSIMmixedcase{\GetExerciseName}\nobreakspace
+ \GetExerciseProperty{counter}%
+ }%
+ }%
+ }%
+ }
+ {\endex}
+
+\xsimsetup{exercise/template = float}
+
+\begin{document}
+
+\listofexs
+
+\begin{exercise}
+ \lipsum[4]
+\end{exercise}
+
+\begin{exercise}[subtitle=Let's have a look]
+ \lipsum[4]
+\end{exercise}
+
+\end{document}