[Top][All Lists]

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

Re: automatic line-breaking in markup

From: tisimst
Subject: Re: automatic line-breaking in markup
Date: Wed, 3 Feb 2016 16:24:26 -0700 (MST)

Nice work, Harm!

- Abraham

On Wed, Feb 3, 2016 at 3:43 PM, Thomas Morley-2 [via Lilypond] <[hidden email]> wrote:
2016-02-03 19:40 GMT+01:00 Simon Albrecht <[hidden email]>:

> On 03.02.2016 19:24, Jonathan Scholbach wrote:
>> I want to create a template for a cover page. I do that by redefining
>> bookTitleMarkup. The title of the piece is stored as string in a variable
> If there’s no particular need for that, I’d use a normal header block and
> \fromproperty.
>> and I want to print it relatively tall on the cover page. It works.
>> But sadly when the title is too long it runs off the page, because
>> LilyPond does not automatically break the line. How can I get LilyPond to
>> break the line automatically when the title runs off page?
> Try this:
> %%%%%%%%%%%%%%
> \version "2.19.22"
> \paper {
>   bookTitleMarkup = \markup {
>     \fontsize #15 \wordwrap-field #'header:title
>   }
> }
> \book {
>   \header {
>     title = "Many many words may result in a title that is too long for one
> line"
>   }
>   \relative c' { c d e f }
> }
> %%%%%%%%%%%%%%%
> I don’t know how to center-align the wrapped lines, though… Anyone?
> Best, Simon

/wordwrap-field puts out a single stencil. You can't align the lines
you see after the stencil is created. At least you wouldn't want ...

How about below, description should make clear what's happening (hopefully).

#(define-markup-command (my-wordwrap-field layout props align symbol)
  (number? symbol?)
  #:properties ((baseline-skip))
  #:category align
  "Same as @code{wordwrap-field}, but internally a stencil-list is produced
first, which will aligned according to @var{align}, putting out a single

  ;; c/p from define-markup-commands.scm, because it's not public
  (define (general-column align-dir baseline mols)
    "Stack @var{mols} vertically, aligned to address@hidden horizontally."
    (let* ((aligned-mols
             (map (lambda (x) (ly:stencil-aligned-to x X align-dir)) mols))
           (stacked-stencil (stack-lines -1 0.0 baseline aligned-mols))
           (stacked-extent (ly:stencil-extent stacked-stencil X)))
      (ly:stencil-translate-axis stacked-stencil (- (car stacked-extent)) X)))

  (let* ((m (chain-assoc-get symbol props)))
    (if (string? m)
          (wordwrap-string-internal-markup-list layout props #f m))

\paper {
  bookTitleMarkup = \markup \fill-line {
    \fontsize #15 \my-wordwrap-field #CENTER #'header:title

\header {
  title = "Many many words may result in a title that is too long for one line"
\relative c' { c d e f }


lilypond-user mailing list
[hidden email]

If you reply to this email, your message will be added to the discussion below:
To start a new topic under User, email [hidden email]
To unsubscribe from Lilypond, click here.

View this message in context: Re: automatic line-breaking in markup
Sent from the User mailing list archive at

reply via email to

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