LilyPond snippets: Fretted strings

# Fretted strings

Fretted string instruments

## Adding fingerings to a score

Fingering instructions can be entered using a simple syntax.

    \relative c'' {
      c4-1 d-2 f-4 e-3
    }

## Adding fingerings to tablatures

To add fingerings to tablatures, use a combination of `\markup` and `\finger`.

    one = \markup { \finger 1 }
    two = \markup { \finger 2 }
    threeTwo = \markup {
      \override #'(baseline-skip . 2)
      \column {
        \finger 3
        \finger 2
      }
    }
    threeFour = \markup {
      \override #'(baseline-skip . 2)
      \column {
        \finger 3
        \finger 4
      }
    }

    \score {
      \new TabStaff {
        \tabFullNotation
        \stemUp
        e8\4^\one b\2 <g\3 e'\1>^>[ b\2 e\4]
        <a\3 fis'\1>^>^\threeTwo[ b\2 e\4]
      }
    }

## Adding markups in a tablature

By default markups does not show in a tablature.

To make them appear, simply use the command `\revert TabStaff.TextScript.stencil`

    %% http://lsr.di.unimi.it/LSR/Item?id=919
    % by P.P.Schneider on June 2014

    high  = { r4 r8 <g c'> q r8 r4 }

    low = { c4 r4 c8 r8 g,8 b, }

    pulse = { s8^"1" s^"&" s^"2" s^"&" s^"3" s^"&" s^"4" s^"&" }

    \score {
     \new TabStaff {
       \repeat unfold 2 << \high \\ \low \\ \pulse >>
      }
      \layout {
        \context {
          \TabStaff
          \clef moderntab
          \revert TextScript.stencil
          \override TextScript.font-series = #'bold
          \override TextScript.font-size = #-2
          \override TextScript.color = #red

        }
        \context {
          \Score
          proportionalNotationDuration = #(ly:make-moment 1/8)
        }
      }
    }

## Allowing fingerings to be printed inside the staff

By default, vertically oriented fingerings are positioned outside the staff; that behavior, however, may be disabled. Attention needs to be paid to situations where fingerings and stems are in the same direction: by default, fingerings will avoid only beamed stems. That setting can be changed to avoid no stems or all stems; the following example demonstrates these two options, as well as how to go back to the default behavior.

    \relative c' {
      <c-1 e-2 g-3 b-5>2
      \override Fingering.staff-padding = #'()
      <c-1 e-2 g-3 b-5>4 g'-0
      a8[-1 b]-2 g-0 r
      \override Fingering.add-stem-support = ##f
      a[-1 b]-2 g-0 r
      \override Fingering.add-stem-support = ##t
      a[-1 b]-2 g-0 r
      \override Fingering.add-stem-support = #only-if-beamed
      a[-1 b]-2 g-0 r
    }

## Barres in automatic fretboards

When automatic fretboards are used, barre indicators will be drawn whenever one finger is responsible for multiple strings.

If no finger indications are given in the chord from which the automatic fretboard is created, no barre indicators will be included, because there is no way to identify where barres should be placed.

    \new FretBoards {
      <f,-1 c-3 f-4 a-2 c'-1 f'-1>1
      <f, c f a c' f'>1
    }

## Bar chords notation for Guitar (with Text Spanner)

Here is how to print bar chords (or barre chords) or half-bar chords (just uncomment the appropriate line for to select either one).

