6

Can I do this in Lilypond? I believe it's possible, however I could not find anything in docs about this.

My question is, instead of repeating like this:

g16-\markup {\tiny\underline\typewriter 1/16 }
g8-\markup {\tiny\underline\typewriter 1/8 }
g4-\markup {\tiny\underline\typewriter 1/4}

Is it possible to have those attributes grouped, then used simply where one would need them?

0

5 Answers 5

3

There are several solutions to this. Here's another suggestion:

tut = #(define-scheme-function
          (parser location text)
          (string?)
          #{\markup { \tiny \underline \typewriter #text }
          #})

{ g16 -\tut "1/16" }
1
  • Maybe this could even be put in an include file and re-used for other scores?
    – bgmCoder
    Mar 7, 2018 at 3:30
3

The straightforward way is to define a markup command:

#(define-markup-command (tut layout props m) (markup?)
  (interpret-markup layout props
   #{ \markup \tiny \underline \typewriter #m #}))

{
  g16-\markup \tut 1/16
  g8-\markup \tut 1/8
  g4-\markup \tut 1/4
}

There is another already upvoted answer that is quite simpler. Unfortunately, simpler than LilyPond would permit.

3
1

For a relatively simple approach, you can (as of 2.19.80) define a markup command using the syntax

\markup tut = \markup \tiny \underline \typewriter \etc
{ g16-\markup \tut 1/16 }
1

Here is another way to temporarily save typing:

\version "2.19.26"

\markupMap TextScriptEvent.text \markup \tiny \underline \typewriter \etc
{
  g16-"1/16"
  g8-"1/8"
  g4-"1/4"
}
0

For a relatively simple approach, you can define a macro:

tut = \tiny\underline\typewriter

g16-\markup {\tut 1/16 }

1
  • You surely can define a macro, but these two lines of code will almost certainly not work just like this. Dec 17, 2021 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.