Next: , Previous: Contexts and engravers, Up: Top


Tweaks and overrides

alignment-vertical-spacing.ly

By setting properties in NonMusicalPaperColumn, vertical spacing of alignments can be adjusted per system.

By setting alignment-extra-space or fixed-alignment-extra-space an individual system may be stretched vertically.

For technical reasons, \overrideProperty has to be used for setting properties on individual objects. \override in a \context block may still be used for global overrides.

#(set-global-staff-size 13)

\relative c''
\new StaffGroup <<
  \new Staff {
    c1\break 
    c\break 
    c\break
  }
  \new Staff { 
    c1 c c 
  }
  \new PianoStaff <<
    \new Voice  {
      \set PianoStaff.instrumentName = #"piano"
      \set PianoStaff.shortInstrumentName = #"pn"
      c1_"normal"
      
      \overrideProperty
        #"Score.NonMusicalPaperColumn"
        #'line-break-system-details
        #'((fixed-alignment-extra-space . 15))
      c_"fixed-aligment-extra-space"

      \overrideProperty
        #"Score.NonMusicalPaperColumn"
        #'line-break-system-details
        #'((alignment-extra-space . 15))
      c_"aligment-extra-space"
    }
    { c1 c c }
  >>
>>


[image of music]

altering-the-number-of-stems-in-a-beam.ly

You can alter the number of stems in a beam. In this example, two sets of four 32nds are joined, as if they were 8th notes.

\relative {
  #(override-auto-beam-setting '(end * * * *)  1 4)
  f32 g a b b a g f

  f32 g a 
  \set stemRightBeamCount = #1  b
  \set stemLeftBeamCount = #1 b
  a g f
}

[image of music]

caesura-railtracks-with-fermata.ly

A caesura is sometimes denoted with a double "railtracks" breath mark with a fermata sign positioned over the top of the railtracks. This snippet should present an optically pleasing combination of railtracks and a fermata.

{
  \context Voice {
    c''2.
    % use some scheme code to construct the symbol
    \override BreathingSign #'text = #(markup #:line 
                                  (#:musicglyph "scripts.caesura.curved"
                                   #:translate (cons -1.75 1.6) 
                                   #:musicglyph "scripts.ufermata"
                                  ))
    \breathe c''4
    % set the breathe mark back to normal
    \revert BreathingSign #'text
    c''2. \breathe c''4
    \bar "|."
  }
}

[image of music]

changing-an-individual-notes-size-in-a-chord.ly

Individual noteheads in a chord can be modified with the \tweak command inside a chord, by altering the 'font-size property.

Inside the chord (within the brackets < >), before the note to be altered, place the \tweak command, followed by #'font-size and define the proper size like #-2 (a tiny notehead).

The code for the chord example shown:

\header{
  title = "Modify an individual notehead's size in a chord"
}

Notes = \relative {
  <\tweak #'font-size #+2 c e g c \tweak #'font-size #-2 e>1^\markup{A tiny e}_\markup{A big c}
}

\score{
  \Notes
}

[image of music]

changing-properties-for-individual-grobs.ly

The \applyOutput command gives you the ability to tune any layout object, in any context. It requires a Scheme function with three arguments; advanced users can write it quite easily, whereas new users may want to use pre-defined functions such as this snippet, or the example in the manual.

% ****************************************************************
% ly snippet:
% ****************************************************************

\layout {
  ragged-right = ##t
}

#(define (mc-squared gr org cur)
  (let*
   (
     (ifs (ly:grob-interfaces gr))
     (sp (ly:grob-property gr 'staff-position))
   )
   (if (memq 'note-head-interface ifs)
    (begin
     (ly:grob-set-property! gr 'stencil ly:text-interface::print)
     (ly:grob-set-property! gr 'font-family 'roman)
     (ly:grob-set-property! gr 'text
      (make-raise-markup -0.5
       (case sp
	((-5) (make-simple-markup "m"))
	((-3) (make-simple-markup "c "))
	((-2) (make-smaller-markup (make-bold-markup "2")))
	(else (make-simple-markup "bla"))
      ))))
  )))

\context Voice \relative c' {
  \stemUp
  \set autoBeaming = ##f

  { <d f g b>8

    \applyOutput #'Voice #mc-squared
    <d f g b>
  }
}

% ****************************************************************
% end ly snippet
% ****************************************************************

[image of music]

changing-the-default-text-font-family.ly

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'^\markup {
    \override #'(font-family . typewriter)
    {
      mono: foo \bold bla \italic bar \italic \bold baz
    }
  }
}  