The syntax is : `\bbarre #"fret_number" note(s)`

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %% %%%%%%%  Cut here ----- Start 'bbarred.ly'

    %% C with slash -------------------------------
    cWithSlash = \markup {
      \combine \roman C \translate #'(0.6 . -0.4) \draw-line #'(0 . 2.0)
    }
    %% Span -----------------------------------
    %% Syntax: \bbarre #"text" { notes } - text = any number of box
    bbarre =
    #(define-music-function (barre location str music) (string? ly:music?)
       (let ((elts (extract-named-music music '(NoteEvent EventChord))))
         (if (pair? elts)
             (let ((first-element (first elts))
                   (last-element (last elts)))
               (set! (ly:music-property first-element 'articulations)
                     (cons (make-music 'TextSpanEvent 'span-direction -1)
                           (ly:music-property first-element 'articulations)))
               (set! (ly:music-property last-element 'articulations)
                     (cons (make-music 'TextSpanEvent 'span-direction 1)
                           (ly:music-property last-element 'articulations))))))
       #{
           \once \override TextSpanner.font-size = #-2
           \once \override TextSpanner.font-shape = #'upright
           \once \override TextSpanner.staff-padding = #3
           \once \override TextSpanner.style = #'line
           \once \override TextSpanner.to-barline = ##f
           \once \override TextSpanner.bound-details =
                #`((left
                    (text . ,#{ \markup { \draw-line #'( 0 . -.5) } #})
                    (Y . 0)
                    (padding . 0.25)
                    (attach-dir . -2))
                   (right
                    (text . ,#{ \markup { \cWithSlash #str } #})
                    (Y . 0)
                    (padding . 0.25)
                    (attach-dir . 2)))
    %% uncomment this line for make full barred
          % \once \override TextSpanner.bound-details.left.text = \markup{"B" #str}
          $music
       #})

    %% %%%%%%%  Cut here ----- End 'bbarred.ly'
    %% Copy and change the last line for full barred. Rename in 'fbarred.ly'
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    %% Syntaxe: \bbarre #"text" { notes } - text = any number of box
    \relative c'{ \clef "G_8" \stemUp \bbarre #"III" { <f a'>16[  c' d c d8] } }

## Changing fret orientations

Fret diagrams can be oriented in three ways. By default the top string or fret in the different orientations will be aligned.

    \include "predefined-guitar-fretboards.ly"

    <<
      \chords {
        c1
        c1
        c1
      }
      \new FretBoards {
        \chordmode {
          c1
          \override FretBoard.fret-diagram-details.orientation =
            #'landscape
          c1
          \override FretBoard.fret-diagram-details.orientation =
            #'opposing-landscape
          c1
        }
      }
      \new Voice {
        c'1
        c'1
        c'
      }
    >>

## Chord glissando in tablature

Slides for chords are indicated by default in both `Staff` and `TabStaff`.

String numbers are necessary for `TabStaff` because automatic string calculations are different for chords and for single notes.

    myMusic = \relative c' {
      <c e g>1 \glissando <f a c>
    }

    \score {
      <<
        \new Staff {
          \clef "treble_8"
          \myMusic
        }
        \new TabStaff \myMusic
      >>
    }

    \score {
      <<
        \new Staff {
          \clef "treble_8"
          \myMusic
        }
        \new TabStaff \with { \override Glissando.style = #'none } {
          \myMusic
        }
      >>
    }

## ChordChanges for FretBoards

FretBoards can be set to display only when the chord changes or at the beginning of a new line.

    \include "predefined-guitar-fretboards.ly"

    myChords = \chordmode {
      c1 c1 \break
      \set chordChanges = ##t
      c1 c1 \break
      c1 c1
    }

    <<
      \new ChordNames { \myChords }
      \new FretBoards { \myChords }
      \new Staff { \myChords }
    >>

## Chords with stretched fingering for FretBoards and TabVoice

Sometimes chords with a stretched fingering are required. If not otherwise specified the context-property `maximumFretStretch` is set to `4`, though. Resulting in a warning about "No string for pitch ..." and the note is omitted. You may set `maximumFretStretch` to an approppriate value or explecitely assign string-numbers to all notes of a chord.

    %% The code below will print two warnings, which may be omitted by uncommenting:
    %#(for-each (lambda (x) (ly:expect-warning "No string for pitch")) (iota 2))

    mus = {
      <c' bes'>
      <c'\2 bes'>
      \set maximumFretStretch = 5
      <c' bes'>
      <c'\2 bes'\1>
    }

    <<
      \new FretBoards \mus
      \new TabVoice \mus
    >>

## Controlling the placement of chord fingerings

The placement of fingering numbers can be controlled precisely. For fingering orientation to apply, it must be used within a chord construct <>, even for single notes. Orientation for string numbers and right-hand fingerings may be set in a similar way.

    \relative c' {
      \set fingeringOrientations = #'(left)
      <c-1 e-3 a-5>4
      \set fingeringOrientations = #'(down)
      <c-1 e-3 a-5>4
      \set fingeringOrientations = #'(down right up)
      <c-1 e-3 a-5>4
      \set fingeringOrientations = #'(up)
      <c-1 e-3 a-5>4
      \set fingeringOrientations = #'(left)
      <c-1>2
      \set fingeringOrientations = #'(down)
      <e-3>2
      \set stringNumberOrientations = #'(up left down)
      <f\3 a\2 c\1>1
      \set strokeFingerOrientations = #'(down right up)
      <c\rightHandFinger #1 e\rightHandFinger #2 c'\rightHandFinger #4 >
    }

## Customizing fretboard fret diagrams

Fret diagram properties can be set through `'fret-diagram-details`. For FretBoard fret diagrams, overrides are applied to the `FretBoards.FretBoard` object. Like `Voice`, `FretBoards` is a bottom level context, therefore can be omitted in property overrides.

    \include "predefined-guitar-fretboards.ly"
    \storePredefinedDiagram #default-fret-table \chordmode { c' }
                            #guitar-tuning
                            #"x;1-1-(;3-2;3-3;3-4;1-1-);"

    % shorthand
    oo = #(define-music-function
           (grob-path value)
           (list? scheme?)
           #{ \once \override $grob-path = #value #})

    <<
      \new ChordNames {
        \chordmode { c1 | c | c | d }
      }
      \new FretBoards {
        % Set global properties of fret diagram
        \override FretBoards.FretBoard.size = #'1.2
        \override FretBoard.fret-diagram-details.finger-code = #'in-dot
        \override FretBoard.fret-diagram-details.dot-color = #'white
        \chordmode {
          c
          \oo FretBoard.size #'1.0
          \oo FretBoard.fret-diagram-details.barre-type #'straight
          \oo FretBoard.fret-diagram-details.dot-color #'black
          \oo FretBoard.fret-diagram-details.finger-code #'below-string
          c'
          \oo FretBoard.fret-diagram-details.barre-type #'none
          \oo FretBoard.fret-diagram-details.number-type #'arabic
          \oo FretBoard.fret-diagram-details.orientation #'landscape
          \oo FretBoard.fret-diagram-details.mute-string #"M"
          \oo FretBoard.fret-diagram-details.label-dir #LEFT
          \oo FretBoard.fret-diagram-details.dot-color #'black
          c'
          \oo FretBoard.fret-diagram-details.finger-code #'below-string
          \oo FretBoard.fret-diagram-details.dot-radius #0.35
          \oo FretBoard.fret-diagram-details.dot-position #0.5
          \oo FretBoard.fret-diagram-details.fret-count #3
          d
        }
      }
      \new Voice {
        c'1 | c' | c' | d'
      }
    >>

## Customizing markup fret diagrams

Fret diagram properties can be set through `'fret-diagram-details`. For markup fret diagrams, overrides can be applied to the `Voice.TextScript` object or directly to the markup.

    <<
      \chords { c1 | c | c | d }

      \new Voice = "mel" {
        \textLengthOn
        % Set global properties of fret diagram
        \override TextScript.size = #'1.2
        \override TextScript.fret-diagram-details.finger-code = #'in-dot
        \override TextScript.fret-diagram-details.dot-color = #'white

        %% C major for guitar, no barre, using defaults
           % terse style
        c'1^\markup { \fret-diagram-terse "x;3-3;2-2;o;1-1;o;" }

        %% C major for guitar, barred on third fret
           % verbose style
           % size 1.0
           % roman fret label, finger labels below string, straight barre
        c'1^\markup {
          % standard size
          \override #'(size . 1.0) {
            \override #'(fret-diagram-details . (
                         (number-type . roman-lower)
                         (finger-code . in-dot)
                         (barre-type . straight))) {
              \fret-diagram-verbose #'((mute 6)
                                       (place-fret 5 3 1)
                                       (place-fret 4 5 2)
                                       (place-fret 3 5 3)
                                       (place-fret 2 5 4)
                                       (place-fret 1 3 1)
                                       (barre 5 1 3))
            }
          }
        }

        %% C major for guitar, barred on third fret
           % verbose style
           % landscape orientation, arabic numbers, M for mute string
           % no barre, fret label down or left, small mute label font
        c'1^\markup {
          \override #'(fret-diagram-details . (
                       (finger-code . below-string)
                       (number-type . arabic)
                       (label-dir . -1)
                       (mute-string . "M")
                       (orientation . landscape)
                       (barre-type . none)
                       (xo-font-magnification . 0.4)
                       (xo-padding . 0.3))) {
            \fret-diagram-verbose #'((mute 6)
                                     (place-fret 5 3 1)
                                     (place-fret 4 5 2)
                                     (place-fret 3 5 3)
                                     (place-fret 2 5 4)
                                     (place-fret 1 3 1)
                                     (barre 5 1 3))
          }
        }

        %% simple D chord
           % terse style
           % larger dots, centered dots, fewer frets
           % label below string
        d'1^\markup {
          \override #'(fret-diagram-details . (
                       (finger-code . below-string)
                       (dot-radius . 0.35)
                       (dot-position . 0.5)
                       (fret-count . 3))) {
            \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"
          }
        }
      }
    >>

## Defining predefined fretboards for other instruments

Predefined fret diagrams can be added for new instruments in addition to the standards used for guitar. This file shows how this is done by defining a new string-tuning and a few predefined fretboards for the Venezuelan cuatro.

This file also shows how fingerings can be included in the chords used as reference points for the chord lookup, and displayed in the fret diagram and the `TabStaff`, but not the music.

These fretboards are not transposable because they contain string information. This is planned to be corrected in the future.

    % add FretBoards for the Cuatro
    %   Note: This section could be put into a separate file
    %      predefined-cuatro-fretboards.ly
    %      and \included into each of your compositions

    cuatroTuning = #`(,(ly:make-pitch 0 6 0)
                      ,(ly:make-pitch 1 3 SHARP)
    		  ,(ly:make-pitch 1 1 0)
    		  ,(ly:make-pitch 0 5 0))

    dSix = { <a\4 b\1 d\3 fis\2> }
    dMajor = { <a\4 d\1 d\3 fis \2> }
    aMajSeven = { <a\4 cis\1 e\3 g\2> }
    dMajSeven = { <a\4 c\1 d\3 fis\2> }
    gMajor = { <b\4 b\1 d\3 g\2> }

    \storePredefinedDiagram #default-fret-table \dSix
                            #cuatroTuning
                            #"o;o;o;o;"
    \storePredefinedDiagram #default-fret-table \dMajor
                            #cuatroTuning
                            #"o;o;o;3-3;"
    \storePredefinedDiagram #default-fret-table \aMajSeven
                            #cuatroTuning
                            #"o;2-2;1-1;2-3;"
    \storePredefinedDiagram #default-fret-table \dMajSeven
                            #cuatroTuning
                            #"o;o;o;1-1;"
    \storePredefinedDiagram #default-fret-table \gMajor
                            #cuatroTuning
                            #"2-2;o;1-1;o;"

    % end of potential include file /predefined-cuatro-fretboards.ly

    #(set-global-staff-size 16)

    primerosNames = \chordmode {
      d:6 d a:maj7 d:maj7
      g
    }
    primeros = {
      \dSix \dMajor \aMajSeven \dMajSeven
      \gMajor
    }

    \score {
      <<
        \new ChordNames {
          \set chordChanges = ##t
          \primerosNames
        }

        \new Staff {
          \new Voice \with {
            \remove "New_fingering_engraver"
          }
          \relative c'' {
            \primeros
          }
        }

        \new FretBoards {
          \set Staff.stringTunings = #cuatroTuning
    %      \override FretBoard
    %        #'(fret-diagram-details string-count) = 4
          \override FretBoard.fret-diagram-details.finger-code = #'in-dot
          \primeros
        }

        \new TabStaff \relative c'' {
          \set TabStaff.stringTunings = #cuatroTuning
          \primeros
        }

      >>

      \layout {
        \context {
          \Score
          \override SpacingSpanner.base-shortest-duration =
            #(ly:make-moment 1 16)
        }
      }
      \midi { }
    }

## Faking a hammer in tablatures

A hammer in tablature can be faked with slurs.

    \score {
      \new TabStaff {
        \relative c'' {
          \tabFullNotation
          c4( d) d( d)
          d2( c)
        }
      }
    }

## Fingerings, string indications, and right-hand fingerings

This example combines left-hand fingering, string indications, and right-hand fingering.

    #(define RH rightHandFinger)

    \relative c {
      \clef "treble_8"
      <c-3\5\RH #1 >4
      <e-2\4\RH #2 >4
      <g-0\3\RH #3 >4
      <c-1\2\RH #4 >4
    }

## Flamenco notation

For flamenco guitar, special notation is used:

- a golpe symbol to indicate a slap on the guitar body with the nail of the ring finger
- an arrow to indicate (the direction of) strokes
- different letters for fingering (“p”: thumb, “i”: index finger, “m”: middle finger, “a”: ring finger and “x”: little finger)
- 3- and 4-finger rasgueados; stroke upwards with all fingers, ending with an up- and down using the index finger
- abanicos: strokes (in tuples) with thumb (down), little and index finger (both up). There’s also an abanico 2 where middle and ring finger are used instead of the little finger.
- alza pua: fast playing with the thumb

Most figures use arrows in combination with fingering; with abanicos and rasgueados, noteheads are printed only for the first chord.

This snippet contains some header-like code that can be copied as ‘`flamenco.ly`’ and included in source files.

    %%%%%%%  Cut here ----- Start 'flamenco.ly'

    % Text indicators :
    abanico = ^\markup\small { \italic Abanico }
    rasgueado = ^\markup\small { \italic Ras. }
    alzapua = ^\markup\small { \italic Alzapua }

    % Finger stroke symbols :
    strokeUp = \markup\combine\override #'(thickness . 1.3) \draw-line #'(0 . 2)\raise #2 \arrow-head #Y #UP ##f
    strokeDown = \markup\combine\arrow-head #Y #DOWN ##f \override #'(thickness . 1.3) \draw-line #'(0 . 2)

    % Golpe symbol :
    golpe = \markup {
      \filled-box #'(0 . 1) #'(0 . 1) #0
      \hspace #-1.6
      \with-color #white
      \filled-box #'(0.15 . 0.85) #'(0.15 . 0.85) #0
    }

    % Strokes, fingers and golpe command :
    RHp = \rightHandFinger #1
    RHi = \rightHandFinger #2
    RHm = \rightHandFinger #3
    RHa = \rightHandFinger #4
    RHx = \rightHandFinger #5
    RHu = \rightHandFinger \strokeUp
    RHd = \rightHandFinger \strokeDown
    RHg = \rightHandFinger \golpe

    % Just handy :)
    tupletOff = {
      \once \omit TupletNumber
      \once \omit TupletBracket
    }

    tupletsOff = {
      \omit TupletNumber
      \override TupletBracket.bracket-visibility = #'if-no-beam
    }

    tupletsOn = {
      \override TupletBracket.bracket-visibility = #'default
      \undo \omit TupletNumber
    }

    headsOff = {
      \hide TabNoteHead
      \hide NoteHead
      \override NoteHead.no-ledgers = ##t
    }

    headsOn = {
      \override TabNoteHead.transparent = ##f
      \override NoteHead.transparent = ##f
      \override NoteHead.no-ledgers = ##f
    }

    %%%%%%%  Cut here ----- End 'flamenco.ly'
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    part = \relative c' {
      \set strokeFingerOrientations = #'(up)
      \key a\major
      <a, e' a cis e\RHu\RHi>8
      <a e' a cis e\RHd\RHi>8
      r4
      r2^\markup\golpe
      <a e' a cis e\RHu\RHi>8
      <a e' a cis e\RHd\RHi>8
      <a e' a cis e\RHu\RHi\RHg>8
      <a e' a cis e\RHd\RHi>8
      r2
      <a e' a cis e\RHu\RHa>16\rasgueado
      \headsOff
      <a e' a cis e\RHu\RHm>
      <a e' a cis e\RHu\RHi>
      <a e' a cis e\RHd\RHi>~
      \headsOn
      <a e' a cis e>2
      r4
      \tupletOff
      \tuplet 5/4 {
        <a e' a cis e\RHu\RHx>16\rasgueado
        \headsOff
        <a e' a cis e\RHu\RHa>
        <a e' a cis e\RHu\RHm>
        <a e' a cis e\RHu\RHi>
        <a e' a cis e\RHd\RHi>~
        \headsOn
      }
      <a e' a cis e>2
      r4
      \tupletsOff
      \tuplet 3/2 {
        <a e' a cis e\RHd\RHp>8\abanico
        \headsOff
        <a e' a cis e\RHu\RHx>
        <a e' a cis e\RHu\RHi>
        \headsOn
      }
      \tuplet 3/2 {
        <a e' a cis e\RHd\RHp>8
        \headsOff
        <a e' a cis e\RHu\RHx>
        <a e' a cis e\RHu\RHi>
        \headsOn
      }
      \tuplet 3/2 {
        <a e' a cis e\RHd\RHp>8
        \headsOff
        <a e' a cis e\RHu\RHx>
        <a e' a cis e\RHu\RHi>
        \headsOn
      }
      \tuplet 3/2 {
        <a e' a cis e\RHd\RHp>8
        \headsOff
        <a e' a cis e\RHu\RHx>
        <a e' a cis e\RHu\RHi>
        \headsOn
      }
      \tupletsOff
      \override Beam.positions = #'(2 . 2)
      \tuplet 3/2 {
        a8\RHp\alzapua
        <e' a\RHu\RHg>
        <e a\RHd>
      }
      \tuplet 3/2 {
        a,8\RHp
        <e' a\RHu\RHg>
        <e a\RHd>
      }
      \tuplet 3/2 {
        a,8\RHp
        <e' a\RHu\RHg>
        <e a\RHd>
      }
      \tuplet 3/2 {
        a,8\RHp
        <e' a\RHu\RHg>
        <e a\RHd>
      }
      \tupletsOn
      <a, e' a\RHu\RHm>1
      \bar "|."
    }

    \score {
      \new StaffGroup <<
        \context Staff = "part" <<
          \clef "G_8"
          {
            \part
          }
        >>
        \context TabStaff {
          \part
        }
      >>
      \layout {
        ragged-right = ##t
      }
    }

