LaTeX forum ⇒ Text FormattingNested list first item on another page Topic is solved

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
kulima
Posts: 23
Joined: Mon Aug 03, 2015 5:42 pm

Nested list first item on another page

Postby kulima » Mon Aug 10, 2015 2:48 am

Hi

I have a itemize list nested in my description list. My Problem is that the page ends right when the itemize list begins, so at the bottom of the page i got my last description(Item 23) and the first itemized item("First nested Item" is on the top of the page.
Now i want to keep "Item 23" on the same page as the nested list. It#s a bit hard to explain, here is a code example of how it looks like. Please ignore the "Random Text" and \bigskips, they are just there to push the items down and illustrate the problem.
  1. \documentclass[12pt,a4paper,headsepline]{scrreprt}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage[naustrian]{babel}
  4. \usepackage[T1]{fontenc}
  5. \usepackage{graphicx}
  6. \usepackage{lmodern}
  7. \usepackage[automark]{scrlayer-scrpage}
  8. \usepackage{blindtext}
  9. %\usepackage{scrletter}
  10. \begin{document}
  11. \blindtext
  12. \blindtext[2]
  13. Random Text
  14.  
  15. \bigskip
  16. Random Text
  17.  
  18. \bigskip
  19. Random Text
  20.  
  21. \bigskip
  22. Random Text
  23.  
  24. \bigskip
  25. Random Text
  26.  
  27.  
  28.  
  29. \begin{description}
  30. \item[Item 1] \hfill \\
  31. Some text
  32. \item[Item 2] \hfill \\
  33. Some more text
  34. \item[Item 23] \hfill
  35. \begin{itemize}
  36. \item First nested Item
  37. \item Second nested Item
  38. \end{itemize}
  39. \item[Item 24] \hfill \\
  40. Last Item text
  41. \end{description}
  42. \end{document}


Now i could quickfix it with \newpage or \bigskip or whatever, but that presents a whole lot of new problmes once i change the document. Is there an (easy) solution to keep nested lists with its parent item, or at least one of the nested items, or push "Item 23" to the next page, so "Item 23" does not look so lonely on the bottom of the page?

Tags:

User avatar
Stefan Kottwitz
Site Admin
Posts: 8460
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Mon Aug 10, 2015 12:53 pm

You could load the needspace package:

  1. \usepackage{needspace}


Then, wherever needed, you can require space. If there's not enough space left on the page, the following text would go to the next page:

  1. \needspace{2\baselineskip}\item[Item 23]


It can be automatized for each \item, but I would not do this as \item is implicitly used at many places.

Stefan
Site admin

kulima
Posts: 23
Joined: Mon Aug 03, 2015 5:42 pm

Postby kulima » Mon Aug 10, 2015 6:00 pm

Works like a charm.
Thanks

User avatar
Stefan Kottwitz
Site Admin
Posts: 8460
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Mon Aug 10, 2015 6:11 pm

Nice to read your confirmation! I also tested it with your code. You provided a very good minimal code example, so it was easy.

I see you are using naustrian. If you like to post in Austrian or German language, feel free to visit our partner forum TeXwelt.de too.

A matching topic is already there: "Wie kann ich in enumerate und itemize für jedes item extra-Code ausführen lassen?"

We love good questions, here and there. :)

Stefan
Site admin

kulima
Posts: 23
Joined: Mon Aug 03, 2015 5:42 pm

Postby kulima » Tue Aug 11, 2015 6:11 am

Good to know! Although i am quiet happy with the services provided here ;-)


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 3 guests