Well, if all the problems boil down to having a variant of \cleardoublepage
that always jumps to an even-numbered page, instead of to an odd-numbered one, this is easily accomplished:
\documentclass[%
twoside,% this is crucial!
a4paper% this is not, of course!
]{article}
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
\usepackage{lipsum}
\makeatletter
% Use "\clearevenpage" if you want the possible extra page to *have*
% running heads:
\newcommand*\clearevenpage{\par
\clearpage
\if@twoside \ifodd\c@page
\null\newpage
\fi\fi
}
% Use "\clearevenemptypage" if you want the possible extra page *not* to have
% running heads:
\newcommand*\clearevenemptypage{\par
\clearpage
\if@twoside \ifodd\c@page
\thispagestyle{empty}%
\null\newpage
\fi\fi
}
\makeatother
\begin{document}
\lipsum[1-6]
We should now be on an even-numbered page.
\clearevenpage
This test appears on the next \emph{even} page; an empty page has been
automatically inserted.
\lipsum[7-12]
We should now be on an odd-numbered page.
\clearevenpage
This text appears on the next even page too, but this time no additional empty
page was needed.
\end{document}
Edit: Re-reading the question more carefully, I realize this is not what you are asking for. (So, I’ll remove this answer after a grace period of 48 hours, to let it witness to my stupidity… ;-) You want to jump to an even-numbered page only if the ensuing poem spans two pages, right? (By the way: what is the expected behavior if the ensuing poem is more than two pages long, so that the reader is forced to turn over the page anyway?)
Addition
The following code defines a Poem
environment that measures the text inside it and, if the proper conditions are met, jumps to the next even-numbered page. More precisely, if both the following are true:
then the contents are printed beginning on the next even-numbered page; otherwise, they will be printed starting on the next page, be it even-numbered or odd-numbered. The examples included in the code illustrate this.
\documentclass[%
twoside,% this is crucial!
a4paper% this is not, of course!
]{article}
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
\usepackage{lipsum}
\makeatletter
\newenvironment*{Poem}{%
\setbox\z@ \vbox\bgroup
\boxmaxdepth\maxdepth
\color@begingroup
% the following penalty will be used later, see (*):
\penalty-\@M
}{%
\@@par
\color@endgroup
\global \dimen@i \prevdepth
\egroup
% (*) What follow is a hack to insert the "\topskip" glue atop "\box0";
% nothing will actually be split off to "\box2":
\splitmaxdepth \maxdepth
\splittopskip \topskip
\setbox\tw@ \vsplit\z@ to\z@ % everything actually stays in "\box0"
\clearpage
\if@twoside
\ifdim \ht\z@>\textheight
\ifodd\c@page
% uncomment the following line if you wish so:
% \thispagestyle{empty}% <-- ...but leave this "%" in place
\null\newpage
\fi
\fi
\fi
\unvbox\z@
\prevdepth \dimen@i
}
\makeatother
\begin{document}
The contents of the \texttt{Poem} environment can be ordinary paragraphs as
well as verses.
\begin{Poem}
\section{First poem}
\lipsum[1-6]
\end{Poem}
\begin{Poem}
\section{Second poem}
\lipsum[7-20]
\end{Poem}
\begin{Poem}
\section{Third poem}
\lipsum[20-22]
\end{Poem}
\begin{Poem}
\section{Fourth poem}
\lipsum[22-24]
\end{Poem}
\begin{Poem}
\section{Fifth poem}
\lipsum[24-32]
\end{Poem}
\begin{Poem}
\section{Sixth poem}
\lipsum[33]
\end{Poem}
\begin{Poem}
\section{Seventh poem}
\lipsum[34]
\end{Poem}
\begin{Poem}
\section{Eighth poem}
\lipsum[35-36]
\end{Poem}
\begin{Poem}
\section{Ninth poem}
\lipsum[37-48]
\end{Poem}
And so on\ldots\space (Check for \verb|\prevdepth|.)
\end{document}
Note that the contents of the Poem
environment can consist of ordinary paragraphs, section titles, lists, verses… The only things you should avoid are:
explicit page breaks (they mess up the measurement of the text);
any commands that imply a page break, like \chapter
(for the same reason);
floating environments;
footnotes (alas, so it is!).
The last limitation is admittedly cumbersome.
\newpage\null\thispagestyle{empty}\newpage
The question is more to do with knowing how many pages a section will span ahead of time, then automatically inserting a page break if needed. I suppose in the end of the day, I can simply look at the output and insert breaks manually... but I wanted the code to do this for me! Ultimate laziness of a hobbyist programmer...