## Fret diagrams explained and developed

This snippet shows many possibilities for obtaining and tweaking fret diagrams.

    <<
      \chords {
        a2 a
        \repeat unfold 3 {
          c c c d d
        }
      }

      \new Voice = "mel" {
        \textLengthOn
        % Set global properties of fret diagram
        \override TextScript.size = #1.2
        \override TextScript.fret-diagram-details.finger-code = #'below-string
        \override TextScript.fret-diagram-details.dot-color = #'black

        %% A chord for ukulele
        a'2^\markup {
          \override #'(fret-diagram-details . (
                       (string-count . 4)
                       (dot-color . white)
                       (finger-code . in-dot))) {
            \fret-diagram "4-2-2;3-1-1;2-o;1-o;"
          }
        }

        %% A chord for ukulele, with formatting defined in definition string
        %  1.2 * size, 4 strings, 4 frets, fingerings below string
        %  dot radius .35 of fret spacing, dot position 0.55 of fret spacing
        a'2^\markup {
          \override #'(fret-diagram-details . (
                       (dot-color . white)
                       (open-string . "o"))) {
            \fret-diagram "s:1.2;w:4;h:3;f:2;d:0.35;p:0.55;4-2-2;3-1-1;2-o;1-o;"
          }
        }

          %% These chords will be in normal orientation

        %% C major for guitar, barred on third fret
        %  verbose style
        %  roman fret label, finger labels below string, straight barre
        c'2^\markup {
          % 110% of default size
          \override #'(size . 1.1) {
            \override #'(fret-diagram-details . (
                         (number-type . roman-lower)
                         (finger-code . below-string)
                         (barre-type . straight))) {
              \fret-diagram-verbose #'((mute 6)
                                       (place-fret 5 3 1)
                                       (place-fret 4 5 2)
                                       (place-fret 3 5 3)
                                       (place-fret 2 5 4)
                                       (place-fret 1 3 1)
                                       (barre 5 1 3))
            }
          }
        }

        %% C major for guitar, barred on third fret
        %% Double barre used to test barre function
        %  verbose style
        c'2^\markup {
          % 110% of default size
          \override #'(size . 1.1) {
            \override #'(fret-diagram-details . (
                         (number-type . arabic)
                         (dot-label-font-mag . 0.9)
                         (finger-code . in-dot)
                         (fret-label-font-mag . 0.6)
                         (fret-label-vertical-offset . 0)
                         (label-dir . -1)
                         (mute-string . "M")
                         (xo-font-magnification . 0.4)
                         (xo-padding . 0.3))) {
              \fret-diagram-verbose #'((mute 6)
                                       (place-fret 5 3 1)
                                       (place-fret 4 5 2)
                                       (place-fret 3 5 3)
                                       (place-fret 2 5 4)
                                       (place-fret 1 3 1)
                                       (barre 4 2 5)
                                       (barre 5 1 3))
            }
          }
        }

        %% C major for guitar, with capo on third fret
        %  verbose style
        c'2^\markup {
          % 110% of default size
          \override #'(size . 1.1) {
            \override #'(fret-diagram-details . (
                         (number-type . roman-upper)
                         (dot-label-font-mag . 0.9)
                         (finger-code . none)
                         (fret-label-vertical-offset . 0.5)
                         (xo-font-magnification . 0.4)
                         (xo-padding . 0.3))) {
              \fret-diagram-verbose #'((mute 6)
                                       (capo 3)
                                       (open 5)
                                       (place-fret 4 5 1)
                                       (place-fret 3 5 2)
                                       (place-fret 2 5 3)
                                       (open 1))
            }
          }
        }

        %% simple D chord
        d'2^\markup {
          \override #'(fret-diagram-details . (
                       (finger-code . below-string)
                       (dot-radius . 0.35)
                       (string-thickness-factor . 0.3)
                       (dot-position . 0.5)
                       (fret-count . 3))) {
            \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"
          }
        }

        %% simple D chord, large top fret thickness
        d'2^\markup  {
          \override #'(fret-diagram-details . (
                       (finger-code . below-string)
                       (dot-radius . 0.35)
                       (dot-position . 0.5)
                       (top-fret-thickness . 7)
                       (fret-count . 3))) {
            \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"
          }
        }

          % These chords will be in landscape orientation
        \override TextScript.fret-diagram-details.orientation = #'landscape

        %% C major for guitar, barred on third fret
        %  verbose style
        %  roman fret label, finger labels below string, straight barre
        c'2^\markup {
          % 110% of default size
          \override #'(size . 1.1) {
            \override #'(fret-diagram-details . (
                         (number-type . roman-lower)
                         (finger-code . below-string)
                         (barre-type . straight))) {
              \fret-diagram-verbose #'((mute 6)
                                       (place-fret 5 3 1)
                                       (place-fret 4 5 2)
                                       (place-fret 3 5 3)
                                       (place-fret 2 5 4)
                                       (place-fret 1 3 1)
                                       (barre 5 1 3))
            }
          }
        }

        %% C major for guitar, barred on third fret
        %% Double barre used to test barre function
        %  verbose style
        c'2^\markup {
          % 110% of default size
          \override #'(size . 1.1) {
            \override #'(fret-diagram-details . (
                         (number-type . arabic)
                         (dot-label-font-mag . 0.9)
                         (finger-code . in-dot)
                         (fret-label-font-mag . 0.6)
                         (fret-label-vertical-offset . 0)
                         (label-dir . -1)
                         (mute-string . "M")
                         (xo-font-magnification . 0.4)
                         (xo-padding . 0.3))) {
              \fret-diagram-verbose #'((mute 6)
                                       (place-fret 5 3 1)
                                       (place-fret 4 5 2)
                                       (place-fret 3 5 3)
                                       (place-fret 2 5 4)
                                       (place-fret 1 3 1)
                                       (barre 4 2 5)
                                       (barre 5 1 3))
            }
          }
        }

        %% C major for guitar, with capo on third fret
        %  verbose style
        c'2^\markup {
          % 110% of default size
          \override #'(size . 1.1) {
            \override #'(fret-diagram-details . (
                         (number-type . roman-upper)
                         (dot-label-font-mag . 0.9)
                         (finger-code . none)
                         (fret-label-vertical-offset . 0.5)
                         (xo-font-magnification . 0.4)
                         (xo-padding . 0.3))) {
              \fret-diagram-verbose #'((mute 6)
                                       (capo 3)
                                       (open 5)
                                       (place-fret 4 5 1)
                                       (place-fret 3 5 2)
                                       (place-fret 2 5 3)
                                       (open 1))
            }
          }
        }

        %% simple D chord
        d'2^\markup {
          \override #'(fret-diagram-details . (
                       (finger-code . below-string)
                       (dot-radius . 0.35)
                       (dot-position . 0.5)
                       (fret-count . 3))) {
            \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"
          }
        }

        %% simple D chord, large top fret thickness
        d'2^\markup {
          \override #'(fret-diagram-details . (
                       (finger-code . below-string)
                       (dot-radius . 0.35)
                       (dot-position . 0.5)
                       (top-fret-thickness . 7)
                       (fret-count . 3))) {
            \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"
          }
        }

          % These chords will be in opposing-landscape orientation
        \override TextScript.fret-diagram-details.orientation = #'opposing-landscape

        %% C major for guitar, barred on third fret
        %  verbose style
        %  roman fret label, finger labels below string, straight barre
        c'2^\markup {
          % 110% of default size
          \override #'(size . 1.1) {
            \override #'(fret-diagram-details . (
                         (number-type . roman-lower)
                         (finger-code . below-string)
                         (barre-type . straight))) {
              \fret-diagram-verbose #'((mute 6)
                                       (place-fret 5 3 1)
                                       (place-fret 4 5 2)
                                       (place-fret 3 5 3)
                                       (place-fret 2 5 4)
                                       (place-fret 1 3 1)
                                       (barre 5 1 3))
            }
          }
        }

        %% C major for guitar, barred on third fret
        %% Double barre used to test barre function
        %  verbose style
        c'2^\markup {
          % 110% of default size
          \override #'(size . 1.1) {
            \override #'(fret-diagram-details . (
                         (number-type . arabic)
                         (dot-label-font-mag . 0.9)
                         (finger-code . in-dot)
                         (fret-label-font-mag . 0.6)
                         (fret-label-vertical-offset . 0)
                         (label-dir . -1)
                         (mute-string . "M")
                         (xo-font-magnification . 0.4)
                         (xo-padding . 0.3))) {
              \fret-diagram-verbose #'((mute 6)
                                       (place-fret 5 3 1)
                                       (place-fret 4 5 2)
                                       (place-fret 3 5 3)
                                       (place-fret 2 5 4)
                                       (place-fret 1 3 1)
                                       (barre 4 2 5)
                                       (barre 5 1 3))
            }
          }
        }

        %% C major for guitar, with capo on third fret
        %  verbose style
        c'2^\markup {
          % 110% of default size
          \override #'(size . 1.1) {
            \override #'(fret-diagram-details . (
                         (number-type . roman-upper)
                         (dot-label-font-mag . 0.9)
                         (finger-code . none)
                         (fret-label-vertical-offset . 0.5)
                         (xo-font-magnification . 0.4)
                         (xo-padding . 0.3))) {
              \fret-diagram-verbose #'((mute 6)
                                       (capo 3)
                                       (open 5)
                                       (place-fret 4 5 1)
                                       (place-fret 3 5 2)
                                       (place-fret 2 5 3)
                                       (open 1))
            }
          }
        }

        %% simple D chord
        d'2^\markup {
          \override #'(fret-diagram-details . (
                       (finger-code . below-string)
                       (dot-radius . 0.35)
                       (dot-position . 0.5)
                       (fret-count . 3))) {
            \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"
          }
        }

        %% simple D chord, large top fret thickness
        d'2^\markup {
          \override #'(fret-diagram-details . (
                       (finger-code . below-string)
                       (dot-radius . 0.35)
                       (dot-position . 0.5)
                       (top-fret-thickness . 7)
                       (fret-count . 3))) {
            \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"
          }
        }
      }
    >>

