Text
Adding a QR code
This snippet lets you draw a QR-code, for example to provide a link to the composer’s, or the music editor’s website. Actually encoding the URL into a QR-code is not done here (this just draws the QR-code from a grid of "black" or "white" values), but see the code for a short Python snippet you can use to avoid having to fill for each small square if it’s black or white.
%% Original thread: https://lists.gnu.org/archive/html/lilypond-user-fr/2022-07/msg00005.html %% (snippet author: Jean Abou Samra <jean@abou-samra.fr>) \paper{tagline=##f} #(define(index-mapf.lsts) "Applies @code{f} to corresponding elements of @code{lists}, just as @code{map}, providing an additional counter starting at zero. @code{f} needs to have the counter in its arguments like @code{(index-map (lambda (i arg) <body>) lists)}" (letloop((lstslsts) (acc'()) (i0)) (if(anynull?lsts) (reverse!acc) (loop(mapcdrlsts) (cons(applyfi(mapcarlsts)) acc) (1+i))))) #(define-markup-command(qr-codelayoutpropsdata)(string?) #:properties((width10)) (let*(;; Return lines in reversed order, since translating in Y-axis ;; uses increasing values. Meaning lines will be stacked upwards. (lines(reverse (remove string-null? (mapstring-trim-both(string-splitdata#\newline))))) (n(lengthlines)) (square-width(/widthn)) (box(make-filled-box-stencil`(0.,square-width) `(0.,square-width)))) ;; Build the final qr-code-stencil from line-stencils list (applyly:stencil-add ;; Get a list of line-stencils (index-map (lambda(iline) ;; Build a line-stencil from square-stencils list (applyly:stencil-add ;; Get a list of (already translated) square-stencils ;; per line (index-map (lambda(jchar) (ly:stencil-translate (stencil-with-color box (casechar ((#0円) white) ((#1円) black) (else (ly:warning "unrecognized character ~a, should be 0 or 1" char) red))) (cons(*jsquare-width) (*isquare-width)))) (string->listline)))) lines)))) %{ A string representation of the QR code. 0 means white, 1 means black. You can generate this automatically using Python and the pyqrcode module ("pip install pyqrcode"). Use this line of code in a Python prompt: >>> import pyqrcode; print(pyqrcode.create("https://lilypond.org").text(quiet_zone=0)) %} lilypondDotOrg= "11111110011100011110101111111 10000010010000010111101000001 10111010010110001000101011101 10111010001010111101001011101 10111010110100000111001011101 10000010011100011001101000001 11111110101010101010101111111 00000000111000111110100000000 00110011101100001000111010000 10101001111000001000001111101 00110111010100000110001011010 01010001100110010111000110001 01111011110010011110010100111 01111101001101010001001101101 01111011000001000011001111011 11001001001011001000111011010 11100110111011011001110111000 00001100010001001011100100100 10111111011001010011001000100 00001100001000101011011011100 01010010000011000000111111111 00000000110011100010100011001 11111110101001101011101010110 10000010000110111110100010011 10111010011010111100111111111 10111010110001101111000011110 10111010100101101010100101001 10000010001001000100000010010 11111110010100110010111100010" \markup\qr-code\lilypondDotOrg \markup\vspace#5 \markup\override#'(width.15)\qr-code\lilypondDotOrg
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={r4r8<gc'>qr8r4} low={c4r4c8r8g,8b,} pulse={s8^"1"s^"&"s^"2"s^"&"s^"3"s^"&"s^"4"s^"&"} \score{ \newTabStaff{ \repeatunfold2<<\high\\\low\\\pulse>> } \layout{ \context{ \TabStaff \clefmoderntab \revertTextScript.stencil \overrideTextScript.font-series=#'bold \overrideTextScript.font-size=#-2 \overrideTextScript.color=#red } \context{ \Score proportionalNotationDuration=#(ly:make-moment1/8) } } }
Adding the current date to a score
With a little Scheme code, the current date can easily be added to a score.
% first, define a variable to hold the formatted date: date=#(strftime"%d-%m-%Y"(localtime(current-time))) % use it in the title block: \header{ title="Including the date!" subtitle=\date } \score{ \relativec''{ c4ccc } } % and use it in a \markup block: \markup{ \date }
Adjusting lyrics vertical spacing
This snippet shows how to bring the lyrics line closer to the staff.
% Default layout: << \newStaff\newVoice=melody\relativec'{ c4def g4fed c1 } \newLyrics\lyricstomelody{aaaaaaaaaaaaaaaaaa} \newStaff{ \newVoice=melody\relativec'{ c4def g4fed c1 } } % Reducing the minimum space below the staff and above the lyrics: \newLyrics\with{ \overrideVerticalAxisGroup.nonstaff-relatedstaff-spacing= #'((basic-distance.1)) } \lyricstomelody{aaaaaaaaaaaaaaaaaa} >>
Aligning and centering instrument names
The horizontal alignment of instrument names is tweaked by changing the
Staff.InstrumentName.self-alignment-X property. 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.
\paper{left-margin=3\cm} \score{ \newStaffGroup<< \newStaff\with{ \overrideInstrumentName.self-alignment-X=#LEFT instrumentName=\markup\left-column{ "Left aligned" "instrument name" } shortInstrumentName="Left" } {c''1\breakc''1} \newStaff\with{ \overrideInstrumentName.self-alignment-X=#CENTER instrumentName=\markup\center-column{ Centered "instrument name" } shortInstrumentName="Centered" } {g'1g'1} \newStaff\with{ \overrideInstrumentName.self-alignment-X=#RIGHT instrumentName=\markup\right-column{ "Right aligned" "instrument name" } shortInstrumentName="Right" } {e'1e'1} >> \layout{ ragged-right=##t indent=4\cm short-indent=2\cm } }
Aligning syllables with melisma
By default, lyrics syllables that start a melisma are left aligned on
their note. The alignment can be altered using the
lyricMelismaAlignment property.
\score{ << \newStaff{ \relativec'' \newVoice="vocal"{ cd~^\markupdefaultde cd~^\markup"right aligned"de cd~^\markup"center aligned"de cd~^\markup"reset to default"de } } \newLyrics\lyricsto"vocal"{ wordwordword \setlyricMelismaAlignment=#RIGHT wordwordword \setlyricMelismaAlignment=#CENTER wordwordword \unsetlyricMelismaAlignment wordwordword } >> }
Blanking staff lines using the \whiteout command
The \whiteout command underlays a markup with a white
box. Since staff lines are in a lower layer than most other grobs,
this white box will not overlap any other grob.
\layout{ ragged-right=##f } \relativec'{ \overrideTextScript.extra-offset=#'(2.4) c2-\markup{\whiteout\pad-markup#0.5"middle C"}c }
Center text below hairpin dynamics
This example provides a function to typeset a hairpin (de)crescendo with some additional text below it, such as “molto” or “poco”. The added text will change the direction according to the direction of the hairpin. The Hairpin is aligned to DynamicText.
The example also illustrates how to modify the way an object is normally printed, using some Scheme code.
\paper{tagline=##f} hairpinWithCenteredText= #(define-music-function(text)(markup?) #{ \once\overrideVoice.Hairpin.after-line-breaking= #(lambda(grob) (let*((stencil(ly:hairpin::printgrob)) (par-y(ly:grob-parentgrobY)) (dir(ly:grob-propertypar-y'direction)) (staff-line-thickness (ly:output-def-lookup(ly:grob-layoutgrob)'line-thickness)) (new-stencil(ly:stencil-aligned-to (ly:stencil-combine-at-edge (ly:stencil-aligned-tostencilXCENTER) Ydir (ly:stencil-aligned-to (grob-interpret-markup grob (make-fontsize-markup (magnification->font-size (+(ly:staff-symbol-staff-spacegrob) (/staff-line-thickness2))) text))XCENTER)) XLEFT)) (staff-space(ly:output-def-lookup (ly:grob-layoutgrob)'staff-space)) (par-x(ly:grob-parentgrobX)) (dyn-text(grob::has-interfacepar-x'dynamic-text-interface)) (dyn-text-stencil-x-length (ifdyn-text (interval-length (ly:stencil-extent(ly:grob-propertypar-x'stencil)X)) 0)) (x-shift (ifdyn-text (- (+staff-spacedyn-text-stencil-x-length) (*0.5staff-line-thickness))0))) (ly:grob-set-property!grob'Y-offset0) (ly:grob-set-property!grob'stencil (ly:stencil-translate-axis new-stencil x-shiftX)))) #}) hairpinMolto= \hairpinWithCenteredText\markup{\italicmolto} hairpinMore= \hairpinWithCenteredText\markup{\largermoltissimo} \layout{ragged-right=##f} \relativec'{ \hairpinMolto c2\<c\f \hairpinMore c2\ppppp\<c\f \break \hairpinMolto c2^\<c\f \hairpinMore c2\ppppp\<c\f }
Changing ottava text
Internally, \ottava sets the properties ottavation (for
example, to 8va or 8vb) and middleCPosition. To
override the text of the bracket, set ottavation after invoking
\ottava.
Short text is especially useful when a brief ottava is used.
{ c'2 \ottava#1 \setStaff.ottavation=#"8" c''2 \ottava#0 c'1 \ottava#1 \setStaff.ottavation=#"Text" c''1 }
Changing the default text font family
The default font families for text can be overridden with
make-pango-font-tree.
%{ You may have to install additional fonts. Red Hat Fedora dejavu-fonts-all Debian GNU/Linux, Ubuntu fonts-dejavu-core fonts-dejavu-extra %} \paper{ % change for other default global staff size. myStaffSize=#20 %{ run lilypond -dshow-available-fonts to show all fonts available in the process log. %} #(definefonts (make-pango-font-tree"DejaVu Serif" "DejaVu Sans" "DejaVu Sans Mono" (/myStaffSize20))) } { g'''4^\markup{ DejaVuSerif:\boldbold \italicitalic \italic\bold{bolditalic} } g4_\markup{ \override#'(font-family.sans){ DejaVuSans:\boldbold \italicitalic \italic\bold{bolditalic} } } g''2^\markup{ \override#'(font-family.typewriter){ DejaVuSansMono:\boldbold \italicitalic \italic\bold{bolditalic} } } }
Combining dynamics with markup texts
Some dynamics may involve text indications (such as “più forte” or
“piano subito”). These can be produced using a \markup block.
piuF=\markup{\italicpiù\dynamicf} \layout{ragged-right=##f} \relativec''{ c2\fc-\piuF }
Combining two parts on the same staff
The part combiner tool ( \partCombine command ) allows the
combination of several different parts on the same staff. Text
directions such as “solo” or “a2” are added by default; to remove
them, simply set the property printPartCombineTexts to f.
For vocal scores (hymns), there is no need to add “solo/a2” texts, so they should be switched off. However, it might be better not to use it if there are any solos, as they won’t be indicated. In such cases, standard polyphonic notation may be preferable.
This snippet presents the three ways two parts can be printed on a same
staff: standard polyphony, \partCombine without texts, and
\partCombine with texts.
%% Combining pedal notes with clef changes musicUp=\relativec''{ \time4/4 a4c4.(g8)a4| g4e'g,(a8b)| cba2. } musicDown=\relativec''{ g4e4.(d8)c4| r2g'4(f8e)| d2\stemDowna } \score{ << \newStaff\with{instrumentName="Standard polyphony"} <<\musicUp\\\musicDown>> \newStaff\with{ instrumentName="PartCombine without text" printPartCombineTexts=##f } \partCombine\musicUp\musicDown \newStaff\with{instrumentName="PartCombine with text"} \partCombine\musicUp\musicDown >> \layout{ indent=6.0\cm \context{ \Score \overrideSystemStartBar.collapse-height=#30 } } }
Creating "real" parenthesized dynamics
Although the easiest way to add parentheses to a dynamic mark is to use
a \markup block, this method has a downside: the created
objects will behave like text markups, and not like dynamics.
However, it is possible to create a similar object using the equivalent
Scheme code (as described in the Notation Reference), combined with the
make-dynamic-script function. This way, the markup will be
regarded as a dynamic, and therefore will remain compatible with
commands such as \dynamicUp or \dynamicDown.
paren= #(define-event-function(dyn)(ly:event?) (make-dynamic-script #{\markup\concat{ \normal-text\italic\fontsize#2( \pad-x#0.2#(ly:music-propertydyn'text) \normal-text\italic\fontsize#2) } #})) \relativec''{ c4\paren\fcc\dynamicUpc\paren\p }
Creating text spanners
The \startTextSpan and \stopTextSpan commands allow the
creation of text spanners as easily as pedal indications or
octavations. Override some properties of the TextSpanner object
to modify its output.
\paper{ragged-right=##f} \relativec''{ \overrideTextSpanner.bound-details.left.text=#"bla" \overrideTextSpanner.bound-details.right.text=#"blu" a4\startTextSpan b4c a4\stopTextSpan \overrideTextSpanner.style=#'line \once\overrideTextSpanner.bound-details.left.stencil-align-dir-y=#CENTER a4\startTextSpan b4c a4\stopTextSpan \overrideTextSpanner.style=#'dashed-line \overrideTextSpanner.bound-details.left.text= \markup{\draw-line#'(0.1)} \overrideTextSpanner.bound-details.right.text= \markup{\draw-line#'(0.-2)} \once\overrideTextSpanner.bound-details.right.padding=#-2 a4\startTextSpan b4c a4\stopTextSpan \setStaff.middleCPosition=#-13 \overrideTextSpanner.dash-period=#10 \overrideTextSpanner.dash-fraction=#0.5 \overrideTextSpanner.thickness=#10 a4\startTextSpan b4c a4\stopTextSpan }
Demonstrating all headers
All header fields with special meanings.
\header{ copyright="copyright" title="title" subtitle="subtitle" composer="composer" arranger="arranger" instrument="instrument" meter="meter" opus="opus" piece="piece" poet="poet" texidoc="All header fields with special meanings." copyright="public domain" enteredby="jcn" source="urtext" } \layout{ ragged-right=##f } \score{ \relativec''{c1|c|c|c} } \score{ \relativec''{c1|c|c|c} \header{ title="localtitle" subtitle="localsubtitle" composer="localcomposer" arranger="localarranger" instrument="localinstrument" metre="localmetre" opus="localopus" piece="localpiece" poet="localpoet" copyright="localcopyright" } }
Embedding native PostScript in a \markup block
PostScript code can be directly inserted inside a \markup
block.
% PostScript is a registered trademark of Adobe Systems Inc. \relativec''{ a4-\markup{\postscript"3 4 moveto 5 3 rlineto stroke"} -\markup{\postscript"[ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke "} b4-\markup{\postscript"3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke"} s2 a'1 }
Formatting lyrics syllables
Markup mode may be used to format individual syllables in lyrics.
mel=\relativec''{c4ccc} lyr=\lyricmode{ Lyrics\markup{\italiccan}\markup{\with-color#redcontain} \markup{\fontsize#8\boldMarkup!} } << \newVoice=melody\mel \newLyrics\lyricstomelody\lyr >>
How to put ties between syllables in lyrics
This can be achieved by separating those syllables by tildes.
\lyrics{ wa~o~a }
Lyrics alignment
Horizontal alignment for lyrics can be set by overriding the
self-alignment-X property of the LyricText object.
#-1 is left, #0 is center and #1 is right;
however, you can use #LEFT, #CENTER and #RIGHT as
well.
\layout{ragged-right=##f} \relativec''{ c1 c1 c1 } \addlyrics{ \once\overrideLyricText.self-alignment-X=#LEFT "This is left-aligned" \once\overrideLyricText.self-alignment-X=#CENTER "This is centered" \once\overrideLyricText.self-alignment-X=#1 "This is right-aligned" }
Markup list
Text that can spread over pages is entered with the \markuplist
command.
%% updated/modified by P.P.Schneider on Feb. 2014 #(set-default-paper-size"a6") #(define-markup-list-command(paragraphlayoutpropsargs)(markup-list?) (interpret-markup-listlayoutprops (make-justified-lines-markup-list(cons(make-hspace-markup2)args)))) % Candide, Voltaire \markuplist{ \override-lines#'(baseline-skip.2.5){ \paragraph{ IlyavaitenWestphalie,danslechâteaudeM.lebaronde Thunder-ten-tronckh,unjeunegarçonàquilanatureavaitdonné lesmœurslesplusdouces.Saphysionomieannonçaitsonâme. Ilavaitlejugementassezdroit,avecl'espritleplus \concat{simple\hspace#.3;} c'est,jecrois,pourcetteraisonqu'onlenommaitCandide.Les anciensdomestiquesdelamaisonsoupçonnaientqu'ilétaitfils delasœurdemonsieurlebaronetd'unbonethonnête gentilhommeduvoisinage,quecettedemoisellenevoulutjamais épouserparcequ'iln'avaitpuprouverquesoixanteetonze quartiers,etquelerestedesonarbregénéalogiqueavaitété perduparl'injuredutemps. } \vspace#.3 \paragraph{ Monsieurlebaronétaitundespluspuissantsseigneursdela Westphalie,carsonchâteauavaituneporteetdesfenêtres.Sa grandesallemêmeétaitornéed'unetapisserie.Tousleschiens desesbasses-courscomposaientunemeutedansle \concat{besoin\hspace#.3;} sespalefreniersétaientses \concat{piqueurs\hspace#.3;} levicaireduvillageétait songrand-aumônier.Ilsl'appelaienttousmonseigneur,etils riaientquandilfaisaitdescontes. } } }
Multi-measure rest markup
Markups attached to a multi-measure rest will be centered above or below it. Long markups attached to multi-measure rests do not cause the measure to expand. To expand a multi-measure rest to fit the markup, use an empty chord with an attached markup before the multi-measure rest. Text attached to a spacer rest in this way is left-aligned to the position where the note would be placed in the measure, but if the measure length is determined by the length of the text, the text will appear to be centered.
\relativec'{ \compressMMRests{ \textLengthOn <>^\markup{[MAJORGENERAL]} R1*19 <>_\markup{\italic{Cue:...itisyours}} <>^\markup{A} R1*30^\markup{[MABEL]} \textLengthOff c4^\markup{CHORUS}dfc } }
Of the ubiquity of markup objects
Text objects are entered either as simple strings between double quotes
or as \markup blocks that can accept a variety of advanced text
formatting and graphical enhancements.
As such, markup blocks may be used:
-
in any TextScript object (attached to notes with
-,^or_), -
any
TextMarkintroduced with the\textMarkor\textEndMarkcommand, or other similar objects such as MetronomeMark introduced with\tempo, -
as standalone markup blocks, entered at the top level outside of any
\scoreblock, -
in any definition inside the
\headerblock (e.g. title, subtitle, composer) or in some variables defined inside the\paperblock such asevenHeaderMarkupfor page numbers.
\markup may additionally be used for lyrics, in chord names,
and as dynamics. In fact, it is possible to use \markup to
customize the appearance of virtually any object, as demonstrated in
this example using various methods.
%% Thanks to Aaron Hill https://lists.gnu.org/archive/html/lilypond-user/2019-01/msg00437.html \paper{ paper-width=8\cmpaper-height=8\cm } \header{ title=\markup"Header" tagline=\markup"(tagline)" } \markup"Top-level markup" dyn=#(make-dynamic-script#{\markup\text"DynamicText"#}) \score{ << \newChordNames \with{majorSevenSymbol=\markup"majorSevenSymbol"} \chordmode{c1:maj7} \newStaff{ \tempo\markup"MetronomeMark" \textMark"TextMark" \once\overrideTupletNumber.text=\markup"TupletNumber" \tuplet3/2{ \once\overrideNoteHead.stencil=#ly:text-interface::print \once\overrideNoteHead.text=\markup\lower#0.5"NoteHead" c''8^\markup"TextScript" \once\overrideRest.stencil=#(lambda(grob) (grob-interpret-markupgrob#{ \markup"Rest" #})) r4 } } \newLyrics\lyricmode{\markup"LyricText"1} \newDynamics{s1\dyn} >> }
Outputting the version number
It is possible to print the version number of LilyPond in markup.
\markup{ProcessedwithLilyPondversion#(lilypond-version)}
Piano template with centered lyrics
Instead of having a full staff for the melody and lyrics, lyrics can be centered between the staves of a piano staff.
upper=\relativec''{ \cleftreble \keyc\major \time4/4 a4bcd } lower=\relativec{ \clefbass \keyc\major \time4/4 a2c } text=\lyricmode{ AaaBeeCeeDee } \score{ \newPianoStaff<< \newStaff=upper{\newVoice="singer"\upper} \newLyrics\lyricsto"singer"\text \newStaff=lower{\lower} >> \layout{} \midi{} }
Printing bar numbers with changing regular intervals
Using the set-bar-number-visibility context function, bar number
intervals can be changed.
\relativec'{ \overrideScore.BarNumber.break-visibility=#end-of-line-invisible \contextScore\applyContext#(set-bar-number-visibility4) \repeatunfold10c'1 \contextScore\applyContext#(set-bar-number-visibility2) \repeatunfold10c }
Printing marks on every staff
Although marks are normally only printed above the topmost staff, they may also be printed on every staff.
\score{ << \newStaff{\mark\defaultc''1\textMark"molto"c''} \newStaff{\mark\defaultc'1\textMark"molto"c'} >> \layout{ \context{ \Score \removeMark_engraver \removeText_mark_engraver \removeStaff_collecting_engraver } \context{ \Staff \consistsMark_engraver \consistsText_mark_engraver \consistsStaff_collecting_engraver } } }
Printing text from right to left
It is possible to print text from right to left in a markup object, as demonstrated here.
{ b1^\markup{ \line{ingirumimusnocte} } f'_\markup{ \override#'(text-direction.-1) \line{ingirumimusnocte} } }
Putting lyrics inside the staff
Lyrics can be moved vertically to place them inside the staff. The
lyrics are moved with
\override LyricText.extra-offset = #'(0 . dy) and there are
similar commands to move the extenders and hyphens. The offset needed
is established with trial and error.
<< \newStaff<< \newVoice="voc"\relativec'{\stemDownabesc8bc4} >> \newLyrics\with{ \overrideLyricText.extra-offset=#'(0.8.6) \overrideLyricExtender.extra-offset=#'(0.8.6) \overrideLyricHyphen.extra-offset=#'(0.8.6) }\lyricsto"voc"{Lala--la___la} >>
Stand-alone two-column markup
Stand-alone text may be arranged in several columns using
\markup commands:
\markup{ \fill-line{ \hspace#1 \column{ \line{Osacrumconvivium} \line{inquoChristussumitur,} \line{recoliturmemoriapassionisejus,} \line{mensimpleturgratia,} \line{futuraegloriaenobispignusdatur.} \line{Amen.} } \hspace#2 \column\italic{ \line{Osacredfeast} \line{inwhichChristisreceived,} \line{thememoryofHisPassionisrenewed,} \line{themindisfilledwithgrace,} \line{andapledgeoffuturegloryisgiventous.} \line{Amen.} } \hspace#1 } }
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?) #{ \overrideTextSpanner.style=#'solid \overrideTextSpanner.font-size=#-5 \overrideTextSpanner.bound-details.left.stencil-align-dir-y=#CENTER \overrideTextSpanner.bound-details.left.text= \markup{\circle\number$StringNumber} #}) \relativec{ \clef"treble_8" \stringNumberSpanner"5" \textSpannerDown a8\startTextSpan bcdef\stopTextSpan \stringNumberSpanner"4" g\startTextSpana bes4ag2\stopTextSpan }
Three-sided box
This example shows how to add a markup command to get a three sided box around some text (or other markup).
% New command to add a three sided box, with sides north, west and south % Based on the box-stencil command defined in scm/stencil.scm % Note that ";;" is used to comment a line in Scheme #(define-public(NWS-box-stencilstencilthicknesspadding) "Add a box around STENCIL, producing a new stencil." (let*((x-ext(interval-widen(ly:stencil-extentstencilX)padding)) (y-ext(interval-widen(ly:stencil-extentstencilY)padding)) (y-rule(make-filled-box-stencil(cons0thickness)y-ext)) (x-rule(make-filled-box-stencil (interval-widenx-extthickness)(cons0thickness)))) ;; (set! stencil (ly:stencil-combine-at-edge stencil X 1 y-rule padding)) (set!stencil(ly:stencil-combine-at-edgestencilXLEFTy-rulepadding)) (set!stencil(ly:stencil-combine-at-edgestencilYUPx-rule0.0)) (set!stencil(ly:stencil-combine-at-edgestencilYDOWNx-rule0.0)) stencil)) % The corresponding markup command, based on the \box command defined % in scm/define-markup-commands.scm #(define-markup-command(NWS-boxlayoutpropsarg)(markup?) #:properties((thickness0.1)(font-size0)(box-padding0.2)) "Draw a box round @var{arg}. Looks at @code{thickness}, @code{box-padding} and @code{font-size} properties to determine line thickness and padding around the markup." (let((pad(*(magstepfont-size)box-padding)) (m(interpret-markuplayoutpropsarg))) (NWS-box-stencilmthicknesspad))) % Test it: \relativec'{ c1^\markup{\NWS-boxABCD} c1^\markup{\NWS-box\note{4}#1.0} }
UTF-8
Various scripts may be used for texts (like titles and lyrics) by entering them in UTF-8 encoding, and using a Pango based backend. Depending on the fonts installed, this fragment will render Bulgarian (Cyrillic), Hebrew, Japanese and Portuguese.
%{ You may have to install additional fonts. Red Hat Fedora linux-libertine-fonts (Latin, Cyrillic, Hebrew) google-noto-serif-jp-fonts (Japanese) Debian GNU/Linux, Ubuntu fonts-linuxlibertine (Latin, Cyrillic, Hebrew) fonts-noto-cjk (Japanese) %} % 'Linux Libertine' fonts also contain Cyrillic and Hebrew glyphs. \paper{ #(definefonts (set-global-fonts #:roman"Linux Libertine O, Noto Serif CJK JP, Noto Serif JP" )) } bulgarian=\lyricmode{ Жълтатадюлябешещастлива,чепухът,койтоцъфна,замръзнакатогьон. } hebrew=\lyricmode{ זהכיףסתםלשמועאיךתנצחקרפדעץטובבגן. } japanese=\lyricmode{ いろはにほへどちりぬるを わがよたれぞつねならむ うゐのおくやまけふこえて あさきゆめみじゑひもせず } % "a nice song for you" portuguese=\lyricmode{ àvo--cêumacan--çãole--gal } \relativec'{ c2d e2f g2f e2d } \addlyrics{\bulgarian} \addlyrics{\hebrew} \addlyrics{\japanese} \addlyrics{\portuguese}
Vocal ensemble template with lyrics aligned below and above the staves
This template is basically the same as the simple “Vocal ensemble”
template, with the exception that here all the lyrics lines are placed
using alignAboveContext and alignBelowContext.
global={ \keyc\major \time4/4 } sopMusic=\relativec''{ c4cc8[(b)]c4 } sopWords=\lyricmode{ hihihihi } altoMusic=\relativec'{ e4fde } altoWords=\lyricmode{ hahahaha } tenorMusic=\relativec'{ g4afg } tenorWords=\lyricmode{ huhuhuhu } bassMusic=\relativec{ c4cgc } bassWords=\lyricmode{ hohohoho } \score{ \newChoirStaff<< \newStaff="women"<< \newVoice="sopranos"{\voiceOne<<\global\sopMusic>>} \newVoice="altos"{\voiceTwo<<\global\altoMusic>>} >> \newLyrics\with{alignAboveContext=#"women"} \lyricsto"sopranos"\sopWords \newLyrics\with{alignBelowContext=#"women"} \lyricsto"altos"\altoWords % we could remove the line about this with the line below, since % we want the alto lyrics to be below the alto Voice anyway. % \new Lyrics \lyricsto "altos" \altoWords \newStaff="men"<< \clefbass \newVoice="tenors"{\voiceOne<<\global\tenorMusic>>} \newVoice="basses"{\voiceTwo<<\global\bassMusic>>} >> \newLyrics\with{alignAboveContext=#"men"} \lyricsto"tenors"\tenorWords \newLyrics\with{alignBelowContext=#"men"} \lyricsto"basses"\bassWords % again, we could replace the line above this with the line below. % \new Lyrics \lyricsto "basses" \bassWords >> }
Volta text markup using repeatCommands
Though volte are best specified using \repeat volta, the
context property repeatCommands must be used in cases where the
volta text needs more advanced formatting with \markup.
Since repeatCommands takes a list, the simplest method of
including markup is to use an identifier for the text and embed it in
the command list using the Scheme syntax
#(list (list 'volta textIdentifier)). Start- and end-repeat
commands can be added as separate list elements:
voltaAdLib=\markup{1.2.3...\text\italic{adlib.}} \relativec''{ c1 \setScore.repeatCommands=#(list(list'voltavoltaAdLib)'start-repeat) c4bde \setScore.repeatCommands=#'((volta#f)(volta"4.")end-repeat) f1 \setScore.repeatCommands=#'((volta#f)) }