Am Mo., 27. Juni 2022 um 13:23 Uhr schrieb Jean Abou Samra <[email protected]>: > > > > Le 27/06/2022 à 12:12, Thomas Morley a écrit : > > Hi, > > > > https://lsr.di.unimi.it/LSR/Item?id=467 provides a markup-command to > > access header-entries for use in arbitrary markup. > > Alas it's limited to $defaultheader. > > Although there is a comment to add/access other headers like from > > \score, \bookpar explicit \book, I found no way to do so. > > I tried to look up '$current-book/'$current-bookpart in parser (and > > apply ly:book-header on the result), but to no avail, the book(part) > > is not found. > > > > How to do so? > > > > Below some code to play with (I reformated, renamed the original > > snippet, adding some condition etc): > > > > \version "2.22.1" > > > > %% LSR 467 > > #(define-markup-command (with-header layout props markup) (markup?) > > "Interpret the given markup with the header fields added to the props. > > This way, one can re-use the same functions (using fromproperty > > #'header:field) in the header block and as top-level markup." > > ;; TODO: If we are inside a score, add the score's local header block, too! > > ;; Currently, I only use the global header block, stored in $defaultheader > > (let ((scopes (list $defaultheader))) > > > > (pretty-print > > (list > > (cons '$current-bookpart (ly:parser-lookup '$current-bookpart)) > > (cons '$current-book (ly:parser-lookup '$current-book)) > > ) > > ) > > (if (every module? scopes) > > (let* ((alists (map ly:module->alist scopes)) > > (prefixed-alist > > (map > > (lambda (alist) > > (map > > (lambda (entry) > > (cons > > (symbol-append 'header: (car entry)) > > (cdr entry))) > > alist)) > > alists)) > > (props > > (append > > prefixed-alist > > props > > (layout-extract-page-properties layout)))) > > (interpret-markup layout props markup)) > > (begin > > (ly:warning "No header-module found, returning point-stencil") > > point-stencil)))) > > > > %{ > > %% (1) \header and \markup at toplevel > > %% works > > \header { my-entry = "Whatever" } > > \markup \with-header \with-color #red \fromproperty #'header:my-entry > > %} > > > > %{ > > %% (2) \header and \markup in explizit book > > %% How to make it work? > > \book { > > \header { my-entry = "Whatever" } > > \markup \with-header \with-color #red \fromproperty #'header:my-entry > > } > > %} > > > > % { > > %% (3) \header and \markup in \bookpart > > %% %% How to make it work? > > \bookpart { > > \header { my-entry = "Whatever" } > > \markup \with-header \with-color #red \fromproperty #'header:my-entry > > } > > %} > > > > %{ > > %% (4) \header and \markup in toplevel \score > > %% %% How to make it work? > > \score { > > { b1-\markup \with-header \with-color #red \fromproperty > > #'header:my-entry } > > \header { my-entry = "Whatever" } > > } > > %} > > > I don't have the time to investigate much right now, but I > think it would be possible by changing the toplevel-score-handler > and such to set a property in the \layout to the \header, and later > use that property from the layout argument of the markup command. > > This is likely to be a bit fragile, though.
I'll probably try tomorrow... > What is the use case? > There may be better ways to achieve what is wanted. I try to code sort of a tablature for Akkordzither. Instead of longish descriptions best look at the image at the bottom of https://gitlab.com/Thomas_Morley/zither-ly/-/tree/development Obviously I need sort of a TabStaff running top to bottom as opposed to the usual left to right. If I use a portrait-paper-size, I can use the default header and need to rotate the TabStaff. Not knowing how to do it different, I did so putting the TabStaff into \markup. This is the master-branch of above linked repo. Alas, I can't ensure consistent line-width of the TabStaff, because LilyPond does not accepts settings for line-width exceeding paper-dimensions. Furthermore, LilyPond not only warns, but rejects my attempts to set such a line-width. LilyPond accepts the max width of the page, though because of said rotation I need up to page-height. This is a show-stopper! Though, keeping default headers keeps multipe bookparts with different headers possible. For landscape pages I can't use the default header (found no way to rotate it). Thus I put all in one markup, faking the \header with above \with-header and adding a TabStaff in usual direction there. All works more nicely and no problems with line-width. Disadvantages: x- and y-coordinates are always switched, driving me crazy, lol. One need to rotate the landscape back to portrait with a different program. Multiple bookparts with different headers are not possible for now. So far for now, Harm
