2

I'm writing a document with some lists and I need to suppress a page break between the \item and the following line. Following is a MWE:

\documentclass[a4paper, 11pt]{scrartcl}
\usepackage{blindtext}
\usepackage{enumitem}

\begin{document}
\blindtext[2]
line\\
line\\
line\\
\begin{enumerate}[label=\textbf{Gruppe \arabic*},align=left,leftmargin=*,itemindent=0cm,labelwidth=\itemindent]
  \item~\\[-2em]
  \begin{enumerate}[label=\textbf{\alph*)},align=left,leftmargin=-1cm]
    \item \blindtext

    \item \blindtext
  \end{enumerate}

  \item~\nopagebreak\\[-2em]\nopagebreak
  \begin{enumerate}[label=\textbf{\alph*)},align=left,leftmargin=-1cm]
    \item \blindtext
  \end{enumerate}
\end{enumerate}
\end{document}

enter image description here enter image description here

I want Gruppe 2 and a) Lorem Ipsum on the same page. A page break before the item or after the first line is ok. But the page breaks between the \item and the first line is a problem. I tried \nopagebreak but it doesn't change anything. I read about samepage environment or minipage but I think this is not possible in this situation. A manual page break is only the last solution since this is at many places in the document and I want to find some generic solution.

Bernard
  • 271,350

2 Answers2

2

I suggest you load the needspace package and employ its \needspace macro.

\documentclass[a4paper, 11pt]{scrartcl}
\usepackage{blindtext,enumitem}
\usepackage{needspace} % <-- new

\begin{document}
\blindtext[2]
line\\
line\\
\begin{enumerate}[label=\textbf{Gruppe \arabic*},
  align=left,leftmargin=*,itemindent=0cm,
  labelwidth=\itemindent]
  \item~\\[-1.25\baselineskip]
  \begin{enumerate}[label=\textbf{\alph*)},
    align=left,leftmargin=-1cm]
    \item \blindtext
    \item \blindtext
  \end{enumerate}

  \needspace{3\baselineskip} % <-- new
  \item~\\[-1.25\baselineskip]
  \begin{enumerate}[label=\textbf{\alph*)},
    align=left,leftmargin=-1cm]
    \item \blindtext
  \end{enumerate}
\end{enumerate}
\end{document}
Mico
  • 506,678
1

You can still use a minipage in your case by utilizing the reume option for lists. This key is applied on second list, third list, and so on. Also notice that these \item~\\[-2em]s are not a recommended style. Use of hard \\s should be avoided, only in tabulars and sparingly in packages.

\documentclass[a4paper, 11pt]{scrartcl}
\usepackage{blindtext}
\usepackage{enumitem}

\begin{document}
\blindtext[2]
line\\
line

\noindent
\begin{minipage}{\linewidth}\noindent
\begin{enumerate}[label=\textbf{Gruppe \arabic*},align=left,leftmargin=*]
  \item {}
  \item[] 
  \begin{enumerate}[label=\textbf{\alph*)},align=left,leftmargin=-1cm]
    \item \blindtext
    \item \blindtext
  \end{enumerate}
\end{enumerate}
\end{minipage}
\begin{minipage}{\linewidth}\noindent
\begin{enumerate}[resume,label=\textbf{Gruppe \arabic*},align=left,leftmargin=*]
  \item {}
  \item []
  \begin{enumerate}[label=\textbf{\alph*)},align=left,leftmargin=-1cm]
    \item \blindtext
  \end{enumerate}
\end{enumerate}
\end{minipage}

\end{document}

enter image description here

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
  • But then I suppress the page break in the whole paragraph. That is not exactly what I want. I want to allow a page break in the paragraph but not between Gruppe 2 and a) – Thomas Sablik Nov 25 '17 at 22:08
  • And the use of \item~\\[-2em] was the only solution I found. It was recommended in this post https://tex.stackexchange.com/questions/29517/forcing-new-line-after-item-number-in-enumerate-environment. If you know a better way, I will listen. – Thomas Sablik Nov 25 '17 at 22:15