### 3.2.1 Creating titles headers and footers

#### Titles explained

Each `\book` block in a single input file produces a separate output file, see File structure. Within each output file three types of titling areas are provided: Book Titles at the beginning of each book, Bookpart Titles at the beginning of each bookpart and Score Titles at the beginning of each score.

Values of titling fields such as `title` and `composer` are set in `\header` blocks. (For the syntax of `\header` blocks and a complete list of the fields available by default see Default layout of bookpart and score titles). Book Titles, Bookpart Titles and Score Titles can all contain the same fields, although by default the fields in Score Titles are limited to `piece` and `opus`.

`\header` blocks may be placed in four different places to form a descending hierarchy of `\header` blocks:

- At the top of the input file, before all `\book`, `\bookpart`, and `\score` blocks.
- Within a `\book` block but outside all the `\bookpart` and `\score` blocks within that book.
- Within a `\bookpart` block but outside all `\score` blocks within that bookpart.
- After the music expression in a `\score` block.

The values of the fields filter down this hierarchy, with the values set higher in the hierarchy persisting unless they are over-ridden by a value set lower in the hierarchy, so:

- A Book Title is derived from fields set at the top of the input file, modified by fields set in the `\book` block. The resulting fields are used to print the Book Title for that book, providing that there is other material which generates a page at the start of the book, before the first bookpart. A single `\pageBreak` will suffice.
- A Bookpart Title is derived from fields set at the top of the input file, modified by fields set in the `\book` block, and further modified by fields set in the `\bookpart` block. The resulting values are used to print the Bookpart Title for that bookpart.
- A Score Title is derived from fields set at the top of the input file, modified by fields set in the `\book` block, further modified by fields set in the `\bookpart` block and finally modified by fields set in the `\score` block. The resulting values are used to print the Score Title for that score. Note, though, that only `piece` and `opus` fields are printed by default in Score Titles unless the `\paper` variable, `print-all-headers`, is set to `#t`.

Note: Remember when placing a \`header` block inside a \`score` block, that the music expression must come before the \`header` block.

It is not necessary to provide `\header` blocks in all four places: any or even all of them may be omitted. Similarly, simple input files may omit the `\book` and `\bookpart` blocks, leaving them to be created implicitly.

If the book has only a single score, the `\header` block should normally be placed at the top of the file so that just a Bookpart Title is produced, making all the titling fields available for use.

If the book has multiple scores a number of different arrangements of `\header` blocks are possible, corresponding to the various types of musical publications. For example, if the publication contains several pieces by the same composer a `\header` block placed at the top of the file specifying the book title and the composer with `\header` blocks in each `\score` block specifying the `piece` and/or `opus` would be most suitable, as here:

>     \header {
>       title = "SUITE I."
>       composer = "J. S. Bach."
>     }

