On 2019-09-30 6:18 am, Kieren MacMillan wrote:
Hi Michael,

for a project of mine I wanted to center a markup inside another markup. I searched the built-in markup functions, but to no avail. (Surely it is
possible that I missed something...)

This is *almost* it, right?

%%%  SNIPPET ENDS
\version "2.19.83"

boxone = \markup \with-color #blue \filled-box #'(0 . 6) #'(0 . 6) #0
boxtwo = \markup \with-color #red \filled-box #'(3 . 5) #'(5 . 7) #0

\markup \combine \halign #0 \boxone \halign #0 \boxtwo
%%%  SNIPPET ENDS

I may be wrong, but I’m thinking there’s some relatively simple
incantation which would take it to the goal line.
Hopefully someone out there more knowledgeable than I will help.

Here's my take:

%%%%
\version "2.19.83"

#(define-markup-command (centered-overlay layout props args)
  (markup-list?)
  (ly:stencil-aligned-to
    (interpret-markup layout props #{ \markup \halign #LEFT \overlay {
#@(map (lambda (m) #{ \markup \vcenter \halign #CENTER $m #}) args) } #})
    Y DOWN))

boxone = \markup \with-color #yellow \filled-box #'(0 . 6) #'(0 . 6) #0
boxtwo = \markup \with-color #green \filled-box #'(3 . 5) #'(5 . 7) #0

\markup {
  "\centered-overlay:"
  \centered-overlay { \boxone "1" }
  \centered-overlay { \boxtwo "2" }
  \centered-overlay { \boxone \boxtwo "1+2" }
}
%%%%


-- Aaron Hill
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to