Discussion:
Protecting against page breaks in markup
Richard Shann
2018-11-27 15:20:04 UTC
Permalink
I'm creating an index to my scores, in the form of a sequence of
LilyPond markups (for title, composer, first few bars etc).
It is working well apart from page breaking which can occur mid-entry.
Is there a way of turning page breaks off and back on around each
entry?

Richard Shann
Thomas Morley
2018-11-27 20:48:05 UTC
Permalink
Am Di., 27. Nov. 2018 um 16:22 Uhr schrieb Richard Shann
Post by Richard Shann
I'm creating an index to my scores, in the form of a sequence of
LilyPond markups (for title, composer, first few bars etc).
What exactly are you doing? An example would be nice.
Post by Richard Shann
It is working well apart from page breaking which can occur mid-entry.
Is there a way of turning page breaks off and back on around each
entry?
Well, of course you know about \noPageBreak and \pageBreak.

Probably you can wrap a \column around all the single markups. At
least page-break can then only happen before or after the whole
thingy.
Depends on what you actually (want to) do.

Cheers,
Harm
Richard Shann
2018-11-28 09:19:37 UTC
Permalink
Post by Thomas Morley
Am Di., 27. Nov. 2018 um 16:22 Uhr schrieb Richard Shann
Post by Richard Shann
I'm creating an index to my scores, in the form of a sequence of
LilyPond markups (for title, composer, first few bars etc).
What exactly are you doing? An example would be nice.
Well, I have my printed scores of trio sonatas filed under composer but
I needed to find just those scores with a Tenor as the second part - I
have perhaps half-a-dozen of these, lost amongst just over a thousand
scores. So I thought I would write a script in Scheme that would
traverse the file system opening scores, extracting an incipit, title,
composer, instrumentation etc and then creating a new score that just
comprised top level markups, one for each entry. Each entry looks like
this:


\markup {\column {\draw-hline}}\markup "Fesch: Sonatina IV"
\markup {instrumentation:Treble, Tenor, Basso}

DenemoGlobalTranspose = #(define-music-function (parser location arg)(ly:music?) #{\transpose c' c'#arg #})

incipit =
\markup \score {\DenemoGlobalTranspose
{ \clef treble
{ \time 3/4 }
{ \key f \major}
%{/home/rshann/musicScores/Fesch/IMSLP270267-PMLP437812-fesch_op7_1.pdf:202:7724:9%} d'' 4 g' 4. ees'' 8 d'' 4 g' 4. bes'' 8
}
\layout {indent = 0.0\cm }
}
\incipit

This all works nicely, and I even managed to allow the user to supply a
custom Scheme expression to act as a filter, but I was left with the
problem that LilyPond would page break in mid-entry.
Post by Thomas Morley
Post by Richard Shann
It is working well apart from page breaking which can occur mid-
entry.
Is there a way of turning page breaks off and back on around each
entry?
Well, of course you know about \noPageBreak and \pageBreak.
Probably you can wrap a \column around all the single markups. At
least page-break can then only happen before or after the whole
thingy.
Ah, thank you - that works. I just looked back at the docs and I see it
says

"The default page breaking may be overridden by inserting \pageBreak or
\noPageBreak commands. 
[...]
The \pageBreak and \noPageBreak commands may also be inserted at top-
level, between scores and top-level markups."

but I didn't spot where it said what the default page breaking is
(besides allowing breaks at bar lines), I think the last bit is the
clue - page breaks are allowed between top level markups, but nowhere
inside them.

I just hoped there might be a \pageBreaksOff and \pageBreaksOn command
lurking somewhere, hence my question. But now I look at it with a clear
understanding of where LilyPond might break it seems obvious where to
put in sufficient \noPageBreak commands to keep each entry un-split.

