# How can I add a "no page break" constraint to a \vspace?

I'm using this command:

\newcommand{\opitem}[1]{\item[\planop{#1} \hspace{\leftmargin} \vspace{\smallskipamount}]}


in a document of mine. I want to tweak it so as ensure I won't get a page break before the rest of the text for this item. How would I best achieve that?

• A \vspace in the middle of an \item argument? what should it do there? Feb 20 '18 at 23:44
• why don't you remove both the spaces and just set the list parameters to have the space that you want? Feb 21 '18 at 0:05
• you have not shown the relevant code but in most latex lists the argument of \item[...] is set in horizontal mode, so using a vertical skip is somewhat strange. Feb 21 '18 at 0:08
• Can you provide a better MWE for your requirement, ie., from \documentclass{}...\end{document}'... Feb 21 '18 at 6:13
• Is there any news here? Feb 25 '18 at 12:02

There’s \nopagebreak. It works well when is placed before \vspace

This text is kept together with following equation on the same page
\nopagebreak\vspace{-.25em}
$$\ldots$$


Another example. I use tocloft to tune table of contents. Without \nopagebreak inside

\renewcommand{\cftchapafterpnum}{\nopagebreak\vspace{.25em}}


I have

which looks silly, chapter is on this page but its sections are on the next one. But \nopagebreak` refines the layout