cgnieder / xsim

eXercise Sheets IMproved
65 stars 20 forks source link

End-of-chapter problems/exercises #97

Closed oviedorodolfo closed 2 years ago

oviedorodolfo commented 2 years ago

Hi Clemens, I am writing a book, but I am new to xsim. I decided to use the default layout for exercises intermingled with the text of each chapter. However, I am having trouble deciding the layout for end-of-chapter problems/exercises? I want the typical format of a numbered list. Can I use the minimal layout? Or do I need a custom layout like in xsim.texsx-370642.tex (Minimalistic layout, Example 29, page 70, Manual)? Many thanks, Rodolfo

cgnieder commented 2 years ago

You can easily define a template that mimics the enumerate environment:

\documentclass{book}
\usepackage{xsim}

\usepackage{kantlipsum}% dummy text
\DeclareExerciseType{xrcs}{
  exercise-env      = xrcs ,
  solution-env      = sltn ,
  exercise-name     = \XSIMtranslate{exercise} ,
  exercises-name    = \XSIMtranslate{exercises} ,
  solution-name     = \XSIMtranslate{solution} ,
  solutions-name    = \XSIMtranslate{solutions} ,
  exercise-template = enumerate ,
  solution-template = enumerate ,
  % counter           = exercise % if a shared counter is wanted
}

\DeclareExerciseEnvironmentTemplate{enumerate}
  {\begin{itemize}\item[\GetExerciseProperty{counter}.]}
  {\end{itemize}}

\begin{document}

\chapter{My chapter}
\section{Heading One}

\kant[1]

\begin{exercise}
  First exercise
\end{exercise}

\section{Heading Two}

\kant[2]

\section{Exercises}
\begin{xrcs}
  Exercise One
\end{xrcs}
\begin{xrcs}
  Exercise Two
\end{xrcs}
\begin{xrcs}
  Exercise Three
\end{xrcs}

\end{document}

grafik