## Fretboards alternate tables

Alternate fretboard tables can be created. These would be used in order to have alternate fretboards for a given chord.

In order to use an alternate fretboard table, the table must first be created. Fretboards are then added to the table.

The created fretboard table can be blank, or it can be copied from an existing table.

The table to be used in displaying predefined fretboards is selected by the property `\predefinedDiagramTable`.

    \include "predefined-guitar-fretboards.ly"

    % Make a blank new fretboard table
    #(define custom-fretboard-table-one
       (make-fretboard-table))

    % Make a new fretboard table as a copy of default-fret-table
    #(define custom-fretboard-table-two
       (make-fretboard-table default-fret-table))

    % Add a chord to custom-fretboard-table-one
    \storePredefinedDiagram #custom-fretboard-table-one
                            \chordmode {c}
                            #guitar-tuning
                            "3-(;3;5;5;5;3-);"

    % Add a chord to custom-fretboard-table-two
    \storePredefinedDiagram #custom-fretboard-table-two
                            \chordmode {c}
                            #guitar-tuning
                            "x;3;5;5;5;o;"

    <<
      \chords {
        c1 | d1 |
        c1 | d1 |
        c1 | d1 |
      }
      \new FretBoards {
        \chordmode {
          \set predefinedDiagramTable = #default-fret-table
          c1 | d1 |
          \set predefinedDiagramTable = #custom-fretboard-table-one
          c1 | d1 |
          \set predefinedDiagramTable = #custom-fretboard-table-two
          c1 | d1 |
        }
      }
      \new Staff {
        \clef "treble_8"
        <<
          \chordmode {
            c1 | d1 |
            c1 | d1 |
            c1 | d1 |
          }
          {
            s1_\markup "Default table" | s1 |
            s1_\markup \column {"New table" "from empty"} | s1 |
            s1_\markup \column {"New table" "from default"} | s1 |
          }
        >>
      }
    >>

