[texhax] How to prevent page break in description environment item
Alan Litchfield
alan at alphabyte.co.nz
Sun Nov 1 01:21:44 CET 2015
True, I did think of that.
Thank you for prompting me to take a more careful look at the problem.
Here is a solution (attribution to Ulrike Fischer):
\makeatletter
\def\mynobreakpar{\par\nobreak\@afterheading}
\makeatother
Apply as
\begin{document}
\quad
\vspace{232mm}
\begin{description}
\item[first item] \quad{}\\
Description of first item
\item[second item] \quad{} \mynobreakpar{}
Description of second item
\end{description}
\end{document}
While this does not redefine the list item, I am not certain one would
want to make such a change in case it breaks something else. My
preference in this case would be to resolve a local problem. That is,
there are many more cases where you would want a subsequent list item
paragraph to appear on a new page than for the previous paragraph(s) to
be dragged onto it.
Regards
Alan
On 1/11/15 12:48 pm, Reinhard Kotucha wrote:
> On 2015-11-01 at 07:48:08 +1300, Alan Litchfield wrote:
>
> > On 1/11/15 2:26 am, Moritz Sichert wrote:
> >> Hi,
> >>
> >> I have this code:
> >>
> >> \begin{description}
> >> \item[first item] \hfill \\
> >> Description of first item
> >> \item[second item] \hfill \\
> >> Description of second item
> >> \end{description}
> >>
> >>
> >> And it generates something like this:
> >>
> >> First Item
> >> Description of first Item
> >> Second Item
> >> -------- PAGE BREAK ----------
> >> Description of second item
> >>
> >>
> >> How can I prevent the page break between the title of an item and its
> >> description?
> >>
> >> I tried adding \nopagebreak after \descriptionlabel like this:
> >>
> >> \let\orig at descriptionlabel\descriptionlabel
> >> \renewcommand*{\descriptionlabel}[1]{\orig at descriptionlabel{#1}\nopagebreak}
> >>
> >> But that didn't change anything. Adding \nopagebreak around the second
> >> item in the code also didn't prevent the break.
>
> > Put \newpage{} at the end of the prior description item.
> >
> > \begin{description}
> > \item[first item] \hfill \\
> > Description of first item \newpage{}
> > \item[second item] \hfill \\
> > Description of second item
> > \end{description}
>
> But what happens if stuff is added in front of the description
> environment? The first item will appear on the next page, immediately
> followed by a \newpage.
>
> I don't think that your suggestion is a solution. What Moritz
> attempts is to re-define LaTeX macros in order to prevent page breaks
> at certain places in his document without manual intervention.
>
> Regards,
> Reinhard
>
--
Dr Alan Litchfield
AlphaByte
PO Box 1941
Auckland, New Zealand 1140
More information about the texhax
mailing list