>     \score {
>       \new Staff \relative g, {
>         \clef bass
>         \key g \major
>         \repeat unfold 2 { g16( d' b') a b d, b' d, } |
>         \repeat unfold 2 { g,16( e' c') b c e, c' e, } |
>       }
>       \header {
>         piece = "Prélude."
>       }
>     }

>     \score {
>       \new Staff \relative b {
>         \clef bass
>         \key g \major
>         \partial 16 b16 |
>         <g, d' b'~>4 b'16 a( g fis) g( d e fis) g( a b c) |
>         d16( b g fis) g( e d c) b(c d e) fis( g a b) |
>       }
>       \header {
>         piece = "Allemande."
>       }
>     }

More complicated arrangements are possible. For example, text fields from the `\header` block in a book can be displayed in all Score Titles, with some fields over-ridden and some manually suppressed:

>     \book {
>       \paper {
>         print-all-headers = ##t
>       }
>       \header {
>         title = "DAS WOHLTEMPERIRTE CLAVIER"
>         subtitle = "TEIL I"
>         % Do not display the tagline for this book
>         tagline = ##f
>       }
>       \markup { \vspace #1 }
>       \score {
>         \new PianoStaff <<
>           \new Staff { s1 }
>           \new Staff { \clef "bass" s1 }
>         >>
>         \header {
>           title = "PRAELUDIUM I"
>           opus = "BWV 846"
>           % Do not display the subtitle for this score
>           subtitle = ##f
>         }
>       }
>       \score {
>         \new PianoStaff <<
>           \new Staff { s1 }
>           \new Staff { \clef "bass" s1 }
>         >>
>         \header {
>           title = "FUGA I"
>           subsubtitle = "A 4 VOCI"
>           opus = "BWV 846"
>           % Do not display the subtitle for this score
>           subtitle = ##f
>         }
>       }
>     }

#### See also

Notation Reference: File structure, Default layout of bookpart and score titles, Custom layout for titles.

#### Default layout of bookpart and score titles

This example demonstrates all `\header` variables:

>     \book {
>       \header {
>           % The following fields are centered
>         dedication = "Dedication"
>         title = "Title"
>         subtitle = "Subtitle"
>         subsubtitle = "Subsubtitle"
>           % The following fields are evenly spread on one line
>           % the field "instrument" also appears on following pages
>         instrument = \markup \with-color #green "Instrument"
>         poet = "Poet"
>         composer = "Composer"
>           % The following fields are placed at opposite ends of the same line
>         meter = "Meter"
>         arranger = "Arranger"
>           % The following fields are centered at the bottom
>         tagline = "tagline goes at the bottom of the last page"
>         copyright = "copyright goes at the bottom of the first page"
>       }
>       \score {
>         { s1 }
>         \header {
>             % The following fields are placed at opposite ends of the same line
>           piece = "Piece 1"
>           opus = "Opus 1"
>         }
>       }
>       \score {
>         { s1 }
>         \header {
>             % The following fields are placed at opposite ends of the same line
>           piece = "Piece 2 on the same page"
>           opus = "Opus 2"
>         }
>       }
>       \pageBreak
>       \score {
>         { s1 }
>         \header {
>             % The following fields are placed at opposite ends of the same line
>           piece = "Piece 3 on a new page"
>           opus = "Opus 3"
>         }
>       }
>     }

Note that

- The instrument name will be repeated on every page.
- Only `piece` and `opus` are printed in a `\score` when the paper variable `print-all-headers` is set to `##f` (the default).
- Text fields left unset in a `\header` block are replaced with `\null` markups so that the space is not wasted.
- The default settings for `scoreTitleMarkup` place the `piece` and `opus` text fields at opposite ends of the same line.

To change the default layout see Custom layout for titles.

If a `\book` block starts immediately with a `\bookpart` block, no Book Title will be printed, as there is no page on which to print it. If a Book Title is required, begin the `\book` block with some markup material or a `\pageBreak` command.

Use the `breakbefore` variable inside a `\header` block that is itself in a `\score` block, to make the higher-level `\header` block titles appear on the first page on their own, with the music (defined in the `\score` block) starting on the next.

    \book {
      \header {
        title = "This is my Title"
        subtitle = "This is my Subtitle"
        copyright = "This is the bottom of the first page"
      }
      \score {
        \repeat unfold 4 { e'' e'' e'' e'' }
        \header {
          piece = "This is the Music"
          breakbefore = ##t
        }
      }
    }

#### See also

Learning Manual: How LilyPond input files work,

Notation Reference: Custom layout for titles, File structure.

Installed Files: ‘`ly/titling-init.ly`’.

#### Default layout of headers and footers

Headers and footers are lines of text appearing at the top and bottom of pages, separate from the main text of a book. They are controlled by the following `\paper` variables:

- `oddHeaderMarkup`
- `evenHeaderMarkup`
- `oddFooterMarkup`
- `evenFooterMarkup`

These markup variables can only access text fields from top-level `\header` blocks (which apply to all scores in the book) and are defined in ‘`ly/titling-init.ly`’. By default:

- page numbers are automatically placed on the top far left (if even) or top far right (if odd), starting from the second page.
- the `instrument` text field is placed in the center of every page, starting from the second page.
- the `copyright` text is centered on the bottom of the first page.
- the `tagline` is centered on the bottom of the last page, and below the `copyright` text if there is only a single page.

The default tagline can be changed by adding a `tagline` in the top-level `\header` block.

    \book {
      \header {
        tagline = "... music notation for Everyone"
      }
      \score {
        \relative c' {
          c4 d e f
        }
      }
    }

To remove the `tagline` set the value to `##f`.

其他语言：deutsch, español, français, italiano, 日本語。
About automatic language selection.

#### LilyPond — Notation Reference v2.18.2 (稳定分支).