I have a few commands which must be on the same page as following content. My LaTeX code is generated so I can't fix each problem manually.
Imagine situation with this code
\documentclass{article}
\usepackage{lipsum}
\newcommand{\heading}{
\noindent \textbf{heading}\\
}
\begin{document}
%% ONLY FOR EXAMPLE
some text
\vspace{185mm}
\heading
\lipsum[1]
\end{document}
which results to this output
How can I ensure that the heading will be always on the same page as following content? Thanks


minipageor an unnumberedsection(i.e.\section*{My heading}). But who/what generates this LaTeX code? – Apr 01 '16 at 12:06\\If you want to keep all the following para togetherput all the text in a\noindent\begin{minipage{\textwidth}...\end{minipage}will keep it together, if you just want the heading to stay with the first few lines, but allow page breaking just use a proper heading command such as\section*{heading}– David Carlisle Apr 01 '16 at 12:07