lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Markup in left and right margins


From: Matthew Fong
Subject: Re: Markup in left and right margins
Date: Thu, 15 Oct 2020 18:03:59 -0700

Hello Andrew,

Yes, in fact, I was considering rotating the content. There isn't much room, but just enough to get a few words sideways.

----

Hello Aaron,

Many thanks for the solution of translation. I'm toying around with it right now, and had a question:
I am possible misunderstanding the solution, and using the abs-override incorrectly. I cannot seem to place a comment string next to the stave. Here is my sample code.

\paper {

   paper-width = 8\cm

   paper-height = 6\cm

   top-margin = 1\cm

   bottom-margin = 1\cm

   left-margin = 1.5\cm

   right-margin = 2.5\cm

   tagline = ##f

}


\layout { indent = 0 ragged-right = ##t }


\new Staff \relative c' {

  c'1^"Comment"

}


\markup \overlay {

   \abs-translate #(cons (ly:cm -1.5) 0)

   \abs-override #(cons 'line-width (ly:cm 4))

   \with-color #'(0.8 0.3 0.2)

   \rotate #90 "This is a test"

}



Many thanks,
mattfong

On Thu, Oct 15, 2020 at 3:23 AM Aaron Hill <lilypond@hillvisions.com> wrote:
On 2020-10-15 2:53 am, Andrew Bernard wrote:
> Hi Matthew,
>
> A good question. But I would have thought that margins are exactly
> that - margins. I don't think LilyPond was ever conceived to support
> marginal annotations and complex print formatting. Wouldn't you have
> to narrow your content in whatever way so as to create left or right
> vertical space and simply add it there, so, inside the margins? But I
> am sure all the TeX experts on the list will chime in.

Nothing prevents you from \translating \markup outside the normal
bounds.

NOTE: The following code requires some helper functions in order to
specify absolute dimensions in \markup.  A real-world usage probably
should be querying the values directly from \paper to eliminate
redundancy.

%%%%
\version "2.20.0"

#(define-markup-command
   (abs-override layout props arg rest)
   (pair? markup?)
   (let* ((sym (car arg))
          (val (cdr arg))
          (scl (ly:output-def-lookup layout 'output-scale)))
     (interpret-markup layout props
       (markup #:override (cons sym (/ val scl)) rest))))

#(define-markup-command
   (abs-translate layout props arg rest)
   (pair? markup?)
   (let* ((x (car arg))
          (y (cdr arg))
          (scl (ly:output-def-lookup layout 'output-scale)))
     (interpret-markup layout props
       (markup #:translate (cons (/ x scl) (/ y scl)) rest))))

\paper {
   paper-width = 8\cm
   paper-height = 5\cm
   top-margin = 1\cm
   bottom-margin = 1\cm
   left-margin = 1.5\cm
   right-margin = 2.5\cm
   tagline = ##f
}

visualizeBounds =
#(define-scheme-function
   (text)
   (markup?)
   #{
     \markup
       \override #'(thickness . 1.5)
       \fill-line {
         \overlay {
           \lower #0.5 \draw-line #'(0 . 1)
           \arrow-head #X #LEFT ##f
           \draw-line #'(2 . 0)
         }
         #text
         \overlay {
           \lower #0.5 \draw-line #'(0 . 1)
           \arrow-head #X #RIGHT ##f
           \draw-line #'(-2 . 0)
         }
       }
   #})

\markup \smaller \column {
   \fill-line { paper: \concat { 5cm \char ##xd7 8cm } }
   \fill-line { left-margin: 1.5cm }
   \fill-line { right-margin: 2.5cm }
   \vspace #0.5
}

\markup \overlay {
   \abs-translate #(cons (ly:cm -1.5) 0)
   \abs-override #(cons 'line-width (ly:cm 1.5))
   \with-color #'(0.8 0.3 0.2)
   \visualizeBounds left

   \with-color #'(0.2 0.8 0.4)
   \visualizeBounds normal

   \abs-translate #(cons (ly:cm 4) 0)
   \abs-override #(cons 'line-width (ly:cm 2.5))
   \with-color #'(0.2 0.5 0.8)
   \visualizeBounds right
}
%%%%


-- Aaron Hill

reply via email to

[Prev in Thread] Current Thread [Next in Thread]