| [ << Titles and headers ] | [Top][Contents][Index] | [ Working with input files >> ] |
| [ < Default layout of headers and footers ] | [ Up: Titles and headers ] | [ Custom text formatting for titles > ] |
21.2 Custom titles, headers, and footers
| 21.2.1 Custom text formatting for titles | ||
| 21.2.2 Custom layout for titles | ||
| 21.2.3 Custom layout for headers and footers |
| [ << Titles and headers ] | [Top][Contents][Index] | [ Working with input files >> ] |
| [ < Custom titles, headers, and footers ] | [ Up: Custom titles, headers, and footers ] | [ Custom layout for titles > ] |
21.2.1 Custom text formatting for titles
Standard \markup commands can be used to customize any header,
footer, or title text within the \header block.
\score { \header { piece = \markup { \fontsize #4 \bold "PRAELUDIUM I" } opus = \markup { \italic "BWV 846" } } { s1 } }![]()
See also
Notation Reference: Formatting text.
21.2.2 Custom layout for titles
\markup commands in the \header block are useful for
simple text formatting, but they do not allow precise control over the
placement of titles. To customize the placement of the text fields,
change either or both of the following \paper variables:
-
bookTitleMarkup -
scoreTitleMarkup
See Default layout of bookpart and score titles for the
placement of titles when using the default values of these
\markup variables.
The default setting for scoreTitleMarkup defined in
ly/titling-init.ly is as follows.
scoreTitleMarkup = \markup \column {
\if \should-print-all-headers { \bookTitleMarkup \hspace #1 }
\fill-line {
\fromproperty #'header:piece
\fromproperty #'header:opus
}
}
This places the piece and opus text fields at opposite
ends of the same line.
\score { \header { piece = "PRAELUDIUM I" opus = "BWV 846" } { s1 } }![]()
The next example redefines scoreTitleMarkup so that the
piece text field is centered, using a large, bold font.
\book { \paper { indent = 0\mm scoreTitleMarkup = \markup { \fill-line { \null \fontsize #4 \bold \fromproperty #'header:piece \fromproperty #'header:opus } } } \header { tagline = ##f } \score { \header { piece = "PRAELUDIUM I" opus = "BWV 846" } { s1 } } }![]()
Text fields not normally effective in score \header blocks
can be printed in the score title area if print-all-headers is
placed inside the \paper block. A disadvantage of using this
method is that text fields intended specifically for the
bookpart title area need to be manually suppressed in every
\score block. See Titles explained.
To avoid this, add the desired text field to the scoreTitleMarkup
definition. In the following example, the composer text field
(normally associated with bookTitleMarkup) is added to
scoreTitleMarkup, allowing each score to list a different
composer.
\book { \paper { indent = 0\mm scoreTitleMarkup = \markup { \fill-line { \null \fontsize #4 \bold \fromproperty #'header:piece \fromproperty #'header:composer } } } \header { tagline = ##f } \score { \header { piece = "MENUET" composer = "Christian Petzold" } { s1 } } \score { \header { piece = "RONDEAU" composer = "François Couperin" } { s1 } } }![]()
It is also possible to create your own custom text fields and refer to them in the markup definition.
\book { \paper { indent = 0\mm scoreTitleMarkup = \markup { \fill-line { \null \override #`(direction . ,UP) \dir-column { \center-align \fontsize #-1 \bold \fromproperty #'header:mycustomtext %% User-defined field \center-align \fontsize #4 \bold \fromproperty #'header:piece } \fromproperty #'header:opus } } } \header { tagline = ##f } \score { \header { piece = "FUGA I" mycustomtext = "A 4 VOCI" %% User-defined field opus = "BWV 846" } { s1 } } }![]()
See also
Notation Reference: Titles explained.
| [ << Titles and headers ] | [Top][Contents][Index] | [ Working with input files >> ] |
| [ < Custom layout for titles ] | [ Up: Custom titles, headers, and footers ] | [ Creating output file metadata > ] |
21.2.3 Custom layout for headers and footers
\markup commands in the \header block are useful for
simple text formatting, but they do not allow precise control over the
placement of headers and footers. To customize the placement of
the text fields, use one or more of the following \paper
variables.
-
oddHeaderMarkup -
evenHeaderMarkup -
oddFooterMarkup -
evenFooterMarkup
The \markup command \if can be used to add markup
conditionally to header and footer text defined within the
\paper block, using the following syntax within
\markup:
\if condition argument
The condition is tested each time the markup is interpreted. The
resulting markup is argument if the condition is true, but empty if false.
Typical conditions include tests for page numbers (first page, last page,
specific page, …). To test for the condition being false, replace
\if with \unless.
The following example centers page numbers at the bottom of every
page. First, the default settings for oddHeaderMarkup and
evenHeaderMarkup are removed by assigning #f.
Then, oddFooterMarkup is redefined with the page
number centered. Finally, evenFooterMarkup is given the
same layout by defining it as \oddFooterMarkup:
\book { \paper { print-page-number = ##t print-first-page-number = ##t oddHeaderMarkup = ##f evenHeaderMarkup = ##f oddFooterMarkup = \markup { \fill-line { \if \should-print-page-number \fromproperty #'page:page-number-string } } evenFooterMarkup = \oddFooterMarkup } \score { \new Staff { s1 \break s1 \break s1 } } }![]()
Here is a list of all predefined procedures available for use with
\if and \unless.
Syntax Condition tested \on-first-pageFirst page in the book? \on-last-pageLast page in the book? \on-first-page-of-partFirst page in the book part? \on-last-page-of-partLast page in the book part? \on-page nOn page number n? \single-pageDoes the book fit on just one page? \should-print-page-numbers-globalPrint page numbers in the book? 8 \should-print-page-numberPrint the number of the current page? \should-print-all-headersIs print-all-headerstrue?
See also
Notation Reference: Titles explained, Default layout of bookpart and score titles, Conditional markup.
Installed Files: ../ly/titling-init.ly.
Footnotes
(8)
\should-print-page-numbers-global can differ from
\should-print-page-number for the first page in the book,
depending on the print-first-page-number setting of the
\paper block.
| [Top][Contents][Index] |
![[image of music]](../f5/lily-d854eb16.png)
![[image of music]](../9b/lily-349beea6.png)
![[image of music]](../a5/lily-f8ab8f2d.png)
![[image of music]](../11/lily-52dc54fb.png)
![[image of music]](../83/lily-c6fb3ec8.png)
![[image of music]](../9b/lily-ca71dd9e.png)