Next: Vocal music, Previous: Editorial annotations, Up: Top
These snippets illustrate the Notation Reference, section Text.
This snippet shows how to bring the lyrics line closer to the staff.
% Default layout: << \new Staff \new Voice = melody \relative c' { c4 d e f g4 f e d c1 } \new Lyrics \lyricsto melody { aa aa aa aa aa aa aa aa aa } % Reducing the minimum space below the staff and above the lyrics: \new Staff \with { \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 4) } \new Voice = melody \relative c' { c4 d e f g4 f e d c1 } \new Lyrics \with { \override VerticalAxisGroup #'minimum-Y-extent = #'(-1.2 . 1) } \lyricsto melody { aa aa aa aa aa aa aa aa aa } >>
Instrument names are generally printed to the left of the staves. To
align the names of several different intruments, put them in a
\markup
block and use one of the following possibilites:
* Right-aligned instrument names: this is the default behavior
*
Center-aligned instrument names: using the \hcenter-in #n
command
places the instrument names inside a padded box, with n
being
the width
of the box
*
Left-aligned instrument names: the names are printed on top of an
empty box, using the \combine
command
with an \hspace #n
object.
\paper { indent = #0 left-margin = #30 line-width = #160 } \new StaffGroup \relative c' << \new Staff { \set Staff.instrumentName = #"Piccolo" c1^"default" | c \break \set Staff.instrumentName = \markup { \hcenter-in #10 Piccolo } c1^"centered" | c \break \set Staff.instrumentName = \markup { \combine \hspace #8 Piccolo } c1^"left-aligned" | c } \new Staff { \set Staff.instrumentName = #"Flute" c1 | c \break \set Staff.instrumentName = \markup { \hcenter-in #10 Flute } c1 | c \break \set Staff.instrumentName = \markup { \combine \hspace #8 Flute } c1 | c } >>
Horizontal alignment for lyrics cam be set by overriding the
self-alignment-X
property of the LyricText
object.
#-1
is left, #0
is center and #1
is right;
however, you can use #LEFT
, #CENTER
and #RIGHT
as
well.
\layout { ragged-right = ##f } \relative c'' { c1 c1 c1 } \addlyrics { \once \override LyricText #'self-alignment-X = #LEFT "This is left-aligned" \once \override LyricText #'self-alignment-X = #CENTER "This is centered" \once \override LyricText #'self-alignment-X = #1 "This is right-aligned" }
If specified, text marks may be aligned with notation objects other
than bar lines. These objects include ambitus
,
breathing-sign
, clef
, custos
, staff-bar
,
left-edge
, key-cancellation
, key-signature
, and
time-signature
.
In such cases, text marks will be horizontally centered above the object. However this can be changed, as demonstrated on the second line of this example (in a score with multiple staves, this setting should be done for all the staves).
\relative c' { e1 % the RehearsalMark will be centered above the Clef \override Score.RehearsalMark #'break-align-symbols = #'(clef) \key a \major \clef treble \mark "↓" e % the RehearsalMark will be centered above the TimeSignature \override Score.RehearsalMark #'break-align-symbols = #'(time-signature) \key a \major \clef treble \time 3/4 \mark "↓" e2. % the RehearsalMark will be centered above the KeySignature \override Score.RehearsalMark #'break-align-symbols = #'(key-signature) \key a \major \clef treble \time 4/4 \mark "↓" e1 \break e % the RehearsalMark will be aligned with the left edge of the KeySignature \once \override Score.KeySignature #'break-align-anchor-alignment = #LEFT \mark "↓" \key a \major e % the RehearsalMark will be aligned with the right edge of the KeySignature \once \override Score.KeySignature #'break-align-anchor-alignment = #RIGHT \key a \major \mark "↓" e % the RehearsalMark will be aligned with the left edge of the KeySignature % and then shifted right by 1 unit. \once \override Score.KeySignature #'break-align-anchor = #1 \key a \major \mark "↓" e1 }
The \whiteout
command underlays a markup with a white box.
Since staff lines are in a lower layer than most other grobs, this
white box will not overlap any other grob.
\layout { ragged-right = ##f } \relative c' { \override TextScript #'extra-offset = #'(2 . 4) c2-\markup { \whiteout \pad-markup #0.5 "middle C" } c }
This example provides a function to typeset a hairpin (de)crescendo with some additional text below it, such as "molto" or "poco". The example also illustrates how to modify the way an object is normally printed, using some Scheme code.
hairpinWithCenteredText = #(define-music-function (parser location text) (markup?) #{ \override Voice.Hairpin #'stencil = #(lambda (grob) (ly:stencil-aligned-to (ly:stencil-combine-at-edge (ly:stencil-aligned-to (ly:hairpin::print grob) X CENTER) Y DOWN (ly:stencil-aligned-to (ly:text-interface::print grob) X CENTER)) X LEFT)) \override Voice.Hairpin #'text = $text #}) hairpinMolto = \hairpinWithCenteredText \markup { \italic molto } hairpinMore = \hairpinWithCenteredText \markup { \bigger moltissimo } \layout { ragged-right = ##f } { \hairpinMolto c'2\< c'\f \hairpinMore c'2\< c'\f }
The default font families for text can be overridden with
make-pango-font-tree
.
\paper { % change for other default global staff size. myStaffSize = #20 %{ run lilypond -dshow-available-fonts blabla to show all fonts available in the process log. %} #(define fonts (make-pango-font-tree "Times New Roman" "Nimbus Sans" "Luxi Mono" ;; "Helvetica" ;; "Courier" (/ myStaffSize 20))) } \relative { c'^\markup { roman: foo \bold bla \italic bar \italic \bold baz } c'_\markup { \override #'(font-family . sans) { sans: foo \bold bla \italic bar \italic \bold baz } } c'2^\markup { \override #'(font-family . typewriter) { mono: foo \bold bla \italic bar \italic \bold baz } } }
Some dynamics may involve text indications (such as "più forte" or
"piano subito"). They can be produced using a \markup
block.
piuF = \markup { \italic più \dynamic f } \layout { ragged-right = ##f } \relative c'' { c2\f c-\piuF }
The part combiner tool ( \partcombine
command ) allows the
combination of several different parts on the same staff. Text
directions such as "solo" or "a2" are added by default; to remove
them, simply set the property printPartCombineTexts
to
"false". For vocal scores (hymns), there is no need to add
"solo"/"a2" texts, so they should be switched off. However, it
might be better not to use it if there are any solos, as they won't be
indicated. In such cases, standard polyphonic notation may be
preferable.
This snippet presents the three ways two parts can be printed on a same
staff: standard polyphony, \partcombine
without texts, and
\partcombine
with texts.
musicUp = \relative c'' { \time 4/4 a4 c4.( g8) a4 | g4 e' g,( a8 b) | c b a2. } musicDown = \relative c'' { g4 e4.( d8) c4 | r2 g'4( f8 e) | d2 \stemDown a } \score { << << \new Staff { \set Staff.instrumentName = "Standard polyphony " << \musicUp \\ \musicDown >> } \new Staff \with { printPartCombineTexts = ##f } { \set Staff.instrumentName = "PartCombine without texts " \partcombine \musicUp \musicDown } \new Staff { \set Staff.instrumentName = "PartCombine with texts " \partcombine \musicUp \musicDown } >> >> \layout { indent = 6.0\cm \context { \Score \override SystemStartBar #'collapse-height = #30 } } }
Although the easiest way to add parentheses to a dynamic mark is to use
a \markup
block, this method has a downside: the created
objects will behave like text markups, and not like dynamics.
However, it is possible to create a similar object using the equivalent
Scheme code (as described in "Markup programmer interface"), combined
with the make-dynamic-script
function. This way, the markup will
be regarded as a dynamic, and therefore will remain compatible with
commands such as \dynamicUp
or \dynamicDown
.
\paper { ragged-right = ##t } parenF = #(make-dynamic-script (markup #:line (#:normal-text #:italic #:fontsize 2 "(" #:hspace -0.8 #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")" ))) \relative c'' { c4\parenF c c \dynamicUp c\parenF }
Unlike text scripts, rehearsal marks cannot be stacked at a particular point
in a score: only one RehearsalMark
object is created. Using an
invisible measure and bar line, an extra rehearsal mark can be added, giving
the appearance of two marks in the same column.
This method may also prove useful for placing rehearsal marks at both the end of one system and the start of the following system.
{ \key a \major \set Score.markFormatter = #format-mark-box-letters \once \override Score.RehearsalMark #'outside-staff-priority = #5000 \once \override Score.RehearsalMark #'self-alignment-X = #LEFT \once \override Score.RehearsalMark #'break-align-symbols = #'(key-signature) \mark \markup { \bold { Senza denti } } % the hidden measure and bar line \once \override Score.TimeSignature #'stencil = ##f \time 1/16 s16 \bar "" \time 4/4 \once \override Score.RehearsalMark #'self-alignment-X = #LEFT \once \override Score.RehearsalMark #'break-align-symbols = #'(bar-line) \mark \markup { \box \bold Intro } d'1 \mark \default d'1 }
The \startTextSpan
and \stopTextSpan
commands allow the
creation of text spanners as easily as pedal indications or
octavations. Override some properties of the TextSpanner
object
to modify its output.
\relative c'' { \override TextSpanner #'edge-text = #'("bla" . "blu") a \startTextSpan b c a \stopTextSpan \override TextSpanner #'dash-period = #2 \override TextSpanner #'dash-fraction = #0.0 a \startTextSpan b c a \stopTextSpan \revert TextSpanner #'style \override TextSpanner #'style = #'dashed-line \override TextSpanner #'bound-details #'left #'text = \markup { \draw-line #'(0 . 1) } \override TextSpanner #'bound-details #'right #'text = \markup { \draw-line #'(0 . -2) } a \startTextSpan b c a \stopTextSpan \set Staff.middleCPosition = #-13 \override TextSpanner #'dash-period = #10 \override TextSpanner #'dash-fraction = #0.5 \override TextSpanner #'thickness = #10 a \startTextSpan b c a \stopTextSpan \set Staff.middleCPosition = #-6 }
All header fields with special meanings.
\header { copyright = "copyright" title = "title" subtitle = "subtitle" composer = "composer" arranger = "arranger" instrument = "instrument" metre = "metre" opus = "opus" piece = "piece" poet = "poet" texidoc = "All header fields with special meanings." copyright = "public domain" enteredby = "jcn" source = "urtext" } \layout { ragged-right = ##f } \score { \relative c'' { c1 | c | c | c } } \score { \relative c'' { c1 | c | c | c } \header { title = "localtitle" subtitle = "localsubtitle" composer = "localcomposer" arranger = "localarranger" instrument = "localinstrument" metre = "localmetre" opus = "localopus" piece = "localpiece" poet = "localpoet" copyright = "localcopyright" } }
PostScript code can be directly inserted inside a \markup
block.
% PostScript is a registered trademark of Adobe Systems Inc. \relative c'' { a4-\markup { \postscript #"3 4 moveto 5 3 rlineto stroke" } -\markup { \postscript #"[ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke " } b4-\markup { \postscript #"3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke" } s2 a'1 }
To format individual syllables in lyrics, use \markup { ....
}
on these lyrics.
% Tip taken from http://lists.gnu.org/archive/html/lilypond-user/2007-12/msg00215.html \header { title = "Markup can be used inside lyrics!" } mel = \relative c'' { c4 c c c } lyr = \lyricmode { Lyrics \markup { \italic "can" } \markup {\with-color #red "contain" } \markup {\fontsize #8 \bold "Markup!" } } << \context Voice = melody \mel \context Lyrics \lyricsto melody \lyr >>
This can be achieved by separating those syllables by tildes.
\lyrics { wa~o~a }
Text that can spread over pages is entered with the
\markuplines
command.
#(set-default-paper-size "a6") #(define-markup-list-command (paragraph layout props args) (markup-list?) (interpret-markup-list layout props (make-justified-lines-markup-list (cons (make-hspace-markup 2) args)))) % Candide, Voltaire \markuplines \override-lines #'(baseline-skip . 2.5) { \paragraph { Il y avait en Westphalie, dans le château de M. le baron de Thunder-ten-tronckh, un jeune garçon à qui la nature avait donné les mœurs les plus douces. Sa physionomie annonçait son âme. Il avait le jugement assez droit, avec l'esprit le plus simple ; c'est, je crois, pour cette raison qu'on le nommait Candide. Les anciens domestiques de la maison soupçonnaient qu'il était fils de la sœur de monsieur le baron et d'un bon et honnête gentilhomme du voisinage, que cette demoiselle ne voulut jamais épouser parce qu'il n'avait pu prouver que soixante et onze quartiers, et que le reste de son arbre généalogique avait été perdu par l'injure du temps. } \paragraph { Monsieur le baron était un des plus puissants seigneurs de la Westphalie, car son château avait une porte et des fenêtres. Sa grande salle même était ornée d'une tapisserie. Tous les chiens de ses basses-cours composaient une meute dans le besoin ; ses palefreniers étaient ses piqueurs; le vicaire du village était son grand-aumônier. Ils l'appelaient tous monseigneur, et ils riaient quand il faisait des contes. } }
Internally, the set-octavation
function sets the properties
ottavation
(for example, to "8va"
or "8vb"
)
and middleCPosition
. To override the text of the bracket, set
ottavation
after invoking set-octavation
.
{ \ottava #1 \set Staff.ottavation = #"8" c''1 \ottava #0 c'1 \ottava #1 \set Staff.ottavation = #"Text" c''1 }
By putting the output of lilypond-version
into a lyric or a
text markup, it is possible to print the version number of LilyPond in
a score, or in a document generated with lilypond-book
.
\score { \new Lyrics { \override Score.RehearsalMark #'self-alignment-X = #LEFT \mark #(ly:export (string-append "Processed with LilyPond version " (lilypond-version))) s2 } }
Instead of having a full staff for the melody and lyrics, lyrics can be centered between the staves of a piano staff.
upper = \relative c'' { \clef treble \key c \major \time 4/4 a4 b c d } lower = \relative c { \clef bass \key c \major \time 4/4 a2 c } text = \lyricmode { Aaa Bee Cee Dee } \score { \new GrandStaff << \new Staff = upper { \new Voice = "singer" \upper } \new Lyrics \lyricsto "singer" \text \new Staff = lower { \lower } >> \layout { \context { \GrandStaff \accepts "Lyrics" } \context { \Lyrics \consists "Bar_engraver" } } \midi { } }
Marks can be printed at the end of the current line, instead of the beginning of the following line. This is particularly useful when a mark has to be added at the end of a score – when there is no next line.
In such cases, the right end of the mark has to be aligned with the final bar line, as demonstrated on the second line of this example.
\relative c'' { \override Score.RehearsalMark #'break-visibility = #begin-of-line-invisible g2 c d,2 a' \mark \default \break \override Score.RehearsalMark #'self-alignment-X = #RIGHT g2 b, c1 \bar "||" \mark "D.C. al Fine" }
Although text marks are normally only printed above the topmost staff, they may also be printed on every staff.
{ \new Score \with { \remove "Mark_engraver" } << \new Staff \with { \consists "Mark_engraver" } { c''1 \mark "molto" c'' } \new Staff \with { \consists "Mark_engraver" } { c'1 \mark "molto" c' } >> }
This example shows how to add a markup command to get a three sided box around some text (or other markup).
% New command to add a three sided box, with sides north, west and south % Based on the box-stencil command defined in scm/stencil.scm % Note that you use ";" to comment a line in Scheme #(define-public (NWS-box-stencil stencil thickness padding) "Add a box around STENCIL, producing a new stencil." (let* ((x-ext (interval-widen (ly:stencil-extent stencil 0) padding)) (y-ext (interval-widen (ly:stencil-extent stencil 1) padding)) (y-rule (make-filled-box-stencil (cons 0 thickness) y-ext)) (x-rule (make-filled-box-stencil (interval-widen x-ext thickness) (cons 0 thickness)))) ; (set! stencil (ly:stencil-combine-at-edge stencil X 1 y-rule padding)) (set! stencil (ly:stencil-combine-at-edge stencil X -1 y-rule padding)) (set! stencil (ly:stencil-combine-at-edge stencil Y 1 x-rule 0.0)) (set! stencil (ly:stencil-combine-at-edge stencil Y -1 x-rule 0.0)) stencil)) % The corresponding markup command, based on the \box command defined % in scm/define-markup-commands.scm #(define-markup-command (NWS-box layout props arg) (markup?) "Draw a box round @var{arg}. Looks at @code{thickness}, @code{box-padding} and @code{font-size} properties to determine line thickness and padding around the markup." (let* ((th (chain-assoc-get 'thickness props 0.1)) (size (chain-assoc-get 'font-size props 0)) (pad (* (magstep size) (chain-assoc-get 'box-padding props 0.2))) (m (interpret-markup layout props arg))) (NWS-box-stencil m th pad))) % Test it: \layout { ragged-right = ##f } \relative c' { c2^\markup { \NWS-box ABCD } c^\markup { \NWS-box \note #"4" #1.0 } }
Various scripts may be used for texts (like titles and lyrics) by entering them in UTF-8 encoding, and using a Pango based backend. Depending on the fonts installed, this fragment will render Bulgarian (Cyrillic), Hebrew, Japanese and Portuguese.
% end verbatim - this comment is a hack to prevent texinfo.tex % from choking on non-European UTF-8 subsets % Cyrillic font bulgarian = \lyricmode { Жълтата дюля беше щастлива, че пухът, който цъфна, замръзна като гьон. } hebrew = \lyricmode { זה כיף סתם לשמוע איך תנצח קרפד עץ טוב בגן. } japanese = \lyricmode { いろはにほへど ちりぬるを わがよたれぞ つねならむ うゐのおくや まけふこえて あさきゆめみじ ゑひもせず } % "a legal song to you" portuguese = \lyricmode { à vo -- cê uma can -- ção legal } \relative { c2 d e2 f g2 f e1 } \addlyrics { \bulgarian } \addlyrics { \hebrew } \addlyrics { \japanese } \addlyrics { \portuguese }
This template is basically the same as the simple "Vocal ensemble"
template, with the exception that here all the lyrics lines are placed
using alignAboveContext
and alignBelowContext
.
global = { \key c \major \time 4/4 } sopMusic = \relative c'' { c4 c c8[( b)] c4 } sopWords = \lyricmode { hi hi hi hi } altoMusic = \relative c' { e4 f d e } altoWords = \lyricmode { ha ha ha ha } tenorMusic = \relative c' { g4 a f g } tenorWords = \lyricmode { hu hu hu hu } bassMusic = \relative c { c4 c g c } bassWords = \lyricmode { ho ho ho ho } \score { \new ChoirStaff << \new Staff = women << \new Voice = "sopranos" { \voiceOne << \global \sopMusic >> } \new Voice = "altos" { \voiceTwo << \global \altoMusic >> } >> \new Lyrics \with { alignAboveContext = women } \lyricsto sopranos \sopWords \new Lyrics \with { alignBelowContext = women } \lyricsto altos \altoWords % we could remove the line about this with the line below, since we want % the alto lyrics to be below the alto Voice anyway. % \new Lyrics \lyricsto altos \altoWords \new Staff = men << \clef bass \new Voice = "tenors" { \voiceOne << \global \tenorMusic >> } \new Voice = "basses" { \voiceTwo << \global \bassMusic >> } >> \new Lyrics \with { alignAboveContext = men } \lyricsto tenors \tenorWords \new Lyrics \with { alignBelowContext = men } \lyricsto basses \bassWords % again, we could replace the line above this with the line below. % \new Lyrics \lyricsto basses \bassWords >> \layout { \context { % a little smaller so lyrics % can be closer to the staff \Staff \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3) } } }
This page is for LilyPond-2.11.58 (development-branch).
Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.
Your suggestions for the documentation are welcome.