## Fretted-string harmonics in tablature

Demonstrates fretted-string harmonics in tablature

    pinchedHarmonics = {
       \textSpannerDown
       \override TextSpanner.bound-details.left.text =
          \markup {\halign #-0.5 \teeny "PH" }
          \override TextSpanner.style =
             #'dashed-line
       \override TextSpanner.dash-period = #0.6
       \override TextSpanner.bound-details.right.attach-dir = #1
       \override TextSpanner.bound-details.right.text =
          \markup { \draw-line #'(0 . 1) }
       \override TextSpanner.bound-details.right.padding = #-0.5
    }

    harmonics = {
      %artificial harmonics (AH)
      \textLengthOn
      <\parenthesize b b'\harmonic>4_\markup { \teeny "AH 16" }
      <\parenthesize g g'\harmonic>4_\markup { \teeny "AH 17" }
      <\parenthesize d' d''\harmonic>2_\markup { \teeny "AH 19" }
      %pinched harmonics (PH)
      \pinchedHarmonics
      <a'\harmonic>2\startTextSpan
      <d''\harmonic>4
      <e'\harmonic>4\stopTextSpan
      %tapped harmonics (TH)
      <\parenthesize g\4 g'\harmonic>4_\markup { \teeny "TH 17" }
      <\parenthesize a\4 a'\harmonic>4_\markup { \teeny "TH 19" }
      <\parenthesize c'\3 c''\harmonic>2_\markup { \teeny "TH 17" }
      %touch harmonics (TCH)
      a4( <e''\harmonic>2. )_\markup { \teeny "TCH" }
    }

    frettedStrings = {
      %artificial harmonics (AH)
      \harmonicByFret #4 g4\3
      \harmonicByFret #5 d4\4
      \harmonicByFret #7 g2\3
      %pinched harmonics (PH)
      \harmonicByFret #7 d2\4
      \harmonicByFret #5 d4\4
      \harmonicByFret #7 a4\5
      %tapped harmonics (TH)
      \harmonicByFret #5 d4\4
      \harmonicByFret #7 d4\4
      \harmonicByFret #5 g2\3
      %touch harmonics (TCH)
      a4 \harmonicByFret #9 g2.\3
    }

    \score {
      <<
        \new Staff
        \with { \omit StringNumber } {
          \new Voice {
            \clef "treble_8"
            \harmonics
          }
        }
        \new TabStaff {
          \new TabVoice {
            \frettedStrings
          }
        }
      >>
    }

## Guitar slides

Unlike glissandos, slides may go from an imprecise point of the fretboard to a specific fret. A good way to do this is to add a hidden grace note before the note which is actually played, as demonstrated in the following example.

    %% Hide fret number: useful to draw slide into/from a casual point of
    %% the fretboard.
    hideFretNumber = {
      \once \hide TabNoteHead
      \once \hide NoteHead
      \once \hide Stem
      \once \override NoteHead.no-ledgers = ##t
      \once \override Glissando.bound-details.left.padding = #0.3
    }

    music= \relative c' {
      \grace { \hideFretNumber d8\2 \glissando s2 } g2\2
      \grace { \hideFretNumber g8\2 \glissando s2 } d2 |

      \grace { \hideFretNumber c,8 \glissando s } f4\5^\markup \tiny { Slide into }
      \grace { \hideFretNumber f8 \glissando s } a4\4
      \grace { \hideFretNumber e'8\3 \glissando s } b4\3^\markup \tiny { Slide from }
      \grace { \hideFretNumber b'8 \glissando s2 } g4 |
    }

    \score {
      <<
        \new Staff {
          \clef "G_8"
          \music
        }
        \new TabStaff {
          \music
        }
      >>
    }

## Guitar strum rhythms

For guitar music, it is possible to show strum rhythms, along with melody notes, chord names and fret diagrams.

    \include "predefined-guitar-fretboards.ly"
    <<
      \new ChordNames {
        \chordmode {
          c1 | f | g | c
        }
      }
      \new FretBoards {
        \chordmode {
          c1 | f | g | c
        }
      }
      \new Voice \with {
        \consists "Pitch_squash_engraver"
      } {
        \relative c'' {
          \improvisationOn
          c4 c8 c c4 c8 c
          f4 f8 f f4 f8 f
          g4 g8 g g4 g8 g
          c4 c8 c c4 c8 c
        }
      }
      \new Voice = "melody" {
        \relative c'' {
          c2 e4 e4
          f2. r4
          g2. a4
          e4 c2.
        }
      }
      \new Lyrics {
        \lyricsto "melody" {
          This is my song.
          I like to sing.
        }
      }
    >>

## Hammer on and pull off using chords

When using hammer-on or pull-off with chorded notes, only a single arc is drawn. However “double arcs” are possible by setting the `doubleSlurs` property to `#t`.

    \new TabStaff {
      \relative c' {
        % chord hammer-on and pull-off
        \set doubleSlurs = ##t
        <g' b>8( <a c> <g b>)
      }
    }

## Hammer on and pull off using voices

The arc of hammer-on and pull-off is upwards in voices one and three and downwards in voices two and four:

    \new TabStaff {
      \relative c' {
        << { \voiceOne g2( a) }
        \\ { \voiceTwo a,( b) }
        >> \oneVoice
      }
    }

## Hammer on and pull off

Hammer-on and pull-off can be obtained using slurs.

    \new TabStaff {
      \relative c' {
        d4( e\2)
        a( g)
      }
    }

