7

I quite often see, and myself create, exercises which consist of multiple subexercises or parts, like this:

# Exercise 1
Two cars are traveling in opposite directions. 
They are 2.7km apart, driving 50km/h and 65km/h, respectively.
a) Write the equations of motion for the two cars.
b) Find the time t at which the two cars will meet.
c) Find the distance traveled by the cars when they meet.

As far as I can see, this is not a feature directly provided by the xsim package. Any recommendations on how to achieve this by other means?

A solution with the enumerate or itemize environment works, but maybe there are other ways.

\documentclass{article}
\usepackage{xsim}
\begin{document}
\begin{exercise}
Two cars travel ....
\begin{enumerate}
\item Write the equations ...
\item Find the time ...
\item Find the distance ...
\end{enumerate}
\end{exercise}
\end{document}

If one uses a solution like the above one, one has to keep the subexercises or parts in the same order in both the exercise and solution environment manually.

5
  • Which features of an xsim exercise do you need for your subexercises?
    – TeXnician
    Nov 21, 2018 at 9:23
  • 1
    For my purpose it is mostly the automatic numbering and keeping exercises/solutions paired up correctly. If I change the order of my enumerate items in the exercise environment, then I manually have to change them in the in the solution environment as well. Some people might want some points bookkeeping to work with subexercises/parts as well. Nov 21, 2018 at 22:41
  • This is trivial in the Exercise package.
    – user5402
    Dec 24, 2018 at 20:11
  • 1
    At this moment I do not recall why I was displeased with the Exercise package. Maybe it didn't internationalize well, did not work well with xelatex, with the Tufte book classes or some such. Anyway, the xsim package appear like a fine package, and this is an obvious question about it (or request for improvement). Dec 25, 2018 at 21:44
  • @clemens (the developer of xsim) Any idea on how to proceed?
    – Clément
    Feb 14, 2019 at 19:32

1 Answer 1

2

I'd simply use enumerate or tasks (from the tasks package).

\documentclass{article}
\usepackage{xsim,tasks,siunitx}

\begin{document}

\begin{exercise}[subtitle=Cars]
  Two cars are traveling in opposite directions. They are
  \SI{2.7}{\kilo\meter} apart, driving \SI{50}{\kilo\meter\per\hour} and
  \SI{65}{\kilo\meter\per\hour}, respectively.
  \begin{tasks}(2)
    \task Write the equations of motion for the two cars. (\addpoints{1})
    \task Find the time $t$ at which the two cars will meet. (\addpoints{2})
    \task Find the distance traveled by the cars when they
      meet. (\addpoints{2})
  \end{tasks}
\end{exercise}

\end{document}

enter image description here


Depending on your setup it might also be a possibility to use xsim's environments for the subexercises directly. An example for this can be found here: Randomly selecting subquestions in exsheets.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .