I like the idea of absolutelynopagebreak environment and I'd like to use it for wrapping theorem-like environments when needed (without modifying those environments). It does work, but the problem is that it creates additional vertical space (before and after).
Is there a way to fix this?
\documentclass{article}
\newtheorem{theorem}{Theorem}
\newenvironment{absolutelynopagebreak}
{\par\nobreak\vfil\penalty0\vfilneg
\vtop\bgroup}
{\par\xdef\tpd{\the\prevdepth}\egroup
\prevdepth=\tpd}
\begin{document}
\begin{theorem}
Statement 001.
\end{theorem}
\begin{theorem}
Statement 002.
\end{theorem}
\begin{absolutelynopagebreak}
\begin{theorem}
Statement 003.
\end{theorem}
\end{absolutelynopagebreak}
\begin{theorem}
Statement 004.
\end{theorem}
\begin{theorem}
Statement 005.
\end{theorem}
\end{document}
I was able to remove vertical space using vspace (approximately), but it's not reliable since it changes when text size changes.
\begin{absolutelynopagebreak}
\vspace{-1.3\baselineskip}
\begin{theorem}
Statement 006.
\end{theorem}
\vspace{-0.65\baselineskip}
\end{absolutelynopagebreak}