[image of music]

changing-the-staff-size.ly

In order to change staff sizes, both staff-space and fontSize must be scaled.

{
  \new Staff \relative c'' { \dynamicDown c8 \ff c c c c c c c } 
}

{
  \new Staff \with {
    fontSize = #-3
    \override StaffSymbol #'staff-space = #(magstep -3)
  }
  {
    \clef bass
    c8 c c c  c c c c
  }
}

[image of music]

clefs-commonly-tweaked-properties.ly

The command \clef "treble_8" is equivalent to setting clefGlyph, clefPosition (which controls the Y position of the clef), middleCPosition and clefOctavation. A clef is printed when any of these properties are changed.

Note that changing the glyph, the position of the clef, or the octavation, does not in itself change the position of subsequent notes on the staff: the position of middle C must also be specified to do this. The positional parameters are relative to the staff centre line, positive numbers displacing upwards, counting 1 for each line and space. The clefOctavation value would normally be set to 7, -7, 15 or -15, but other values are not invalid.

When a clef change takes place at a line break the new clef symbol is printed at both the end of the previous line and the beginning of the new line by default. If the warning clef at the end of the previous line is not required it can be suppressed by setting the explicitClefVisibility Staff property to the value end-of-line-invisible. The default behaviour can be recovered with \unset Staff.explicitClefVisibility.

The following examples show the possibilities when setting these properties manually. On the first line, the manual changes preserve the standard relative positioning of clefs and notes, whereas on the second line, they do not.

{
  % The default treble clef
  c'1
  % The standard bass clef
  \set Staff.clefGlyph = #"clefs.F"
  \set Staff.clefPosition = #2
  \set Staff.middleCPosition = #6
  c'
  % The baritone clef
  \set Staff.clefGlyph = #"clefs.C"
  \set Staff.clefPosition = #4
  \set Staff.middleCPosition = #4
  c'
  % The standard choral tenor clef
  \set Staff.clefGlyph = #"clefs.G"
  \set Staff.clefPosition = #-2
  \set Staff.clefOctavation = #-7
  \set Staff.middleCPosition = #1
  c'
  % A non-standard clef
  \set Staff.clefPosition = #0
  \set Staff.clefOctavation = #0
  \set Staff.middleCPosition = #-4
  c' \break
  
  
  % The following clef changes do not preserve
  % the normal relationship between notes and clefs:
  
  \set Staff.clefGlyph = #"clefs.F"
  \set Staff.clefPosition = #2
  c'
  \set Staff.clefGlyph = #"clefs.G"
  c'
  \set Staff.clefGlyph = #"clefs.C"
  c'
  \set Staff.clefOctavation = #7
  c'
  \set Staff.clefOctavation = #0
  \set Staff.clefPosition = #0
  c'
  
  % Here we go back to the normal clef:
  
  \set Staff.middleCPosition = #4
  c'
}

[image of music]

coloring-objects.ly

LilyPond gives you the ability to assign different colors to any grob in your score, such as NoteHeads, Alterations, Beams and so on, by simply overriding the #'color property and choosing your color (over 200 colors are available, see the "List of Colors" Appendix in the Manual).

\relative {
  \override Accidental #'color = #darkgreen
  \override Beam #'color = #cyan
  \override NoteHead #'color = #darkyellow
  c4
  \override NoteHead #'color = #red
  f
  \override NoteHead #'color = #darkmagenta
  g
  \override NoteHead #'color = #darkblue
  b
  \override NoteHead #'color = #green
  \override Stem #'color = #blue
  e8 es d dis e4 r
}

[image of music]

controlling-tuplet-bracket-visibility.ly

Default behaviour of tuplet-bracket visibility is to print a bracket unless there is a beam of the same length as the tuplet. To control the visibility of tuplet brackets, you can set the property TupletBracket #'bracket-visibility to either ##t (always print a bracket), ##f (never print a bracket) or #'if-no-beam (only print a bracket if there is no beam).

mus = \relative c'' {
  \times 2/3 {c16 [ d e } f8]
  \times 2/3 {c8 d e }
  \times 2/3 { c4 d e }
}

