[Tex/LaTex] The exercise package in list form

exerciseslists

I would like — using the exercise package — to make lists of exercises using the ExerciseList environment. The output is supposed to look like in the below example.

Example from book

The exercises are to be indented as shown, with the number to the left, like in an ordinary list environment. Can this be done within the exercise package?

EDIT: In order to please @cfr, I hereby publish my own attempts at solving this problem. The code crashes painfully:

\documentclass[openright,book]{memoir}

%Dansk sprog:
\usepackage[utf8]{inputenc}
\usepackage[danish]{babel}
\usepackage[T1]{fontenc}
\renewcommand{\danishhyphenmins}{22}
%\OnehalfSpacing %hvis der oenskes halvanden linjeafstand

%Pakker
\usepackage[noDcommand]{kpfonts} % the kpfonts font
\usepackage{%
    amsmath,graphicx,enumerate,amstext,geometry,array,xfrac,bm,mathtools,siunitx,
    %tikz, pgfplots
    etoolbox, xparse, %til subexc
    fixltx2e, %fikser et par bugs i LaTeX-kernen
    microtype, %smaa fiks, der goer tekst lettere at laese
    varioref,
    }

\usepackage{exercise}
\renewcommand\ExerciseListName{} % I don't want any word like "exercise" anywhere
\renewcommand\ExerciseHeaderTitle{\Exercisetitle}

\renewcommand{\ExerciseListHeader}{\ExerciseHeaderDifficulty%
    \item[\ExerciseHeaderNB]\ExerciseHeaderTitle\ %
    \ExerciseHeaderOrigin\ignorespaces}

\renewenvironment{ExerciseList}{\enumerate[1]\beginExerciseListEnv}{\endExerciseListEnv\endenumerate}


\begin{document}

\begin{ExerciseList}
    \Exercise What is this?
    \Exercise What is that
    \Question What in the world?
    \subQuestion What is this?
    \ExeText We define $x = y$.
\end{ExerciseList}

\end{document}

Best Answer

Since in the comments an exsheets solution for such a layout was welcomed here it is... the usage is quite different from the exercise package, though...

The solution contains of several steps:

  • Wrap KOMA-Script's addmargin environment around the question environment with the help of etoolbox's \AtBeginEnvironment and \AtEndEnvironment. This gets the question bodies indented by the specified margin (3em in the example below). The addmargin environment is provided by the scrextend package so it can be used with other classes, too.

  • Declare a new heading instance inspired by margin-nr instance described in the exsheets manual which uses the same margin as set by the addmargin environment (3em in the example below) to place the question number aligned with the text margin.

  • Set up exsheets to use the new instance and add some options for in-section numbering.

This is how the document from the code below looks like:

enter image description here

\documentclass{article}
\usepackage{scrextend}% not needed with a KOMA-Script class, provides the
                      % `addmargin' environment

\usepackage[load-headings]{exsheets}
\DeclareInstance{exsheets-heading}{mylist}{default}{
  runin = true ,
  attach = {
    main[l,vc]number[l,vc](-3em,0pt) ; % 3em = indent of question body
    main[r,vc]points[l,vc](\linewidth+\marginparsep,0pt)
  }
}

\SetupExSheets{
  headings = mylist , % use the new headings instance
  headings-format = \normalfont ,
  counter-format = se.qu ,
  counter-within = section
}


\usepackage{etoolbox}
% 3em = indent of question body :
\AtBeginEnvironment{question}{\addmargin[3em]{0em}}
\AtEndEnvironment{question}{\endaddmargin}

\usepackage{lipsum}

\begin{document}
\setcounter{section}{10}

\section*{Exercises}
\subsection*{Exercises to section \thesection}

\begin{question}
  \lipsum[4]
\end{question}

\begin{question}
  \lipsum[6]
\end{question}

\begin{question}
  \lipsum[10]
\end{question}

\end{document}
Related Question