Is it possible to procedurally generate page breaks by measuring text/page space? I am having a problem which you can see here:
There are two problems in this picture. First, the heading should overflow to the next page because it doesn't fit...but more importantly, and more annoyingly, the heading should be forced to the next page because its content does not fit on the same page.
I am procedurally generating my latex from javascript, so it is sort of hard to post code snippets, but I can show you the function/environment I am using...it is the second code block in the accepted answer here
Any ideas or tips for measuring the text?
edit
Here is the code to generate my custom lists, from the link above:
\documentclass{article}
\usepackage{fancyhdr}
\usepackage[head=41.68335pt]{geometry}
\usepackage{enumitem}
\usepackage{indentfirst}
\pagestyle{empty}
%% I use a box for your "title" and save its width in "\mytitlewidth"
\newlength{\mytitlewidth}
\newlength{\mytopsep}
\newsavebox{\mytitlebox}
%% and environment to handle your list
\newenvironment{enumwithinenum}[1]
{\setlength{\mytitlewidth}{\dimexpr0.30\textwidth\relax}%%'
\setlength{\mytopsep}{2ex}%%'
%% save the title in a box so we can access its height later to
%% use to adjust where the next enumerate begins.
\begin{lrbox}{\mytitlebox}%%'
\begin{minipage}[t]{\dimexpr\mytitlewidth\relax}
\raggedright\strut
\textbf{#1}
\par\xdef\tpd{\the\prevdepth}%%'
\end{minipage}%%'
\end{lrbox}%%"
\usebox{\mytitlebox}%%'
\vspace{-\dimexpr\dp\mytitlebox+\parskip+0.7\baselineskip+\mytopsep\relax}%%'
\begin{enumerate}[align=left,
label={.\arabic*},
leftmargin=\dimexpr\mytitlewidth+2em\relax,
topsep=\mytopsep,
]
}
{\end{enumerate}}
%-@-(1)---------------------------------------------------------------------
\begin{document}
\noindent
\textbf{Part One - General}
zzz
\vspace{12.85cm}
\begin{enumerate}[leftmargin=*,topsep=1ex,itemsep=4ex,label={1.\arabic*}]
\item \begin{enumwithinenum}{SECTION INCLUDES}
\item \strut Work covered by Contract documents
\item Contract Method
\item Contract Method
\item Contract Method
\item Contract Method
\item Contract Method
\item Contract Method
\item Contract Method
\item Contract Meth
\end{enumwithinenum}
\item \begin{enumwithinenum}{THIS IS A LONGER TITLE}
\item \strut Work covered by Contract documents
\item Contract Method
\end{enumwithinenum}
\end{enumerate}
\end{document}
needspace
package which would conditionally insert a page break if the space left on a page doesn't meet some threshold. You could set the contents in the "right column" and use it as a test. But it's not easy to provide more detail without some tangible code.\textbf
rather than a sectioning command for\part
you are not using any of latex's code to avoid bad braks after section heads.