\new Voice \relative c'{
  << \mus s4^"default" >>
   \override TupletBracket #'bracket-visibility = #'if-no-beam
  << \mus s4^"'if-no-beam" >>
  \override TupletBracket #'bracket-visibility = ##t
  << \mus s4^"#t" >>
  \override TupletBracket #'bracket-visibility = ##f
  << \mus s4^"#f" >>
} 

[image of music]

creating-text-spanners.ly

The <code>\startTextSpan</code> and <code>\stopTextSpan</code> commands give you the ability to create text spanners as easily as pedals indications or octavations. Override some properties of the <code>TextSpanner</code> 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 = #.5
    \override TextSpanner  #'thickness = #10
    a \startTextSpan
    b c 
    a \stopTextSpan
    \set Staff.middleCPosition = #-6	
}

[image of music]

custodes.ly

Custodes may be engraved in various styles.

\layout {
  \context {
    \Staff
    \consists Custos_engraver
  }
  ragged-right = ##t
}

{
  \override Staff.Custos  #'neutral-position = #4

  \override Staff.Custos  #'style = #'hufnagel
  c'1^"hufnagel"
  \break < d' a' f''>1

  \override Staff.Custos  #'style = #'medicaea
  c'1^"medicaea"
  \break < d' a' f''>1

  \override Staff.Custos  #'style = #'vaticana
  c'1^"vaticana"
  \break < d' a' f''>1

  \override Staff.Custos  #'style = #'mensural
  c'1^"mensural"
  \break < d' a' f''>1
}

[image of music]

drawing-boxes-around-grobs.ly

The print-function can be overridden to draw a box around an arbitrary grob.

\relative c'' {
  \override TextScript  #'stencil =
  #(make-stencil-boxer 0.1 0.3 ly:text-interface::print)

  c'4^"foo"

  \override Stem  #'stencil =
  #(make-stencil-boxer 0.05 0.25 ly:stem::print)

  \override Score.RehearsalMark  #'stencil =
  #(make-stencil-boxer 0.15 0.3 ly:text-interface::print)
  b8
  \revert Stem #'stencil

  c4. c4 \mark "F" c1
}

[image of music]

drawing-circles-around-various-objects.ly

The \circle command allows you to draw circles around various objects, for example fingering indications. However, some objects require specific tweaks: rehearsal marks depend on the Score.markFormatter context, bar numbers on the Score.BarNumber context, and so on.

You can tweak the printing of your circles by setting some properties such as #'thickness, #'circle-padding or #'font-size.

\relative c'{
c1
\set Score.markFormatter
  = #(lambda (mark context)
             (make-circle-markup (format-mark-numbers mark context)))
\mark \default
c2 d^\markup{\circle \finger "2"}
\override Score.BarNumber #'break-visibility = #all-visible
\override Score.BarNumber  #'stencil
  = #(make-stencil-circler 0.1 0.25 ly:text-interface::print)
}

[image of music]

making-an-object-invisible-with-the-transparent-property.ly

