1

When I typeset exercises, I sometimes like to provide the exercise number in the left margin rather than as part of the paragraph describing the exercise. This poses a problem when I need typeset exercises with multiple parts (pictured below).

Problem visualization

If an exercise has text before the enumerate environment, then the default indentation is desirable (this is case 1). However, if an exercise has no text occurring before the enumerate environment, then I would like the enumerate environment to have the following properties (this is case 2).

  • The first list item should begin on the same line as the exercise.
  • The entire list should be flush with the left margin of the page, i.e. there is no gap between the left margin of the page and the parts of the exercise.
  • The list items should be resilient to page breaks, i.e. the exercise should split between one or more pages if necessary.
  • The enumerate environment should distinguish between cases 1 and 2 automatically, without the user having to indicate which behavior he/she wants.

The MWE given below defines an enumerate environment satisfying properties (1) and (2), but not (3) and (4). Do you know how I could modify this environment so that properties (3) and (4) are also satisfied?

Thanks for your help!

\documentclass[11pt, a4paper]{article}
\usepackage{enumitem}
\usepackage[marginparwidth=1in]{geometry}
\usepackage{marginnote}

\newlist{indentlist}{enumerate}{2}
\setlist[indentlist, 1]{label=(\alph*), listparindent=\parindent}
\setlist[indentlist, 2]{label=\roman*., listparindent=\parindent}

\newlist{noindentlist}{enumerate}{2}
\setlist[noindentlist, 1]{label=(\alph*), listparindent=\parindent, leftmargin=6mm}
\setlist[noindentlist, 2]{label=\roman*., listparindent=\parindent}

\begin{document}

\reversemarginpar\noindent\marginnote{\textit{Exercise 1.}}
\begin{minipage}[t]{\textwidth}
\begin{noindentlist}
\item This is a test.
\item A.
\begin{noindentlist}
\item A.
\item A.
\end{noindentlist}
\end{noindentlist}
\end{minipage}
\medskip

\reversemarginpar\noindent\marginnote{\textit{Exercise 2.}} This is a sentence.
\begin{indentlist}
\item This is a test.
\item A.
\begin{indentlist}
\item A.
\item A.
\end{indentlist}
\end{indentlist}

\end{document}
2

If you define an exercises list of type enumerate, with problems at level 1, questions at level 2 and subquestions at level 3, you can do that without margin notes while having consistent left margins for multiline (sub)questions. To make the code more readable, I also define \qu and \subqu as aliases for \item, to be used in the relevant context:

\documentclass[11pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage[marginparwidth=1in, showframe, reversemp]{geometry}
\usepackage{xcolor}
\newlist{exercises}{enumerate}{3}
\setlist[exercises]{wide = 0pt, listparindent=\parindent,labelsep = 0pt,leftmargin =\labelwidth}
\setlist[exercises, 1]{label =\llap{\itshape Exercise~\arabic*.\hskip\marginparsep}}
\setlist[exercises, 2]{label=(\alph*), labelwidth = 1.8em, leftmargin =\labelwidth}
\setlist[exercises, 3]{label=\roman*.,labelwidth = 1.333em, leftmargin =\labelwidth, }
\let\qu\item
\let\subqu\item

\begin{document}

\begin{exercises}%
\item Some introductory text and notation setting. Some introductory text and notation setting.
  \begin{exercises}
\qu Now for a first simple question.
\qu The trickier question that follows requires three subquestions and a good deal of ingenuity.
\begin{exercises}
\subqu A preparatory subquestion.
\subqu A proof based on Cauchy’s type of induction that consists in proving, first that $ \mathcal P(n)$ implies $ \mathcal P({\color{red}2}n)$ and, second, that $ \mathcal P(n)$ implies $ \mathcal P(n {\color{red}{}-{}} 1)$.
\subqu A.
\end{exercises}
\end{exercises}

\item
\begin{exercises}
\qu No introductory text for this exercise.
\qu B.
\begin{exercises}
\subqu B1.
\subqu B2.
\end{exercises}
\end{exercises}
\end{exercises}


\end{document} 

enter image description here

1

I found a nice solution which satisfies properties (1)--(3) using one of egreg's answers to another question (apologies, but I lost track of which question this was). In this answer, egreg suggested using a dummy description environment to avoid the undesired line break after the beginning of the itemize environment. In this case, I use marginnote instead of paragraph text and enumerate instead of itemize, but the trick still works as long as we are careful.

I don't have the time now to post an MWE, but I wrote a class file that I now use for typesetting exercises. The support for typesetting multipart exercises uses this trick. Here's a picture of a simple document produced using this class file:

enter image description here

Code:

\documentclass[11pt, a4paper]{ps}
\usepackage[marginparwidth=1in]{geometry}

% Problem set information.
\coursename{Course Title}
\coursetitle{Course Number}
\author{My Name}
\problemset{1}

\begin{document}

\begin{problem}
Hello!
\begin{parts}
\item Hi.
\item Hii.
\item Hiii.
\end{parts}
\end{problem}

\begin{multiproblem}
\item Hi.
\item Hii.
\item Hiii.
\end{multiproblem}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.