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: Aaron Hill
Subject: Re: Markup in left and right margins
Date: Thu, 15 Oct 2020 03:22:33 -0700
User-agent: Roundcube Webmail/1.4.9

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

Attachment: margin-markup.png
Description: PNG image


reply via email to

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