Setting the transparent property will cause an object to be printed in `invisible ink': the object is not printed, but all its other behavior is retained. The object still takes up space, it takes part in collisions, and slurs, and ties and beams can be attached to it.

The snippet demonstrates how to connect different voices using ties. Normally, ties only connect two notes in the same voice. By introducing a tie in a different voice, and blanking the first up-stem in that voice, the tie appears to cross voices.

\relative c'' <<
  {
    \once \override Stem #'transparent = ##t
    b8~ b8\noBeam
  } \\ {
    b[ g8]
  }
>>

[image of music]

manually-controlling-beam-positions.ly

Beam positions may be controlled manually, by overriding the positions setting of the Beam grob.

\score { 
    \context Voice \relative c {
	%% from upper staffline (position 4) to centre (position 0)
	\override Beam  #'positions = #'(2 . 0)
	 c'8[ c] 
	
	%% from center to one above centre (position 2)
	\override Beam  #'positions = #'(0 . 1)
	 c[ c]
  }

}


[image of music]

move-specific-text.ly

Objects of the same type, like text, can be moved around by using some Scheme code.

#(define (make-text-checker text)
   (lambda (grob) (equal? text (ly:grob-property grob 'text))))

\score {
  \relative c''' {
    \stemUp
    \applyOutput #'Voice
    #(outputproperty-compatibility
      (make-text-checker (make-simple-markup "m.d."))
      'extra-offset '(-3.5 . -4.5))
    a^2^"m.d."
  }
  \layout { ragged-right = ##t}
}

[image of music]

proportional-strict-notespacing.ly

If strict-note-spacing is set spacing of notes is not influenced by bars or clefs part way along the system. Rather, they are put just before the note that occurs at the same time. This may cause collisions.

\paper {
  ragged-right = ##t
  indent = 0
}
\layout {
  \context {
    \Score
  }
}

\relative c'' <<
  \override Score.SpacingSpanner #'strict-note-spacing = ##t 
  \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
  \new Staff {
    c8[ c \clef alto c c \grace { d16 }  c8 c]  c4 c2
    \grace { c16[ c16] }
    c2 }
  \new Staff {
    c2  \times 2/3 { c8 \clef bass cis,, c } 
    c4
    c1
  }
>>

[image of music]

rest-styles.ly

Rests may be used in various styles.

\layout {
    indent = 0.0
    raggedright = ##t
}

\context Staff \relative c {
    \set Score.timing = ##f
    \override Staff.Rest  #'style = #'mensural
    r\maxima^\markup \typewriter { mensural }
    r\longa r\breve r1 r2 r4 r8 r16 r32 r64 r128 r128
    \bar "" 

    \override Staff.Rest  #'style = #'neomensural
    r\maxima^\markup \typewriter { neomensural }
    r\longa r\breve r1 r2 r4 r8 r16 r32 r64 r128 r128
    \bar "" 

    \override Staff.Rest  #'style = #'classical
    r\maxima^\markup \typewriter { classical }
    r\longa r\breve r1 r2 r4 r8 r16 r32 r64 r128 r128
    \bar ""
    
    \override Staff.Rest  #'style = #'default
    r\maxima^\markup \typewriter { default }
    r\longa r\breve r1 r2 r4 r8 r16 r32 r64 r128 r128
    
}


[image of music]

rhythmic-slashes.ly

In "simple" lead-sheets, sometimes no actual notes are written, instead only "rhythmic patterns" and chords above the measures are noted giving the structure of a song. Such a feature is for example useful while creating/transcribing the structure of a song and also when sharing lead sheets with guitarists or jazz musicians.

The standard support for this is described in section "Measure repeats", but then the first beat has to be an ordinary note or rest.

This example shows two solutions to this problem, by redefining ordinary rests to be printed as slashes. (If the duration of each beat is not a quarter note, replace the r4 in the definitions by a rest of the appropriate duration).

% Macro to print single slash
rs = {
  \once \override Rest #'stencil = #ly:percent-repeat-item-interface::beat-slash
  \once \override Rest #'thickness = #'0.48
  \once \override Rest #'slope = #'1.7
  r4
}


% Function to print a specified number of slashes
comp = #(define-music-function (parser location count) ( integer?)
  #{
    \override Rest #'stencil = #ly:percent-repeat-item-interface::beat-slash
    \override Rest #'thickness = #'0.48
    \override Rest #'slope = #'1.7
    \repeat unfold $count { r4 }
    \revert Rest #'stencil
  #}
)

\score{
  \relative c'{
    c d e f | \rs \rs \rs \rs | \comp #4 |
  }
}

[image of music]

time-signature-in-parentheses.ly

You may put the time signature in parentheses.

tsMarkup = \markup  {
  \number {
    \bracket \column { "2" "4" }
  }
}

\score {
  \relative c'' {

% FIXME: Gee, it doesn't work with 2.10 -vv

%{

  \override Staff.TimeSignature   #'print-function = #Text_interface::print
  \override Staff.TimeSignature   #'text = #tsMarkup

%}

  \time 2/4

    a4 b8 c |
  }
}

[image of music]

transcription-of-ancient-music-with-incipit.ly

As a workaround to get real incipits which are independent from the main score these are included as a markup into the field normally used for the instrument name. As for now lyrics can only be added as a direct markup. It doesn't unfortunately conform with the spacing of the main lyrics.

global = {
  \set Score.skipBars = ##t
  \key g \major
  \time 4/4
  
  %make the staff lines invisible on staves
  \override Staff.BarLine #'transparent = ##t
  \skip 1*8 % the actual music

  % let finis bar go through all staves
  \override Staff.BarLine #'transparent = ##f

  % finis bar
  \bar "|."
}

  
discantusNotes = {
  \transpose c' c'' {
    \clef "treble"
    d'2. d'4 |
    b e' d'2 |
    c'4 e'4.( d'8 c' b |
    a4) b a2 |
    b4.( c'8 d'4) c'4 |
    \once \override NoteHead #'transparent = ##t c'1 |
    b\breve |
  }
}

discantusLyrics = \lyricmode {
  Ju -- bi -- |
  la -- te De -- |
  o, om --
  nis ter -- |
  ra, __ om- |
  "..." |
  -us. |
}

altusNotes = {
  \transpose c' c'' {
    \clef "treble"
    r2 g2. e4 fis g | % two bars
    a2 g4 e |
    fis g4.( fis16 e fis4) |
    g1 |
    \once \override NoteHead #'transparent = ##t g1 |
    g\breve |
  }
}

altusLyrics = \lyricmode {
  Ju -- bi -- la -- te | % two bars
  De -- o, om -- |
  nis ter -- ra, |
  "..." |
  -us. |
}

tenorNotes = {
  \transpose c' c' {
    \clef "treble_8"
    R1 |
    R1 |
    R1 |
    r2 d'2. d'4 b e' | % two bars
    \once \override NoteHead #'transparent = ##t e'1 |
    d'\breve |
  }
}

tenorLyrics = \lyricmode {
  Ju -- bi -- la -- te | % two bars
  "..." |
  -us. 
}

bassusNotes = {
  \transpose c' c' {
    \clef "bass"
    R1 |
    R1 |
    R1 |
    R1 |
    g2. e4 |
    \once \override NoteHead #'transparent = ##t e1 |
    g\breve |
  }
}

bassusLyrics = \lyricmode {
  Ju -- bi- |
  "..." |
  -us. 
}

incipitDiscantus = \markup{
	\score{
		{
		\set Staff.instrumentName="Discantus "
		\override NoteHead   #'style = #'neomensural
		\override Rest #'style = #'neomensural
		\override Staff.TimeSignature #'style = #'neomensural
		\cadenzaOn 
		\clef "neomensural-c1"
		\key f \major
		\time 2/2
	  	c''1._"IV-" s2  %two bars
	  	\skip 1*8 % eight bars
    	}
	\layout {
		\context {\Voice
			\remove Ligature_bracket_engraver
			\consists Mensural_ligature_engraver
		}
		line-width=4.5\cm 
	}
	}
}

incipitAltus = \markup{
	\score{
		{ 
		\set Staff.instrumentName="Altus "
		\override NoteHead   #'style = #'neomensural
		\override Rest #'style = #'neomensural
		\override Staff.TimeSignature #'style = #'neomensural
		\cadenzaOn 
		\clef "neomensural-c3"
		\key f \major
		\time 2/2
	  	r1        % one bar
        f'1._"IV-" s2   % two bars
        \skip 1*7 % seven bars
		}
	\layout {
		\context {\Voice
			\remove Ligature_bracket_engraver
			\consists Mensural_ligature_engraver
		}
		line-width=4.5\cm 
	}
	}
}

incipitTenor = \markup{
    \score{ {
    \set Staff.instrumentName = "Tenor  "
    \override NoteHead   #'style = #'neomensural
	\override Rest #'style = #'neomensural
	\override Staff.TimeSignature #'style = #'neomensural
	\cadenzaOn 
	\clef "neomensural-c4"
	\key f \major
	\time 2/2
    r\longa   % four bars
    r\breve   % two bars
    r1        % one bar
    c'1._"IV-" s2   % two bars
    \skip 1   % one bar
    }
    \layout {
		\context {\Voice
			\remove Ligature_bracket_engraver
			\consists Mensural_ligature_engraver
		}
		line-width=4.5\cm 
}
}
}

incipitBassus = \markup{
    \score{ {
    \set Staff.instrumentName = "Bassus  "
    \override NoteHead   #'style = #'neomensural
	\override Rest #'style = #'neomensural
	\override Staff.TimeSignature #'style = #'neomensural
	\cadenzaOn 
	\clef "bass"
	\key f \major
	\time 2/2
    % incipit
    r\maxima  % eight bars
    f1._"IV-" s2    % two bars
    }
    \layout {
		\context {\Voice
			\remove Ligature_bracket_engraver
			\consists Mensural_ligature_engraver
		}
		line-width=4.5\cm 
            }
     }
}

%StaffGroup is used instead of ChoirStaff to get bar lines between systems
\score {
  <<
  \new StaffGroup = choirStaff <<
    \new Voice =
      "discantusNotes" << \global 
      \set Staff.instrumentName=\incipitDiscantus   
      \discantusNotes >>
    \new Lyrics =
      "discantusLyrics" \lyricsto discantusNotes { \discantusLyrics }
      
    \new Voice =
      "altusNotes" << \global 
      \set Staff.instrumentName=\incipitAltus 
      \altusNotes >>
    \new Lyrics =
      "altusLyrics" \lyricsto altusNotes { \altusLyrics }
     
    \new Voice =
      "tenorNotes" << \global 
      \set Staff.instrumentName=\incipitTenor 
      \tenorNotes >>
    \new Lyrics =
      "tenorLyrics" \lyricsto tenorNotes { \tenorLyrics }
     
    \new Voice =
      "bassusNotes" << \global 
      \set Staff.instrumentName=\incipitBassus
      \bassusNotes >>
      >>
    \new Lyrics =
      "bassusLyrics" \lyricsto bassusNotes { \bassusLyrics } 
    %Keep the bass lyrics outside of the staff group to avoid bar lines
    %between the lyrics.
  >>
  
  \layout {
    \context {
      \Score

      % no bars in staves
      \override BarLine #'transparent = ##t
    }
    % the next three instructions keep the lyrics between the barlines
	\context { \Lyrics 
	   \consists "Bar_engraver" 
	   \override BarLine #'transparent = ##t } 
	\context { \StaffGroup \consists "Separating_line_group_engraver" }
    \context {
      \Voice

      % no slurs
      \override Slur #'transparent = ##t

      % Comment in the below "\remove" command to allow line
      % breaking also at those barlines where a note overlaps
      % into the next bar.  The command is commented out in this
      % short example score, but especially for large scores, you
      % will typically yield better line breaking and thus improve
      % overall spacing if you comment in the following command.
      %\remove "Forbid_line_break_engraver"
    }
    	indent=5\cm
  }
}

[image of music]

using-the--tweak-command-to-tweak-individual-grobs.ly

With the weak command, you can tune every grob directly. Here are some examples of available tweaks.

{
  \set fingeringOrientations = #'(right)
  <
    \tweak #'font-size #3  c
    \tweak #'color #red  d-\tweak #'font-size #8 -4
    \tweak #'style #'cross  g
    \tweak #'duration-log #1  a
  >4
}

[image of music]

vertically-aligning-ossias-and-lyrics.ly

This snippet shows of to use the alignBelowContext and alignAboveContext properties, which may be needed for text elements (e.g. lyrics) positioning, but also for musical contents such as ossias.

\paper {
  ragged-right = ##t
}

\relative <<
  \new Staff = "1" { c4 c s2 }
  \new Staff = "2" { c4  c s2 }
  \new Staff = "3" { c4  c s2 }
  { \skip 2
    <<
      \lyrics {
	\set alignBelowContext = #"1"
	below8 first staff
      }
      \new Staff {
	\set Staff.alignAboveContext = #"3"
	\times 4/6 {
	  \override TextScript #'padding = #3
	  c8^"this" d_"staff" e^"above" d_"last" e^"staff" f
	}
      }
    >> }
>>

[image of music]

vertically-centered-dynamics-and-textscripts.ly

By setting the Y-extent property to a fixed value (here -1.5 . 1.5), we force LilyPond to align every elements of the DynamicLineSpanner (text elements and dynamics) to a common reference point, regardless to the actual extent of these objects. This way, every element will be vertically centered, for a nicer output (you can compare the first and the second line in this example; the trick is only applied on the second line).

The same idea is used to align the text scripts along their baseline.

\paper { indent = 0 line-width = 5\in }

music = \relative c''
{
   c2\p^\markup { "gorgeous" } c\f^\markup { "fantastic" }
   c4\p c \f \> c c \! \p
}

\score
{
   {
       \music \break

       \override DynamicLineSpanner #'staff-padding = #2.0
       \override DynamicLineSpanner #'Y-extent = #'(-1.5 . 1.5)
       \override TextScript #'Y-extent = #'(-1.5 . 1.5)
       \music
   }
}

[image of music]



Next: , Previous: Contexts and engravers, Up: Top

This page is for LilyPond-2.11.40 (development-branch).

Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.

Your suggestions for the documentation are welcome.