Richard
Flaming Hakama by Elaine
2018-11-28 00:33:56 UTC
Permalink
---------- Forwarded message ----------
Date: Tue, 27 Nov 2018 15:20:04 +0000
Subject: Protecting against page breaks in markup
I'm creating an index to my scores, in the form of a sequence of
LilyPond markups (for title, composer, first few bars etc).
It is working well apart from page breaking which can occur mid-entry.
Is there a way of turning page breaks off and back on around each
entry?
Richard Shann
When pagination gets hairy, I use \autoPageBreaksOff, and then manually put
in all page breaks using \pageBreak


HTH,

Elaine Alt
415 . 341 .4954 "*Confusion is
highly underrated*"
***@flaminghakama.com
Producer ~ Composer ~ Instrumentalist
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Richard Shann
2018-11-28 09:50:04 UTC
Permalink
Post by Flaming Hakama by Elaine
---------- Forwarded message ----------
Cc: 
Bcc: 
Date: Tue, 27 Nov 2018 15:20:04 +0000
Subject: Protecting against page breaks in markup
I'm creating an index to my scores, in the form of a sequence of
LilyPond markups (for title, composer, first few bars etc).
It is working well apart from page breaking which can occur mid-
entry.
Is there a way of turning page breaks off and back on around each
entry?
Richard Shann
When pagination gets hairy, I use \autoPageBreaksOff, and then
manually put in all page breaks using \pageBreak
Sorry, I should have made it clearer that this index is being
automatically generated. Now you point out that there is an
\autoOageBreaksOff, which is what I thought I needed, I realize that it
wouldn't help - I would need to turn them off and back on between each
entry in the hope that LilyPond would take advantage of such an Off/On
sequence to insert a page break in between if needed, which I'm sure it
wouldn't :(

Richard
Lukas-Fabian Moser
2018-11-28 14:45:06 UTC
Permalink
Post by Richard Shann
Sorry, I should have made it clearer that this index is being
automatically generated. Now you point out that there is an
\autoOageBreaksOff, which is what I thought I needed, I realize that it
wouldn't help - I would need to turn them off and back on between each
entry in the hope that LilyPond would take advantage of such an Off/On
sequence to insert a page break in between if needed, which I'm sure it
wouldn't :(
I'm not sure I understand you correctly, but it is perfectly possible to
forbid page breaks between arbitrary markup lines:

\version "2.19.80"

