1 % DO NOT EDIT this file manually; it is automatically
2 % generated from Documentation/snippets/new
3 % Make any changes in Documentation/snippets/new/
4 % and then run scripts/auxiliar/makelsr.py
6 % This file is in the public domain.
7 %% Note: this file works from version 2.15.31
11 lsrtags = "text, tweaks-and-overrides, contexts-and-engravers"
13 For technical reasons, text scripts attached to note heads cannot
14 easily be centered on a note head's width, unlike articulations.
16 Instead of using trial-and-error offset tweaks, this snippet uses a
17 Scheme engraver to reset the horizontal parent of each markup to a
18 @code{NoteColumn}. This also allows text to follow note heads which have
19 been shifted via @code{force-hshift}.
21 doctitle = "Centering markup on note heads automatically"
25 #(define (Text_align_engraver ctx)
30 ((note-column-interface trans grob source)
31 ;; cache NoteColumn in this Voice context
32 (set! note-column grob))
33 ((text-script-interface trans grob source)
34 ;; whenever a TextScript is acknowledged,
35 ;; add it to `scripts' list
36 (set! scripts (cons grob scripts))))
37 ((stop-translation-timestep trans)
38 ;; if any TextScript grobs exist,
39 ;; set NoteColumn as X-parent
40 (for-each (lambda (script)
41 (set! (ly:grob-parent script X) note-column))
43 ;; clear scripts ready for next timestep
44 (set! scripts '())))))
49 \consists #Text_align_engraver
50 \override TextScript #'X-offset =
51 #ly:self-alignment-interface::aligned-on-x-parent
52 \override TextScript #'self-alignment-X = #CENTER
58 \override NoteColumn #'force-hshift = #3
59 c1-\markup { \arrow-head #Y #DOWN ##t }
63 a4 a-\markup { \huge ^ } a a