Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to use the enumitem package to define a custom enumerate list such that the label occupies its own line. An example would be:

\documentclass{article}

\usepackage[shortlabels]{enumitem}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex}

\begin{document}

\begin{center}
{\Large\sc Assignment 1}\\[2ex]
\end{center}

\begin{enumerate}[label={\large\bf Problem \arabic*.},wide]

\item

\begin{enumerate}[(a)]
    \item First question.
    \item Second question.
\end{enumerate}

\item

\begin{enumerate}[(a)]
    \item First question.
    \item Second question.
\end{enumerate}

\end{enumerate}

\end{document}

Example

I would like the labels (Problem 1., Problem 2.) to appear on their own line, i.e., to force a line break right after the label.

According to this post putting \mbox{}\\ after \item works, but I thought it could be possible to avoid that using features of enumitem.

share|improve this question
    
Wow, all great answers! Though I don't quite understand all that fancy etoolbox stuff, the one by Bernard was probably the most slick. But I picked the one by Daniel Wunderlich because it seemed like the most direct to me. –  mrbrich Aug 13 at 1:44

4 Answers 4

up vote 2 down vote accepted

I haven't found anything like this at the enumitem documentation and I would also suggest daleif's answer using theorems.

But I was able to answer your question by redefining \item before a 1st level enumerate environment and redefining it back to it's original definition after the environment. It also works with a simple ~, you don't need a \mbox{} (maybe a \mbox{} has some advantages?).

I know this solution is bit dirty, but it leads to the desired result. Keep in mind that it affects all 1st level enumerations! Alternatively you could create a new list (see enumitem documentation).

\documentclass{article}

\usepackage[shortlabels]{enumitem}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex}

\let\itemorig\item    % Create a copy of the original \item

\setlist[enumerate, 1]{%
  before=\renewcommand{\item}{\itemorig~},    % Append '~' to \item
  after=\renewcommand{\item}{\itemorig}       % Restore original \item
}

\begin{document}

\begin{center}
{\Large\sc Assignment 1}\\[2ex]
\end{center}

\begin{enumerate}[label={\large\bf Problem \arabic*.},wide]

\item

\begin{enumerate}[(a)]
    \item First question.
    \item Second question.
\end{enumerate}

\item

\begin{enumerate}[(a)]
    \item First question.
    \item Second question.
\end{enumerate}

\end{enumerate}

\end{document}

Break after item of 1st level enumeration

share|improve this answer

I think it might be better not to make the Problem ... lists, but rather theorems. Then you do not have to add those "empty" items.

Using ntheorem we can also build the list configuration into the surrounding env:

\documentclass[a4paper]{memoir}
\usepackage{enumitem}
\usepackage{ntheorem}
\theoremstyle{break}
\theorembodyfont{\normalfont}
\theoremseparator{.}
\theoremprework{
  \setlist*[enumerate]{label=(\alph*)} 
}
\newtheorem{problem}{Problem}


\begin{document}

\begin{problem}
  \begin{enumerate}
  \item First question.
  \item Second question.
  \end{enumerate}
\end{problem}

\begin{problem}
  \begin{enumerate}
  \item First question.
  \item Second question.
  \end{enumerate}
\end{problem}


\end{document}
share|improve this answer

Here is a solution using enumitem and etoolbox. I also changed the centred ‘Assignment’s, manually numbered, to sections, automatically numbered and referable, with the titlesec package.

\documentclass{article}

\usepackage[shortlabels]{enumitem}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex}

\usepackage{etoolbox}
\newenvironment{problems}{%
\apptocmd{\item}{\mbox{}}{}{}
\setlist[enumerate, 2]{wide}
%\vspace{0.5\baselineskip}
\AtEndEnvironment{enumerate}{\vskip 1\baselineskip}
\begin{enumerate}[label={\large\bf Problem \arabic*.},wide]}%
{\end{enumerate}}

\usepackage[explicit]{titlesec}

\titleformat{\section}[block]{\filcenter\Large\scshape}{Assignment~\thesection}{0em}{\ifstrempty{#1}{}{: #1}}
\titlespacing{\section}{0pt}{2\baselineskip}{2.5\baselineskip}%{}

\begin{document}

\section{}
\begin{problems}

\item

\begin{enumerate}
    \item First question.
    \item Second question.
\end{enumerate}

\item

\begin{enumerate}
    \item First question.
    \item Second question.
\end{enumerate}

\end{problems}

\section{}

\begin{problems}

\item

\begin{enumerate}
    \item First question.
    \item Second question.
\end{enumerate}

\item

\begin{enumerate}
    \item First question.
    \item Second question.
\end{enumerate}

\end{problems}

\end{document} 

enter image description here

share|improve this answer

Start the second level lists with a empty item \item[] ([] is very important) or define a new list that do this like

\newenvironment{mylist}[1][]{\begin{enumerate}[#1]\item[]}{\end{enumerate}}

Thus, the normal space of the lists does not change and the options of the enumitem package can be used.

\begin{mylist}[<enumitem options>]
    \item First question.
    \item Second question.
\end{mylist}

My code

\documentclass{article}

\usepackage[shortlabels]{enumitem}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex}

\begin{document}
\newenvironment{mylist}[1][]{\begin{enumerate}[#1]\item[]}{\end{enumerate}}
\begin{enumerate}[label={\large\bf Problem \arabic*.},wide]
\item
\begin{mylist}[(i)]
    \item First question.
    \item Second question.
\end{mylist}
\end{enumerate}
\end{document}

generates

enter image description here

share|improve this answer
    
Very nice trick, but a minor criticism is this only works if every Problem has sub-parts. Well, indeed that was the case in the example, but it still makes the solution slightly less general IMHO. –  mrbrich Aug 13 at 1:34
    
In the Daniel Wunderlich's solution the label Problem doesn't occupy its own line if the item begins with another text instead of an enumerate environment. It also leaves too much space before the first item. –  skpblack Aug 13 at 1:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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