I would like to create a macro for keeping lines together. I have read unbreakable block and other posts like it. What I have found to work best is the simple use of \vbox; A MWE is below.
\documentclass[12pt]{book}
\usepackage{pgffor}
\begin{document}
\foreach \n in {0,...,34}{% also works for 33
\par text line
}
\vspace{15pt}
\vbox{
Keep these lines together\\
Keep these lines together\\
Keep these lines together
}
\foreach \n in {0,...,33}{
\par text line
}
\end{document}
The problem is my latex file is automatically generated by a separate process that I have no access to. However, there are hooks in the code like in the following example, which does not run.
\documentclass[12pt]{book}
\usepackage{pgffor}
\newcommand{\blockStart}{
\vspace{15pt}
\vbox{
}
\newcommand{\blockStop}{
}
}
\begin{document}
\foreach \n in {0,...,34}{
\par text line
}
\blockStart
Keep these lines together\\
Keep these lines together\\
Keep these lines together
\blockStop
\foreach \n in {0,...,33}{
\par text line
}
\end{document}
My task is to define macros for \blockStart and \blockStop that make this code work like the first example. The problem is the hanging braces in the \newcommand lines. I am not looking for an alternative to \vbox; it does exactly what I want with no extra spacing issues. I am looking for a way to define these macros.
samepagehas different spacing thanvbox. Thanks, though. – louis Aug 21 '16 at 20:49