Text alignment
==============

LilyPond provides many different ways to positiong text.
The appendix here outlines some of the most important.


Default alignment
-----------------

LilyPond LEFT aligns markup relative to the LEFT edge-of-notehead by default.

<abjad>
notes = construct.run(1, Rational(1, 4))
staff = RhythmicStaff(notes)
leaves = staff.leaves
leaves[0].markup.up.append('XX')
write_ly(staff, 'default-alignment', template = 'thebes') <hide
show(staff, 'thebes')
</abjad>


``TextScript #'self-alignment-X``
---------------------------------

Use ``#'self-alignment-X`` to LEFT-, CENTER- or RIGHT-align markup
relative to the LEFT edge-of-notehead.

.. note:: changes to ``#'self-alignment-X`` do not change the fact
   that markup positioning is by default relative to the 
   LEFT edge-of-notehead.

<abjad>
notes = construct.run(3, Rational(1, 4))
staff = RhythmicStaff(notes)
leaves = staff.leaves
leaves[0].markup.up.append('XX')
leaves[0].text.self_alignment_X = 'left'
leaves[1].markup.up.append('XX')
leaves[1].text.self_alignment_X = 'center'
leaves[2].markup.up.append('XX')
leaves[2].text.self_alignment_X = 'right'
write_ly(staff, 'self-alignment-X-alone', template = 'thebes') <hide
show(staff, 'thebes')
</abjad>


``TextScript #'X-offset``
-------------------------

Use ``#'X-offset`` to OFFSET markup by some number of magic units
in the horizontal direction.

.. note:: Specify ``#'X-offset`` arguments as numbers like ``#2.5``.
   Do not specify ``#'X-offset`` arguments as direction contstants 
   like ``#right``.

.. note:: changes to ``#'X-offset`` do not change the fact
   that markup positioning is by default relative to the 
   LEFT edge-of-notehead.

<abjad>
notes = construct.run(4, Rational(1, 4))
staff = RhythmicStaff(notes)
leaves = staff.leaves
leaves[0].markup.up.append('XX')
leaves[0].text.X_offset = 0
leaves[1].markup.up.append('XX')
leaves[1].text.X_offset = 2
leaves[2].markup.up.append('XX')
leaves[2].text.X_offset = 4
leaves[3].markup.up.append('XX')
leaves[3].text.X_offset = 6
write_ly(staff, 'X-offset-alone', template = 'thebes') <hide
show(staff, 'thebes')
</abjad>
