Separating footers with a horizontal line

Revision as of 12:21, 26 February 2026 by SimonAlbrecht (talk | contribs) (remove spurious comment, add new comment for documentation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Separating footers from the main content of the page using a horizontal line can be done by altering the oddFooterMarkup paper variable (and evenFooterMarkup, if they should be different). However, this requires printing the horizontal line only if any footer is shown on that page; this snippet demonstrates how to program such a condition.

\version "2.24"

#(define (separator-condition layout props arg)
   ;; only print `arg' if copyright and/or tagline is printed on that page
   (if (or (and (chain-assoc-get 'header:copyright props)
                ;; on-first-page-of-part copied from ly/titling-init.ly
                (= (chain-assoc-get 'page:page-number props -1)
                   (ly:output-def-lookup layout 'first-page-number)))
           (and (chain-assoc-get 'header:tagline props)
                ;; on-last-page (two following conditions)
                (chain-assoc-get 'page:is-bookpart-last-page props #f)
                (chain-assoc-get 'page:is-last-bookpart props #f)))
       (interpret-markup layout props arg)
       empty-stencil))

\header {
  tagline = "Special tagline"
}

\paper {
  #(set-paper-size "a9landscape")
  oddFooterMarkup = \markup \center-column {
    \on-the-fly \separator-condition \with-color #grey \override #'(span-factor . 1/3) \draw-hline
    %% Copyright header field only on first page in each bookpart.
    \if \on-first-page-of-part \fill-line {
      \fromproperty #'header:copyright
    }
    %% Tagline only on last page in each book.
    \if \on-last-page \fill-line {
      \fromproperty #'header:tagline
    }
  }
}

\bookpart {
  \markup "(Public Domain content)"
}
\bookpart {
  \header { copyright = "©" }
  \markup "(Copyright content)"
  \pageBreak
  \markup \column { "(no Copyright statement""on subsequent page)" }
}
\bookpart {
  \markup "(final page with tagline)"
}