## How to change fret diagram position

If you want to move the position of a fret diagram, for example, to avoid collision, or to place it between two notes, you have various possibilities:

1) modify #’padding or #’extra-offset values (as shown in the first snippet)

2) you can add an invisible voice and attach the fret diagrams to the invisible notes in that voice (as shown in the second example).

If you need to move the fret according with a rythmic position inside the bar (in the example, the third beat of the measure) the second example is better, because the fret is aligned with the third beat itself.

    harmonies = \chordmode
    {
      a8:13
    % THE FOLLOWING IS THE COMMAND TO MOVE THE CHORD NAME
      \once \override ChordNames.ChordName.extra-offset = #'(10 . 0)
      b8:13 s2.
    % THIS LINE IS THE SECOND METHOD
        s4 s4  b4:13
    }

    \score
    {
      <<
        \new ChordNames \harmonies
        \new Staff
        {a8^\markup { \fret-diagram  "6-x;5-0;4-2;3-0;2-0;1-2;"  }
    % THE FOLLOWING IS THE COMMAND TO MOVE THE FRET DIAGRAM
         \once \override TextScript.extra-offset = #'(10 . 0)
         b4.~^\markup { \fret-diagram  "6-x;5-2;4-4;3-2;2-2;1-4;"  } b4. a8\break
    % HERE IS THE SECOND METHOD
         <<
           { a8 b4.~ b4. a8}
           { s4 s4 s4^\markup { \fret-diagram  "6-x;5-2;4-4;3-2;2-2;1-4;"  }
           }
         >>
       }
      >>
    }