three-line-entry = #(define-void-function (a b c) (string? string? string?)
          (add-text a)
          (add-music #{ \noPageBreak #})
          (add-text b)
          (add-music #{ \noPageBreak #})
          (add-text c)
          )

#(do ((i 1 (1+ i)))
   ((> i 200))
  (three-line-entry "Entry nr.:" (number->string i) "End of entry. Only
good place for page break."))

Best
Lukas
Richard Shann
2018-11-29 08:31:43 UTC
Permalink
Post by Lukas-Fabian Moser
Post by Richard Shann
Sorry, I should have made it clearer that this index is being
automatically generated. Now you point out that there is an
\autoOageBreaksOff, which is what I thought I needed, I realize that it
wouldn't help - I would need to turn them off and back on between each
entry in the hope that LilyPond would take advantage of such an Off/On
sequence to insert a page break in between if needed, which I'm sure it
wouldn't :(
I'm not sure I understand you correctly, but it is perfectly possible
to 
yes, that's what I needed to do, and I'm now doing that - it's working
fine now. What I didn't realize was that Lily will not put page breaks
inside a \markup {} - Harm pointed this out to me via his \column
{\line .. \line ...} example, Lily does not break at any of the
\lines. 
Once he'd tipped me off I looked again at the docs and saw that,
although they don't quite explicitly say that Lily will not page break
inside a markup block it is implied by the bit of the docs I quoted
"The \pageBreak and \noPageBreak commands may also be inserted [...]
between [...] top-level markups."
Perhaps the Docs should contain an explicit statement there that no
automatic breaking will happen inside a \markup {} ...

Richard
Thomas Morley
2018-11-29 08:50:51 UTC
Permalink
Am Do., 29. Nov. 2018 um 09:33 Uhr schrieb Richard Shann
Post by Richard Shann
Post by Lukas-Fabian Moser
Post by Richard Shann
Sorry, I should have made it clearer that this index is being
automatically generated. Now you point out that there is an
\autoOageBreaksOff, which is what I thought I needed, I realize that it
wouldn't help - I would need to turn them off and back on between each
entry in the hope that LilyPond would take advantage of such an Off/On
sequence to insert a page break in between if needed, which I'm sure it
wouldn't :(
I'm not sure I understand you correctly, but it is perfectly possible to
yes, that's what I needed to do, and I'm now doing that - it's working
fine now. What I didn't realize was that Lily will not put page breaks
inside a \markup {} - Harm pointed this out to me via his \column
{\line .. \line ...} example, Lily does not break at any of the
\lines.
Once he'd tipped me off I looked again at the docs and saw that,
although they don't quite explicitly say that Lily will not page break
inside a markup block it is implied by the bit of the docs I quoted
"The \pageBreak and \noPageBreak commands may also be inserted [...]
between [...] top-level markups."
Perhaps the Docs should contain an explicit statement there that no
automatic breaking will happen inside a \markup {} ...
Richard
Well, in NR 1.8.1 Writing text one can read about toplevel markup/markuplist:
"
Separate text
...
Separate text blocks can be spread over multiple pages, making it
possible to print text documents or books entirely within LilyPond.
This feature, and the specific syntax it requires, are described in
Multi-page markup.
...
"

And later

"
Multi-page markup

Although standard markup objects are not breakable, a specific syntax
makes it possible to enter lines of text that can spread over multiple
pages:
"

Could you suggest how to improve this?


Cheers,
Harm
Richard Shann
2018-11-29 10:03:06 UTC
Permalink
Post by Thomas Morley
Am Do., 29. Nov. 2018 um 09:33 Uhr schrieb Richard Shann
Post by Richard Shann
Post by Lukas-Fabian Moser
Post by Richard Shann
Sorry, I should have made it clearer that this index is being
automatically generated. Now you point out that there is an
\autoOageBreaksOff, which is what I thought I needed, I realize that it
wouldn't help - I would need to turn them off and back on
between
each
entry in the hope that LilyPond would take advantage of such an Off/On
sequence to insert a page break in between if needed, which I'm sure it
wouldn't :(
I'm not sure I understand you correctly, but it is perfectly possible
to
yes, that's what I needed to do, and I'm now doing that - it's working
fine now. What I didn't realize was that Lily will not put page breaks
inside a \markup {} - Harm pointed this out to me via his \column
{\line .. \line ...} example, Lily does not break at any of the
\lines.
Once he'd tipped me off I looked again at the docs and saw that,
although they don't quite explicitly say that Lily will not page break
inside a markup block it is implied by the bit of the docs I quoted
"The \pageBreak and \noPageBreak commands may also be inserted [...]
between [...] top-level markups."
Perhaps the Docs should contain an explicit statement there that no
automatic breaking will happen inside a \markup {} ...
Richard
Well, in NR 1.8.1 Writing text one can read about toplevel
"
Separate text
...
Separate text blocks can be spread over multiple pages, making it
possible to print text documents or books entirely within LilyPond.
This feature, and the specific syntax it requires, are described in
Multi-page markup.
...
"
And later
"
Multi-page markup
Although standard markup objects are not breakable, a specific syntax
makes it possible to enter lines of text that can spread over
multiple
"
Could you suggest how to improve this?
Yes, I think I can. The presence of the word "Although" in the last-
quoted paragraph indicates that the writer expected that the fact that
standard markup objects were not breakable had been documented
elsewhere. I suggest

"4.3.2 Page breaking

The default page breaking may be overridden by inserting \pageBreak or
\noPageBreak commands. "

could become

"4.3.2 Page breaking

By default page breaks may be inserted at bar lines and between top-
level markups. The default page breaking may be overridden by inserting
\pageBreak or \noPageBreak commands. "

As a further point is the term "standard markup objects" well-
documented - does it mean "top-level markups", or what I tend to refer
to as \markup{} blocks?

Richard
Thomas Morley
2018-11-29 21:53:33 UTC
Permalink
Hi Richard,

please bear in mind I'm not a native speaker.
Thus work on the docs is pretty difficult for me.

That said:

Am Do., 29. Nov. 2018 um 11:04 Uhr schrieb Richard Shann
Post by Richard Shann
Post by Thomas Morley
Well, in NR 1.8.1 Writing text one can read about toplevel
"
Separate text
...
Separate text blocks can be spread over multiple pages, making it
possible to print text documents or books entirely within LilyPond.
This feature, and the specific syntax it requires, are described in
Multi-page markup.
...
"
And later
"
Multi-page markup
Although standard markup objects are not breakable, a specific syntax
makes it possible to enter lines of text that can spread over multiple
"
Could you suggest how to improve this?
Yes, I think I can. The presence of the word "Although" in the last-
quoted paragraph indicates that the writer expected that the fact that
standard markup objects were not breakable had been documented
elsewhere.
I think "standard markup" is a little foggy.
Probably:
"Although text objects invoked with \markup are not breakable, ..."

and in NR 1.8.1

Separate text
...

Separate text entered with \markup can't be distributed over multiple
pages, thus a a page break will happen only before or after the whole
text. In extreme cases the text will exceed the paper bottom.
Nevertheless, separate text blocks can be spread over multiple pages,
making it possible to print text documents or books entirely within
LilyPond. This feature, and the specific syntax it requires, are
described in Multi-page markup.
Post by Richard Shann
I suggest
"4.3.2 Page breaking
The default page breaking may be overridden by inserting \pageBreak or
\noPageBreak commands. "
could become
"4.3.2 Page breaking
By default page breaks may be inserted at bar lines and between top-
level markups. The default page breaking may be overridden by inserting
\pageBreak or \noPageBreak commands. "
Quoting a little more from NR:
"The default page breaking may be overridden by inserting \pageBreak
or \noPageBreak commands. These commands are analogous to \break and
\noBreak. They should be inserted at a bar line.
[...]
The \pageBreak and \noPageBreak commands may also be inserted at
top-level, between scores and top-level markups."

Does it not contain all what's needed to know?
Post by Richard Shann
As a further point is the term "standard markup objects" well-
documented - does it mean "top-level markups", or what I tend to refer
to as \markup{} blocks?
I think what's meant is the difference between \markup and \markuplist


Cheers,
Harm
David Kastrup
2018-11-29 22:21:52 UTC
Permalink
Post by Thomas Morley
Am Do., 29. Nov. 2018 um 11:04 Uhr schrieb Richard Shann
Post by Richard Shann
As a further point is the term "standard markup objects" well-
documented - does it mean "top-level markups", or what I tend to refer
to as \markup{} blocks?
I think what's meant is the difference between \markup and \markuplist
It's worth pointing out that for typographic treatment a toplevel markup
(namely a markup invoked outside of any other expression) is
indistinguishable from a markup list with a single element: either are
processed by calling toplevel-text-handler with a markup list (in case
of the markup, a list containing just one markup as element).
--
David Kastrup
Thomas Morley
2018-11-29 23:34:36 UTC
Permalink
Post by David Kastrup
Post by Thomas Morley
Am Do., 29. Nov. 2018 um 11:04 Uhr schrieb Richard Shann
Post by Richard Shann
As a further point is the term "standard markup objects" well-
documented - does it mean "top-level markups", or what I tend to refer
to as \markup{} blocks?
I think what's meant is the difference between \markup and \markuplist
It's worth pointing out that for typographic treatment a toplevel markup
(namely a markup invoked outside of any other expression) is
indistinguishable from a markup list with a single element: either are
processed by calling toplevel-text-handler with a markup list (in case
of the markup, a list containing just one markup as element).
--
David Kastrup
You mean what can be observed with below?

\markup \italic "foo-1"
\markup \italic "bar-1"
\markup \italic "buzz-1"

\markuplist \italic { "foo-2" "bar-2" "buzz-2" }

#(newline)
#(display-scheme-music (reverse (ly:parser-lookup 'toplevel-scores)))

=>

(list (list (markup #:italic "foo-1"))
(list (markup #:italic "bar-1"))
(list (markup #:italic "buzz-1"))
(list (markup #:italic "foo-2")
(markup #:italic "bar-2")
(markup #:italic "buzz-2")))


If I add:
\paper {
ragged-last-bottom = ##f
markup-markup-spacing.stretchability = 1000
}
and watch the printed output, the single markups are distributed over
the page, while the elements of the markuplist are kept close
together.
Am undecided whether I should have expected it or should be surprised ... lol


Cheers,
Harm
David Kastrup
2018-11-30 10:21:21 UTC
Permalink
Post by Thomas Morley
Post by David Kastrup
Post by Thomas Morley
Am Do., 29. Nov. 2018 um 11:04 Uhr schrieb Richard Shann
Post by Richard Shann
As a further point is the term "standard markup objects" well-
documented - does it mean "top-level markups", or what I tend to refer
to as \markup{} blocks?
I think what's meant is the difference between \markup and \markuplist
It's worth pointing out that for typographic treatment a toplevel markup
(namely a markup invoked outside of any other expression) is
indistinguishable from a markup list with a single element: either are
processed by calling toplevel-text-handler with a markup list (in case
of the markup, a list containing just one markup as element).
--
David Kastrup
You mean what can be observed with below?
\markup \italic "foo-1"
\markup \italic "bar-1"
\markup \italic "buzz-1"
\markuplist \italic { "foo-2" "bar-2" "buzz-2" }
Those are different. The first three all get an own call of
toplevel-markup-handler while the third is a single call. The following
would be equivalent:

\markup \italic "foo-1"
\markup \italic "bar-1"
\markup \italic "buzz-1"

\markuplist \italic { "foo-2" }
\markuplist \italic { "bar-2" }
\markuplist \italic { "buzz-2" }
Post by Thomas Morley
#(newline)
#(display-scheme-music (reverse (ly:parser-lookup 'toplevel-scores)))
=>
(list (list (markup #:italic "foo-1"))
(list (markup #:italic "bar-1"))
(list (markup #:italic "buzz-1"))
(list (markup #:italic "foo-2")
(markup #:italic "bar-2")
(markup #:italic "buzz-2")))
\paper {
ragged-last-bottom = ##f
markup-markup-spacing.stretchability = 1000
}
and watch the printed output, the single markups are distributed over
the page, while the elements of the markuplist are kept close
together.
Am undecided whether I should have expected it or should be surprised ... lol
LilyPond is a complex system. Expecting things is likely to end up in
surprises anyway. Much of the time I answer questions I check the code
before feigning competence.
--
David Kastrup
Richard Shann
2018-11-30 08:55:24 UTC
Permalink
Post by Thomas Morley
Hi Richard,
please bear in mind I'm not a native speaker.
Thus work on the docs is pretty difficult for me.
ok - I'll take that as welcoming further tweaks to the wording ...
below
Post by Thomas Morley
Am Do., 29. Nov. 2018 um 11:04 Uhr schrieb Richard Shann
Post by Richard Shann
Post by Thomas Morley
Well, in NR 1.8.1 Writing text one can read about toplevel
"
Separate text
...
Separate text blocks can be spread over multiple pages, making it
possible to print text documents or books entirely within
LilyPond.
This feature, and the specific syntax it requires, are described in
Multi-page markup.
...
"
And later
"
Multi-page markup
Although standard markup objects are not breakable, a specific syntax
makes it possible to enter lines of text that can spread over multiple
"
Could you suggest how to improve this?
Yes, I think I can. The presence of the word "Although" in the last-
quoted paragraph indicates that the writer expected that the fact that
standard markup objects were not breakable had been documented
elsewhere.
I think "standard markup" is a little foggy.
"Although text objects
well, graphics too, anything gobbled up by \markup
Post by Thomas Morley
invoked with \markup are not breakable, ..."
Although breaks will not be generated within the output of \markup
expressions ...
Post by Thomas Morley
and in NR 1.8.1
Separate text
...
Separate text entered with \markup can't be distributed over multiple
pages, thus a a page break will happen only before or after the whole
text. In extreme cases the text will exceed the paper bottom.
In the worst case the text will run off the bottom of the page.

(Hmm, that is rather idiomatic English -
In the worst case the text will overrun the bottom margin and be
trucated.)
Post by Thomas Morley
Nevertheless, separate text blocks can be spread over multiple pages,
making it possible to print text documents or books entirely within
LilyPond. This feature, and the specific syntax it requires, are
described in Multi-page markup.
Post by Richard Shann
I suggest
"4.3.2 Page breaking
The default page breaking may be overridden by inserting \pageBreak or
\noPageBreak commands. "
could become
"4.3.2 Page breaking
By default page breaks may be inserted at bar lines and between top-
level markups. The default page breaking may be overridden by inserting
\pageBreak or \noPageBreak commands. "
"The default page breaking may be overridden by inserting \pageBreak
or \noPageBreak commands. These commands are analogous to \break and
\noBreak. They should be inserted at a bar line.
[...]
The \pageBreak and \noPageBreak commands may also be inserted at
top-level, between scores and top-level markups."
Does it not contain all what's needed to know?
Yes - that was my point: it contains all that is needed, but obliquely,
saying \pageBreak can be placed between toplevel markups hints that
automatic breaking will not occur within them and manual page breaks
cannot be placed within them.

Richard
Flaming Hakama by Elaine
2018-11-29 02:08:15 UTC
Permalink
Post by Richard Shann
Post by Flaming Hakama by Elaine
---------- Forwarded message ----------
Date: Tue, 27 Nov 2018 15:20:04 +0000
Subject: Protecting against page breaks in markup
I'm creating an index to my scores, in the form of a sequence of
LilyPond markups (for title, composer, first few bars etc).
It is working well apart from page breaking which can occur mid-
entry.
Is there a way of turning page breaks off and back on around each
entry?
Richard Shann
When pagination gets hairy, I use \autoPageBreaksOff, and then
manually put in all page breaks using \pageBreak
Sorry, I should have made it clearer that this index is being
automatically generated. Now you point out that there is an
\autoOageBreaksOff, which is what I thought I needed, I realize that it
wouldn't help - I would need to turn them off and back on between each
entry in the hope that LilyPond would take advantage of such an Off/On
sequence to insert a page break in between if needed, which I'm sure it
wouldn't :(
Richard
Yeah, once autoPageBreaksOff is declared, all page breaks need to be added
manually.

I've found that when the automatic page breaks don't work, it usually
easier to go this way than the other alternative, which is to use auto page
breaks and add noPageBreak where necessary.

Mostly because forcing a no page break doesn't guarantee that the newly
calculated automatic break will be in a good place, so you often end up
adding lots of noPageBreak commands in close succession, and it ends up
being more tedious and less semantic.

Also, page break calculations take up time, so using manual breaks speeds
up compilation and saves time in the long run.

I'm not sure if when you say this is being automatically generated that it
may be produced in different editions which need different page breaks. But
even in that case it is probably easiest to use tags or something like the
addition engraver to specify the page breaks.

You can also try putting scores in book Parts which have the effect of
forcing a page break at the start of the book part.
Loading...