Flaming Hakama Design Consultancy

Dressed to Kill: Attire for Martial Arts

Brackets and Parenthesis in Lilypond

Bracketing Content

Here’s one approach:

\version "2.18.2"

%% Bracket defs:
LBracket =
  \markup
  \with-dimensions #'(0 . 0) #'(0 . 0)
  \path #0.15
    #'((moveto  -1  0)
       (rlineto -1  0)
       (rlineto  0 -1.5))
 
RBracket =
  \markup
  \scale #'(-1 . 1)
  \LBracket

startBracket =
  -\tweak dash-period 0
  -\tweak bound-details
            #`((left
                (text . ,LBracket)
                (Y . 1.5))
               (right
                (text . ,RBracket)
                (Y . 1.5))) 
   \startTextSpan

stopBracket = \stopTextSpan

Another approach


doubleSlur = { \once \set doubleSlurs = ##t }

introStart = \markup {
  \raise #1
  \path #0.1 #'((moveto -1 0)(rlineto 0 1)(rlineto 1 0))
}

% Accompaniment introduction end mark
introEnd = \markup {
  \raise #1
  \path #0.1 #'((moveto 1.5 1)(rlineto 1 0)(rlineto 0 -1))
}

% A mark that starts a little farther out (to the right)
introEndLong = \markup {
  \raise #1
  \path #0.1 #'((moveto 4 1)(rlineto 1 0)(rlineto 0 -1))
}

%  Attach them to the note/chord you want, like (from "The Spirit of God"):

\relative c' {
  \key bes \major
  \partial 4 4^\introStart |
  2 4  |
  2 4  |
  \doubleSlur 2 ( 4 )  |
  \doubleSlur 4. ( 8 )^\introEnd 4 \bar "" \break
}   

Chords in Parenthesis

An example based on this LSR snippet:

startParenthesis = {
  \once \override ParenthesesItem.stencils = #(lambda (grob)
        (let ((par-list (parentheses-item::calc-parenthesis-stencils grob)))
          (list (car par-list) point-stencil )))
}

endParenthesis = {
  \once \override ParenthesesItem.stencils = #(lambda (grob)
        (let ((par-list (parentheses-item::calc-parenthesis-stencils grob)))
          (list point-stencil (cadr par-list))))
}

\new ChordNames  {
  \override ParenthesesItem.font-size = #5
  \startParenthesis \parenthesize 
  d' e' f'
  \endParenthesis \parenthesize g'
}

several years ago, someone posted a solution in the German lilypond forum.

This can be adjusted to draw parentheses only on the left or right
side:

%
-------------------------------------------------------------------------------------
#(define (parenthesis-ignatzek-chord-names in-pitches bass inversion
context)
(markup #:line ( "(" (ignatzek-chord-names in-pitches bass inversion
context) ")" )))

#(define (left-parenthesis-ignatzek-chord-names in-pitches bass inversion
context)
(markup #:line ( "(" (ignatzek-chord-names in-pitches bass inversion
context) )))

#(define (right-parenthesis-ignatzek-chord-names in-pitches bass inversion
context)
(markup #:line ( (ignatzek-chord-names in-pitches bass inversion context)
")" )))

paren = #(define-music-function (parser location griffe) (ly:music?)
#{
        \set chordNameFunction = #parenthesis-ignatzek-chord-names
        $griffe
        \set chordNameFunction = #ignatzek-chord-names
#})

leftParen = #(define-music-function (parser location griffe) (ly:music?)
#{
        \set chordNameFunction = #left-parenthesis-ignatzek-chord-names
        $griffe
        \set chordNameFunction = #ignatzek-chord-names
#})

rightParen = #(define-music-function (parser location griffe) (ly:music?)
#{
        \set chordNameFunction = #right-parenthesis-ignatzek-chord-names
        $griffe
        \set chordNameFunction = #ignatzek-chord-names
#})

\new ChordNames \chordmode {
  \paren f1:maj7   \leftParen g2:m7  \rightParen c2:7
}
%