2

I am using enumitem for a list:

\usepackage{enumitem}

\begin{enumerate}[1.]
\item ...
\item ...
\end{enumerate}

And I want each "item" itself not breakable across a page. I have looked at this answer, but having a hard time to adapt it to work with enumitem package. Can you help?

1

Perhaps putting the item contents in a \parbox is sufficient.

The \itemsep must also be incorporated in to the \parskip of the box.

\documentclass{article}
\usepackage{enumitem,lipsum}
\newcommand\itemnobreak[1]{\item \parbox[t]{\dimexpr\textwidth-\leftmargin}{%
  \parskip=\itemsep\relax#1}}
\begin{document}
\begin{enumerate}
\item \lipsum[1-4]
\itemnobreak{\lipsum[2-3]}
\end{enumerate}
\end{document}

enter image description here


SUPPLEMENT

The OP suggested a useful alternative in a comment, but it needed tweaking to capture the proper behavior of \item and also to allow a \parsep.

\documentclass{article}
\usepackage{enumitem,lipsum}
\newcommand\itemnobreak[1]{\item \parbox[t]{\dimexpr\textwidth-\leftmargin}{%
  \parskip=\itemsep\relax#1}}
\newenvironment{block-itemize}{% 
  \itemize \let\olditem\item \let\closepage\relax \renewcommand\item[1][\relax]{% 
    \closepage%
    \ifx\relax##1\olditem\else\olditem[##1]\fi%
    \minipage[t]{\linewidth}\parskip=\parsep\relax% 
    \let\closepage\endminipage }% 
  }{% 
  \closepage \enditemize }
\begin{document}
\noindent\hrulefill
\begin{block-itemize}
\item \lipsum[1-4]
\item \lipsum[2-3]
\end{block-itemize}
\end{document}
  • Is it possible to adapt this construct instead: \newenvironment{block-itemize}{% \itemize \let\olditem\item \let\closepage\relax \renewcommand\item[1][]{% \closepage\olditem[#1]\minipage[t]{\linewidth}% \let\closepage\endminipage }% }{% \closepage \enditemize } This way, I don't have to remember the open brace and close brace – python152 Feb 21 at 20:53
  • Also, not sure why you have syntax error, the actual include I use is \usepackage[shortlabels]{enumitem}, maybe it has something to do with it? – python152 Feb 21 at 20:56
  • @python152 This is why it is important for the questioner to provide more than just a code snippet...a full but minimum working example. You can't expect those who might try to help you to know all the package options available. – Steven B. Segletes Feb 21 at 21:10
  • @python152 Try this: \newenvironment{block-itemize}{% \itemize \let\olditem\item \let\closepage\relax \renewcommand\item[1][\relax]{% \closepage% \ifx\relax##1\olditem\else\olditem[##1]\fi% \minipage[t]{\linewidth}\parskip=\parsep\relax% \let\closepage\endminipage }% }{% \closepage \enditemize } – Steven B. Segletes Feb 21 at 21:17
  • @python152 I have provided it as a SUPPLEMENT to my answer. – Steven B. Segletes Feb 21 at 21:20

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.