A.11.5 Conditional markup

\if condition? (procedure) argument (markup)

Test condition?, and only insert argument if it is true.

The condition is provided as a procedure taking an output definition and a property alist chain. The procedure is applied, and its result determines whether to print the markup. This command is most useful inside oddHeaderMarkup or similar. Here is an example printing page numbers in bold:

\paper {
  oddHeaderMarkup =
    \markup \fill-line {
      ""
      \if #print-page-number
           \bold \fromproperty #'page:page-number-string
    }
  evenHeaderMarkup =
    \markup \fill-line {
      \if #print-page-number
           \bold \fromproperty #'page:page-number-string
      ""
    }
}
\unless condition? (procedure) argument (markup)

Test condition?, and only insert argument if it is false.

This function is similar to \if; the following example shows how to print the copyright notice on all pages but the last instead of just the first page.

\paper {
  oddFooterMarkup = \markup {
    \unless #on-last-page-of-part \fill-line {
      \fromproperty #'header:copyright
    }
  }
}

\header {
  copyright = "© LilyPond Authors. License: GFDL."
  tagline = "© LilyPond Authors.  Documentation placed
under the GNU Free Documentation License
version 1.3."
}

LilyPond 記譜法リファレンス v2.25.21 (開発版).