## Jazz combo template

This is quite an advanced template, for a jazz ensemble. Note that all instruments are notated in `\key c \major`. This refers to the key in concert pitch; the key will be automatically transposed if the music is within a `\transpose` section.

    \header {
      title = "Song"
      subtitle = "(tune)"
      composer = "Me"
      meter = "moderato"
      piece = "Swing"
      tagline = \markup {
        \column {
          "LilyPond example file by Amelie Zapf,"
          "Berlin 07/07/2003"
        }
      }
    }
    % To make the example display in the documentation
    \paper {
      paper-width = 130
    }
    %#(set-global-staff-size 16)
    \include "english.ly"

    %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%

    sl = {
      \override NoteHead.style = #'slash
      \hide Stem
    }
    nsl = {
      \revert NoteHead.style
      \undo \hide Stem
    }
    crOn = \override NoteHead.style = #'cross
    crOff = \revert NoteHead.style

    %% insert chord name style stuff here.

    jazzChords = { }

    %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%

    global = { \time 4/4 }

    Key = { \key c \major }

    % ############ Horns ############

    % ------ Trumpet ------
    trpt = \transpose c d \relative c'' {
      \Key
      c1 | c | c |
    }
    trpHarmony = \transpose c' d {
      \jazzChords
    }
    trumpet = {
      \global
      \clef treble
      <<
        \trpt
      >>
    }

    % ------ Alto Saxophone ------
    alto = \transpose c a \relative c' {
      \Key
      c1 | c | c |
    }
    altoHarmony = \transpose c' a {
      \jazzChords
    }
    altoSax = {
      \global
      \clef treble
      <<
        \alto
      >>
    }

    % ------ Baritone Saxophone ------
    bari = \transpose c a' \relative c {
      \Key
      c1
      c1
      \sl
      d4^"Solo" d d d
      \nsl
    }
    bariHarmony = \transpose c' a \chordmode {
      \jazzChords s1 s d2:maj e:m7
    }
    bariSax = {
      \global
      \clef treble
      <<
        \bari
      >>
    }

    % ------ Trombone ------
    tbone = \relative c {
      \Key
      c1 | c | c
    }
    tboneHarmony = \chordmode {
      \jazzChords
    }
    trombone = {
      \global
      \clef bass
      <<
        \tbone
      >>
    }

    % ############ Rhythm Section #############

    % ------ Guitar ------
    gtr = \relative c'' {
      \Key
      c1
      \sl
      b4 b b b
      \nsl
      c1
    }
    gtrHarmony = \chordmode {
      \jazzChords
      s1 c2:min7+ d2:maj9
    }
    guitar = {
      \global
      \clef treble
      <<
        \gtr
      >>
    }

    %% ------ Piano ------
    rhUpper = \relative c'' {
      \voiceOne
      \Key
      c1 | c | c
    }
    rhLower = \relative c' {
      \voiceTwo
      \Key
      e1 | e | e
    }

    lhUpper = \relative c' {
      \voiceOne
      \Key
      g1 | g | g
    }
    lhLower = \relative c {
      \voiceTwo
      \Key
      c1 | c | c
    }

    PianoRH = {
      \clef treble
      \global
      <<
        \new Voice = "one" \rhUpper
        \new Voice = "two" \rhLower
      >>
    }
    PianoLH = {
      \clef bass
      \global
      <<
        \new Voice = "one" \lhUpper
        \new Voice = "two" \lhLower
      >>
    }

    piano = {
      <<
        \new Staff = "upper" \PianoRH
        \new Staff = "lower" \PianoLH
      >>
    }

    % ------ Bass Guitar ------
    Bass = \relative c {
      \Key
      c1 | c | c
    }
    bass = {
      \global
      \clef bass
      <<
        \Bass
      >>
    }

    % ------ Drums ------
    up = \drummode {
      \voiceOne
      hh4 <hh sn> hh <hh sn>
      hh4 <hh sn> hh <hh sn>
      hh4 <hh sn> hh <hh sn>
    }
    down = \drummode {
      \voiceTwo
      bd4 s bd s
      bd4 s bd s
      bd4 s bd s
    }

    drumContents = {
      \global
      <<
        \new DrumVoice \up
        \new DrumVoice \down
      >>
    }

    %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%

    \score {
      <<
        \new StaffGroup = "horns" <<
          \new Staff = "trumpet" \with { instrumentName = "Trumpet" }
          \trumpet
          \new Staff = "altosax" \with { instrumentName = "Alto Sax" }
          \altoSax
          \new ChordNames = "barichords" \with { instrumentName = "Trumpet" }
          \bariHarmony
          \new Staff = "barisax" \with { instrumentName = "Bari Sax" }
          \bariSax
          \new Staff = "trombone" \with { instrumentName = "Trombone" }
          \trombone
        >>

        \new StaffGroup = "rhythm" <<
          \new ChordNames = "chords" \gtrHarmony
          \new Staff = "guitar" \with { instrumentName = "Guitar" }
          \guitar
          \new PianoStaff = "piano" \with {
            instrumentName = "Piano"
            midiInstrument = "acoustic grand"
          }
          \piano
          \new Staff = "bass" \with { instrumentName = "Bass" }
          \bass
          \new DrumStaff \with { instrumentName = "Drums" }
          \drumContents
        >>
      >>
      \layout {
        \context { \Staff \RemoveEmptyStaves }
        \context {
          \Score
          \override BarNumber.padding = #3
          \override RehearsalMark.padding = #2
          skipBars = ##t
        }
      }
      \midi { }
    }

## Laissez vibrer ties

Laissez vibrer ties have a fixed size. Their formatting can be tuned using `'tie-configuration`.

    \relative c' {
      <c e g>4\laissezVibrer r <c f g>\laissezVibrer r
      <c d f g>4\laissezVibrer r <c d f g>4.\laissezVibrer r8

      <c d e f>4\laissezVibrer r
      \override LaissezVibrerTieColumn.tie-configuration
         = #`((-7 . ,DOWN)
              (-5 . ,DOWN)
              (-3 . ,UP)
              (-1 . ,UP))
      <c d e f>4\laissezVibrer r
    }

## Let TabStaff print the topmost string at bottom

In tablatures usually the first string is printed topmost. If you want to have it at the bottom change the `stringOneTopmost`-context-property. For a context-wide setting this could be done in `layout` as well.

    %
    %\layout {
    %  \context {
    %    \Score
    %    stringOneTopmost = ##f
    %  }
    %  \context {
    %    \TabStaff
    %    tablatureFormat = #fret-letter-tablature-format
    %  }
    %}

    m = {
      \cadenzaOn
      e, b, e gis! b e'
      \bar "||"
    }

    <<
      \new Staff { \clef "G_8" <>_"default" \m <>_"italian (historic)"\m }
      \new TabStaff
      {
        \m
        \set Score.stringOneTopmost = ##f
        \set TabStaff.tablatureFormat = #fret-letter-tablature-format
        \m
      }
    >>

