summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xsim/examples/xsim.crossref.tex
blob: 0a6c8f4eab9c75c51c1cdab846f3bac621629bc6 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
\documentclass{article}
\usepackage{xsim,lipsum,hyperref}

\DeclareExerciseHeadingTemplate{custom}
  {\section{\XSIMexpandcode{\XSIMtranslate{default-heading}}}}

\DeclareExerciseEnvironmentTemplate{custom}
  {%
    \IfInsideSolutionTF
      {\label{sol:\ExerciseID}}
      {\label{ex:\ExerciseID}}
    \subsection*
      {%
        \XSIMmixedcase{\GetExerciseName}%
        \IfInsideSolutionTF
          {
            to \GetExerciseParameter{exercise-name}%
            ~\GetExerciseProperty{counter}%
          }
          {%
            ~\GetExerciseProperty{counter}
            \GetExercisePropertyT{subtitle}
              { {\normalfont\itshape\PropertyValue}}%
          }%
      }
    \noindent\llap{%
      \footnotesize\sffamily
      \IfInsideSolutionTF
        {%
          \XSIMmixedcase{\GetExerciseParameter{exercise-name}}
          on page~\pageref{ex:\ExerciseID}.%
        }
        {%
          \XSIMmixedcase{\GetExerciseParameter{solution-name}}
          on page~\pageref{sol:\ExerciseID}.%
        }%
      \hspace*{\marginparsep}%
    }%
  }
  {}
\xsimsetup{
  exercise/template = custom ,
  solution/template = custom ,
  print-solutions/headings-template = custom
}

\begin{document}

\section{Exercises}
\begin{exercise}
  \lipsum[4]
\end{exercise}
\begin{solution}
  \lipsum[4]
\end{solution}

\clearpage
\printsolutions

\end{document}