summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xsim/examples/xsim.texsx-369636.tex
blob: 73ab7868f63a1c6e0bc735d68cc4a6af9962be27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
% https://tex.stackexchange.com/q/369686/
\documentclass[a4paper,11pt]{article}
\usepackage[top=2cm, bottom=3cm, left=4cm, right=4cm]{geometry}

\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{tgpagella}

\usepackage{xsim,needspace,adjustbox,scrextend}

\xsimsetup{
  exercise/the-counter = \arabic{exercise}. ,
  exercise/template    = square
}

\DeclareExerciseEnvironmentTemplate{square}{%
  \Needspace*{2\baselineskip}%
  \addmargin[0pt]{.15\textwidth}%
  \par\noindent
  \adjustbox{
    fbox = 1pt 0pt,
    lap = {\textwidth},
    valign = t,
    set vsize = {0pt}{0pt}
  }{\rule{0pt}{20pt}\hspace{20pt}}%
  \textbf{\GetExerciseProperty{counter}} %
}{\endaddmargin\vspace{\baselineskip}}

\usepackage{lipsum}

\begin{document}

\noindent\hrulefill

\begin{exercise}
  \lipsum[1]
\end{exercise}

\begin{exercise}
  \lipsum[2]
\end{exercise}

\end{document}