or
Caleb
koma
I am working on a document that has a large number of external Lilypond files included. These render quite well and (while a bit of a pain to use) lilypond-book is smart enough to render the music systems at the available width of the host document and add line breaks (and potentially page breaks) between systems.

I can even override the function Lilypond uses between systems to tell latex that I really-really don't want page breaks inside individual scores if it can help it:

\newcommand{\betweenLilyPondSystem}[1]{\linebreak\nopagebreak[3]}

This works great for keeping short scores together on a page, but there are a few cases where this is simply not possible. Some scores are simply too long and must span two or more pages. In these cases it much easier on musicians if the score starts on an even (left) page and runs over onto an odd (right) page.

I would like to be able to change the weight of the page-break penalty so that scores tried to stay on a page but that scores starting on even pages shouldn't care much (say \nopagebreak[1]), while ones on odd pages make a big deal out of it (\nopagebreak[3] or even 4). Additionally, it would be nice to have some sort  of page-clear inserted before scores that were going to run over such that longer scores always start on even pages.

How could this be accomplished?
Matthias imported from SE
You can try to use the command \ifthispageodd{<true part>}{<false part>}, which is part of KOMA-Script. It uses a label in the .aux file and therefore needs at least two LaTeX passes to function. In your case it could look like:

\ifthispageodd{\nopagebreak[3]}{\nopagebreak[4]}

Without a MWE, however, it is difficult to tell whether this really works or not.
Variable page break penalty for odd/even pages?
Caleb
**Note**: This old imported question is the back-story for [this new followup question](https://topanswers.xyz/tex?q=339).
Caleb
I just want to note it would be totally _free_ to place a break from even→odd but give a small penalty for odd→even breaks (while still allowing them, because frequently  that's the least bad break possible).
Caleb
But I don't have so much space that I can afford to not start the score on whatever page I'm on. The entire reason for these shenanigans is that I'm cramming too much content into a limited page count and trying to be as least-bad as possible.
Caleb replying to Skillmon
I do have complete control over the entire pipeline. They use a custom class and the content is auto-generated by a script.
Skillmon
@Caleb Do you have control over the output routine, that is, can you output each score into a special environment? If that were the case you could measure the total height of each score and make an educated guess whether it should start on an even page because it is too long.