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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Fun times, I'm making a (manual) index of the lecture slides for class (which are nowhere near latex, ppt files yay) and of course Latex insists on placing pagebreaks willie nillie through my items. Why isn't there a "keep (paragraph) with next (paragraph)" option like there is in Word 2007 (and all others I think). Is Word really more powerful than Latex [when it comes to this specific attribute of paragraph flow]?

*full page before here*
Knowledge in the \nopagebreak\\
\nopagebreak - Head

Results in

*full page*
Knowledge in the 
---8<--- Next page
- Head ... 

Yes, I know I can place a \newpage before the line to push it to the next page, but there has to [HAS TO] be a way to make Latex understand that this isn't what I want, these two lines are supposed to stick together!

Edit: Full context:

*empty line*
Knowledge in the \\
- Head \slid{44, 69}
- World \slid{5, \textbf{44}, 66, 69, 84}
*empty line*

With slid being:

\newcommand{\slid}[1]{\dotfill #1 \nopagebreak\\}

It seems to be to be that the -World line is pulling down the -Head line, if I add an empty line between them, both Knowledge.. and -Head stay on the same page, with -World on the next one. But when I combine the two, only -Head gets pulled to a new page, and Knowledge... stays on the previous page.

share|improve this question
Yes, \nopagebreak can be extremely tricky, and this is unfortunate. While this site is the right place to ask such a question, I think it's not a place to rant about LaTeX. – Hendrik Vogt Dec 16 '10 at 15:53
what would you suggest I change to reduce the "rant" to a "colorful commentary"? – gakera Dec 16 '10 at 15:54
@gakera: Try to go into a bikers bar and rant about bikes. ;-) – Stefan Kottwitz Dec 16 '10 at 16:00
@Stefan It's the Word comment, isn't it :) I knew that would get under some skins, people have to have a sense of humor also, this is harmless teasing. And, if this is truly something that Word can do but Latex can not do, I stand by my "rant", hah! :D – gakera Dec 16 '10 at 16:04
@gakera: Now you have added some context, that's good. However, I can't reproduce the behaviour you're describing: For me, \nopagebreak does work. Maybe you can replace the context bit with a full compilable (but minimal) example? (Incidentally, I'm a professional when it comes to ranting; I even rant about LaTeX from time to time. I just don't do it here as I like the site to be a friendly place.) – Hendrik Vogt Dec 16 '10 at 16:49
up vote 19 down vote accepted

If "- Head -" is a normal text line \\* should work. If not we need to know what it is. In a lot of case solutions with \@afterheading can be used, e.g.:

share|improve this answer
OOOHH, I had such high hopes for \\\* I'm sad to say that doesn't change anything, but I did update the OP with full context, to me the -Head line is just a normal text line, unless I'm just way too stupid to be using Latex. – gakera Dec 16 '10 at 16:33
Ah, I see. Your \\* is after the first line of a paragraph. In this case \clubpenalty gets in the way. You will have to set it to 10000 temporarly for this paragraph. (\clubpenalty=10000). – Ulrike Fischer Dec 16 '10 at 17:27
AHA! \clubpenalty=10000 added after the \\\* in the Knowledge ... line works great! Thanks. – gakera Dec 16 '10 at 17:56

You could use a minipage environment or a \parbox. They won't be broken accross pages.

Further, LaTeX provides the \samepage command, which may be used as environment: \begin{samepage}...\end{samepage}. But I would not use samepage because it relies on setting penalties.

Also, the needspace packages comes often handy in such cases.

share|improve this answer
hmm needspace sounds interesting. I decided to use \begin{minipage}{\textwidth} ... \end{minipage} even though that feels like I'm shooting a canon at the canary. – gakera Dec 16 '10 at 16:16
out of curiosity, what's wrong with setting penalties? Isn't that the proper TeX way of influencing breaks? – Jan Hlavacek Dec 16 '10 at 16:58
@Jan: It might not work at all places. And \samepage support is questionable in LaTeX2e, which can be read in source2e.pdf p344, p358. – Stefan Kottwitz Dec 16 '10 at 17:11
A downside of \samepageis that \marginpar text seems to become unusable inside that block. – Hugo Aug 16 '12 at 3:11
An example of minipage might be nice to add to your answer: \begin{minipage}[t]{\textwidth}...\end{minipage} – Jonathan May 6 '13 at 17:54

You could also do this with samepage:

*full page before here*
Knowledge in the \\

- Head
share|improve this answer

Did you try \nopagebreak[4] ? As to the second part of your question

Is Word really more powerful than Latex?

There is absolutely no comparison to LaTeX. Word produces ugly, unstructured documents, crashes frequently, can eat your files and you have to recover, knows of no typographical rules and you have to pay a licence. As opposed to LaTeX it processes words rather than typesetting books, articles or other structured documents.

share|improve this answer
I'm pretty sure that \nopagebreak[4] is equivalent to \nopagebreak. – Hendrik Vogt Dec 16 '10 at 16:00
Yes, same results with all those nopagebreaks turned up to 4 :( I know Word sucks, but at least this is no problem to do in Word. Just one click and all is well. – gakera Dec 16 '10 at 16:01
@Hendrik possibly it can still fail in a bad spot, 0 : penalty = 0, 1 : penalty = \@lowpenalty, 2 : penalty = \@medpenalty, 3 : penalty = \@highpenalty, 4 : penalty = 10000, but without a minimal is difficult to check. – Yiannis Lazarides Dec 16 '10 at 18:42
I'm not sure what you're aiming at. Of course \nopagebreak can fail, but adding [4] doesn't help as indeed those two are equivalent. – Hendrik Vogt Dec 17 '10 at 10:06
:-( I have to disagree with nearly everything you said about Word (or any comparable open source alternative). I think LaTeX is uglier (less consistent), harder to use, crashes more (or worse, fails to compile/create the document at all)... Yes LaTeX is more powerful, but it's also far more crude. I don't need to build a combustion engine every time I want to drive to the store, I shouldn't have to build an entire typesetting structure every time I want to write a paper. It's just horrific. – Travis Bemrose Jun 22 at 0:58

Alternately, use the needspace package. Before entering a bit where you absolutely need to have 48 points of vertical space (for example) put in \needspace{48pt}

share|improve this answer

Your Answer


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.