Jump to content

Aligning and centering instrument names: Difference between revisions

From LilyPond wiki
m Replace version="2.24.0" with version="2.24" now that the LilyWiki extension supports auto-selecting the latest release in a stable series
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
The horizontal alignment of instrument names is tweaked by changing the <code>Staff.InstrumentName.self-alignment-X</code> property. The <code>\layout</code> variables <code>indent</code> and <code>short-indent</code> define the space in which the instrument names are aligned before the first and the following systems, respectively.
The horizontal alignment of instrument names is tweaked by changing the <code>self-alignment-X</code> property of the <code>InstrumentName</code> grob (usually in the <code>Staff</code> context). The <code>\layout</code> variables <code>indent</code> and <code>short-indent</code> define the space in which the instrument names are aligned before the first and the following systems, respectively.


<lilypond version="2.24" full>
<lilypond version="2.24">
\paper { left-margin = 3\cm tagline = ##f }
\paper {
  left-margin = 3\cm
}


\score {
\new StaffGroup <<
   \new StaffGroup <<
  \new Staff \with {
    \override InstrumentName.self-alignment-X = #LEFT
    instrumentName = \markup \left-column { "Left aligned"
                                            "instrument name" }
    shortInstrumentName = "Left"
   } {
    c''1 \break c''1
  }


    \new Staff \with {
  \new Staff \with {
      \override InstrumentName.self-alignment-X = #LEFT
    \override InstrumentName.self-alignment-X = #CENTER
      instrumentName = \markup \left-column {
    instrumentName = \markup \center-column { Centered
        "Left aligned"
                                              "instrument name" }
        "instrument name"
    shortInstrumentName = "Centered"
        }
  } {
        shortInstrumentName = "Left"
    g'1 g'1
      }
  }


      {  c''1 \break c''1 }
  \new Staff \with {
 
     \override InstrumentName.self-alignment-X = #RIGHT
    \new Staff \with {
    instrumentName = \markup \right-column { "Right aligned"
      \override InstrumentName.self-alignment-X = #CENTER
                                            "instrument name" }
      instrumentName = \markup \center-column {
    shortInstrumentName = "Right"
        Centered
  } {
        "instrument name"
     e'1 e'1
        }
  }
      shortInstrumentName = "Centered"
>>
    }
 
    { g'1 g'1}
 
     \new Staff \with {
      \override InstrumentName.self-alignment-X = #RIGHT
      instrumentName = \markup \right-column {
        "Right aligned"
        "instrument name"
      }
      shortInstrumentName = "Right"
    }
 
     { e'1 e'1 }
 
  >>


  \layout {
\layout {
    indent = 4\cm
  indent = 4\cm
    short-indent = 2\cm
  short-indent = 2\cm
    line-width = 6.5\cm
  line-width = 6.5\cm
  }
}
}
</lilypond>
</lilypond>


[[Category:Non-music]]
[[Category:Non-music]]
[[Category:Paper and layout]]
[[Category:Text]]
[[Category:Text]]
[[Category:Paper and layout]]
[[Category:Titles]]
[[Category:Titles]]
[[Category:Included in the official documentation]]
[[Category:Included in the official documentation]]
[[Category:Snippet]]

Latest revision as of 15:22, 12 December 2025

The horizontal alignment of instrument names is tweaked by changing the self-alignment-X property of the InstrumentName grob (usually in the Staff context). The \layout variables indent and short-indent define the space in which the instrument names are aligned before the first and the following systems, respectively.

\version "2.24"

\paper {
  left-margin = 3\cm
}

\new StaffGroup <<
  \new Staff \with {
    \override InstrumentName.self-alignment-X = #LEFT
    instrumentName = \markup \left-column { "Left aligned"
                                            "instrument name" }
    shortInstrumentName = "Left"
  } {
    c''1 \break c''1
  }

  \new Staff \with {
    \override InstrumentName.self-alignment-X = #CENTER
    instrumentName = \markup \center-column { Centered
                                              "instrument name" }
    shortInstrumentName = "Centered"
  } {
    g'1 g'1
  }

  \new Staff \with {
    \override InstrumentName.self-alignment-X = #RIGHT
    instrumentName = \markup \right-column { "Right aligned"
                                             "instrument name" }
    shortInstrumentName = "Right"
  } {
    e'1 e'1
  }
>>

\layout {
  indent = 4\cm
  short-indent = 2\cm
  line-width = 6.5\cm
}