## Letter tablature formatting

Tablature can be formatted using letters instead of numbers.

    music = \relative c {
      c4 d e f
      g4 a b c
      d4 e f g
    }

    <<
      \new Staff {
        \clef "G_8"
        \music
      }
      \new TabStaff \with {
        tablatureFormat = #fret-letter-tablature-format
      }
      {
        \music
      }
    >>

## Open string harmonics in tablature

This snippet demonstrates open-string harmonics.

    openStringHarmonics = {
      \textSpannerDown
      \override TextSpanner.staff-padding = #3
      \override TextSpanner.dash-fraction = #0.3
      \override TextSpanner.dash-period = #1

      %first harmonic
      \override TextSpanner.bound-details.left.text =
        \markup\small "1st harm. "
      \harmonicByFret #12 e,2\6\startTextSpan
      \harmonicByRatio #1/2 e,\6\stopTextSpan

      %second harmonic
      \override TextSpanner.bound-details.left.text =
        \markup\small "2nd harm. "
      \harmonicByFret #7 e,\6\startTextSpan
      \harmonicByRatio #1/3 e,\6
      \harmonicByFret #19 e,\6
      \harmonicByRatio #2/3 e,\6\stopTextSpan
      %\harmonicByFret #19 < e,\6 a,\5 d\4 >
      %\harmonicByRatio #2/3 < e,\6 a,\5 d\4 >

      %third harmonic
      \override TextSpanner.bound-details.left.text =
        \markup\small "3rd harm. "
      \harmonicByFret #5 e,\6\startTextSpan
      \harmonicByRatio #1/4 e,\6
      \harmonicByFret #24 e,\6
      \harmonicByRatio #3/4 e,\6\stopTextSpan
      \break

      %fourth harmonic
      \override TextSpanner.bound-details.left.text =
        \markup\small "4th harm. "
      \harmonicByFret #4 e,\6\startTextSpan
      \harmonicByRatio #1/5 e,\6
      \harmonicByFret #9 e,\6
      \harmonicByRatio #2/5 e,\6
      \harmonicByFret #16 e,\6
      \harmonicByRatio #3/5 e,\6\stopTextSpan

      %fifth harmonic
      \override TextSpanner.bound-details.left.text =
        \markup\small "5th harm. "
      \harmonicByFret #3 e,\6\startTextSpan
      \harmonicByRatio #1/6 e,\6\stopTextSpan
      \break

      %sixth harmonic
      \override TextSpanner.bound-details.left.text =
        \markup\small "6th harm. "
      \harmonicByFret #2.7 e,\6\startTextSpan
      \harmonicByRatio #1/7 e,\6\stopTextSpan

      %seventh harmonic
      \override TextSpanner.bound-details.left.text =
        \markup\small "7th harm. "
      \harmonicByFret #2.3 e,\6\startTextSpan
      \harmonicByRatio #1/8 e,\6\stopTextSpan

      %eighth harmonic
      \override TextSpanner.bound-details.left.text =
        \markup\small "8th harm. "
      \harmonicByFret #2 e,\6\startTextSpan
      \harmonicByRatio #1/9 e,\6\stopTextSpan
    }

    \score {
      <<
        \new Staff
        \with { \omit StringNumber } {
          \new Voice {
            \clef "treble_8"
            \openStringHarmonics
          }
        }
        \new TabStaff {
          \new TabVoice {
            \openStringHarmonics
          }
        }
      >>
    }

## Placement of right-hand fingerings

It is possible to exercise greater control over the placement of right-hand fingerings by setting a specific property, as demonstrated in the following example.

    #(define RH rightHandFinger)

    \relative c {
      \clef "treble_8"

      \set strokeFingerOrientations = #'(up down)
      <c\RH #1 e\RH #2 g\RH #3 c\RH #4 >4

      \set strokeFingerOrientations = #'(up right down)
      <c\RH #1 e\RH #2 g\RH #3 c\RH #4 >4

      \set strokeFingerOrientations = #'(left)
      <c\RH #1 e\RH #2 g\RH #3 c\RH #4 >2

      \set strokeFingerOrientations = #'(right)
      c\RH #1
    }

## Polyphony in tablature

Polyphony is created the same way in a `TabStaff` as in a regular staff.

    upper = \relative c' {
      \time 12/8
      \key e \minor
      \voiceOne
      r4. r8 e, fis g16 b g e e' b c b a g fis e
    }

    lower = \relative c {
      \key e \minor
      \voiceTwo
      r16 e d c b a g4 fis8 e fis g a b c
    }

    \score {
      <<
        \new StaffGroup = "tab with traditional" <<
          \new Staff = "guitar traditional" <<
            \clef "treble_8"
            \new Voice = "upper" \upper
            \new Voice = "lower" \lower
          >>
          \new TabStaff = "guitar tab" <<
            \new TabVoice = "upper" \upper
            \new TabVoice = "lower" \lower
          >>
        >>
      >>
    }

## Slides in tablature

Slides can be typeset in both `Staff` and `TabStaff` contexts:

    slides = {
      c'8\3(\glissando d'8\3)
      c'8\3\glissando d'8\3
      \hideNotes
      \grace { g16\glissando }
      \unHideNotes
      c'4\3
      \afterGrace d'4\3\glissando {
      \stemDown \hideNotes
      g16 }
      \unHideNotes
    }

    \score {
      <<
        \new Staff { \clef "treble_8" \slides }
        \new TabStaff { \slides }
      >>
      \layout {
        \context {
          \Score
          \override Glissando.minimum-length = #4
          \override Glissando.springs-and-rods =
                              #ly:spanner::set-spacing-rods
          \override Glissando.thickness = #2
          \omit StringNumber
          % or:
          %\override StringNumber.stencil = ##f
        }
      }
    }

## Stem and beam behavior in tablature

The direction of stems is controlled the same way in tablature as in traditional notation. Beams can be made horizontal, as shown in this example.

    \new TabStaff {
      \relative c {
        \tabFullNotation
        g16 b d g b d g b
        \stemDown
        \override Beam.concaveness = #10000
        g,,16 b d g b d g b
      }
    }

## String number extender lines

Make an extender line for string number indications, showing that a series of notes is supposed to be played all on the same string.

    stringNumberSpanner =
      #(define-music-function (StringNumber) (string?)
        #{
          \override TextSpanner.style = #'solid
          \override TextSpanner.font-size = #-5
          \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
          \override TextSpanner.bound-details.left.text =
            \markup { \circle \number $StringNumber }
        #})

    \relative c {
      \clef "treble_8"
      \stringNumberSpanner "5"
      \textSpannerDown
      a8\startTextSpan
      b c d e f\stopTextSpan
      \stringNumberSpanner "4"
      g\startTextSpan a
      bes4 a g2\stopTextSpan
    }

#### LilyPond — Snippets v2.22.2 (stable-branch).