Autor Thema: Tabellen template  (Gelesen 4678 mal)

mgd

  • Member
Tabellen template
« am: Sonntag, 24. Mai 2015, 13:31 »
Hallo Forum !

Aus dem LSR snippet http://lsr.di.unimi.it/LSR/Item?id=628 habe ich die Grundidee für eine Tabelle abgeleitet. Das dortige Beispiel habe ich noch weiter parameterisiert, indem alle relevanten Tabellenabstände in Variablen ausgelagert habe. Ich kann so das Spacing meiner Tabelle sehr einfach ändern.

Soweit so gut. Das angefügte Beispiel zeigt, wie das aussieht:\version "2.18.2"

#(define YPos 0)
#(define YOffset 3.4)
#(define YSpace 4.6)

#(define XColOne 0)
#(define XColTwo 11)
#(define XColThree 16)
#(define XColFour 18)
#(define XColFourb 21.5)
#(define XColCont 28)

%% overlay from LSR
%% http://lsr.di.unimi.it/LSR/Item?id=628
%% see also http://lilypond.org/doc/v2.18/Documentation/notation/text-markup-commands.fr.html
#(define-public (stack-stencil-overlay stencils)
  "Recursive function to add stencils together"
  (if (and (pair? stencils)
           (ly:stencil? (car stencils)))

      (if (and (pair? (cdr stencils))
               (ly:stencil? (cadr stencils)))
          (let ((tail (stack-stencil-overlay (cdr stencils)))
                (head (car stencils)))
               (ly:stencil-add head tail))
          (car stencils))
      point-stencil))

#(define-markup-command (overlay layout props args)
  (markup-list?)
  "Overlay arguments one on top of the next"
  (let ((stencils (interpret-markup-list layout props args)))
       (stack-stencil-overlay
         (remove ly:stencil-empty? stencils))))


\markup {
  \overlay {
      %% verse 1
      \translate #(cons XColOne YPos) \center-align \dynamic f
      \translate #(cons XColTwo YPos) \right-align \italic "Full"
      \translate #(cons XColThree YPos) \right-align 1
      \translate #(cons XColFour YPos) \left-align \line { When the Lord turn'd again the cap- | tivity of | Sion : }
      #(set! YPos (- YPos YOffset))
      \translate #(cons XColFourb YPos) \left-align \line { then were we | like unto | them that | dream. }
      #(set! YPos (- YPos YSpace))

      %% verse 2
      \translate #(cons XColOne YPos) \center-align \dynamic mf
      \translate #(cons XColTwo YPos) \right-align \italic "Full"
      \translate #(cons XColThree YPos) \right-align 2
      \translate #(cons XColFour YPos) \left-align \line { Then was our mouth | fill'd with | laugh- }
      #(set! YPos (- YPos YOffset))
      \translate #(cons XColFourb YPos) \left-align \line { ter, | and our | tongue with | joy. }
      #(set! YPos (- YPos YSpace))

  }
}

Dieser Code funktioniert für mich insoweit, dass unter 2.18.2 die erzeugte Ausgabe korrekt aussieht. Allerdings verursachen die #(set! YPos (- YPos YOffset))bzw. #(set! YPos (- YPos YSpace))Fehlermeldungen, die ich gern loswerden würde.

Kann mir jmd sagen, wie das geht, oder wie ich meinen Code ggf. anders strukturieren müßte ?

Frohe Pfingsten,
Michael

Pusteblumi

  • Member
Re: Tabellen template
« Antwort #1 am: Montag, 25. Mai 2015, 21:46 »
Hallo Michael,

du könntest für jede Zeile einen eigenen \markup \overlay - Block verwenden:
\version "2.18.2"

#(define YPos 0)
#(define YOffset 3.4)
#(define YSpace 4.6)

#(define XColOne 0)
#(define XColTwo 11)
#(define XColThree 16)
#(define XColFour 18)
#(define XColFourb 21.5)
#(define XColCont 28)

%% overlay from LSR
%% http://lsr.di.unimi.it/LSR/Item?id=628
%% see also http://lilypond.org/doc/v2.18/Documentation/notation/text-markup-commands.fr.html
#(define-public (stack-stencil-overlay stencils)
   "Recursive function to add stencils together"
   (if (and (pair? stencils)
            (ly:stencil? (car stencils)))

       (if (and (pair? (cdr stencils))
                (ly:stencil? (cadr stencils)))
           (let ((tail (stack-stencil-overlay (cdr stencils)))
                 (head (car stencils)))
             (ly:stencil-add head tail))
           (car stencils))
       point-stencil))

#(define-markup-command (overlay layout props args)
   (markup-list?)
   "Overlay arguments one on top of the next"
   (let ((stencils (interpret-markup-list layout props args)))
     (stack-stencil-overlay
      (remove ly:stencil-empty? stencils))))


\markup {
  \overlay {
    %% verse 1
    \translate #(cons XColOne YPos) \center-align \dynamic f
    \translate #(cons XColTwo YPos) \right-align \italic "Full"
    \translate #(cons XColThree YPos) \right-align 1
    \translate #(cons XColFour YPos) \left-align \line { When the Lord turn'd again the cap- | tivity of | Sion : }
  }
}
\markup {
  \overlay {
    \translate #(cons XColFourb YPos) \left-align \line { then were we | like unto | them that | dream. }
  }
}
\markup \vspace #0.2
\markup {
  \overlay {
    %% verse 2
    \translate #(cons XColOne YPos) \center-align \dynamic mf
    \translate #(cons XColTwo YPos) \right-align \italic "Full"
    \translate #(cons XColThree YPos) \right-align 2
    \translate #(cons XColFour YPos) \left-align \line { Then was our mouth | fill'd with | laugh- }
  }
}
\markup {
  \overlay {
    \translate #(cons XColFourb YPos) \left-align \line { ter, | and our | tongue with | joy. }
  }
}

Allerdings bestimmt dann Lilypond die Höhe jeder Zeile automatisch.
Deshalb könnte man in jeden Block ein \vspace einbauen, um eine Mindesthöhe zu "verbrauchen":

\version "2.18.2"

#(define YPos 0)
#(define YOffset 3.4)
#(define YSpace 4.6)

#(define XColOne 0)
#(define XColTwo 11)
#(define XColThree 16)
#(define XColFour 18)
#(define XColFourb 21.5)
#(define XColCont 28)

%% overlay from LSR
%% http://lsr.di.unimi.it/LSR/Item?id=628
%% see also http://lilypond.org/doc/v2.18/Documentation/notation/text-markup-commands.fr.html
#(define-public (stack-stencil-overlay stencils)
   "Recursive function to add stencils together"
   (if (and (pair? stencils)
            (ly:stencil? (car stencils)))

       (if (and (pair? (cdr stencils))
                (ly:stencil? (cadr stencils)))
           (let ((tail (stack-stencil-overlay (cdr stencils)))
                 (head (car stencils)))
             (ly:stencil-add head tail))
           (car stencils))
       point-stencil))

#(define-markup-command (overlay layout props args)
   (markup-list?)
   "Overlay arguments one on top of the next"
   (let ((stencils (interpret-markup-list layout props args)))
     (stack-stencil-overlay
      (remove ly:stencil-empty? stencils))))


\markup {
  \overlay {
    %% verse 1
    \translate #(cons XColOne YPos) \center-align \dynamic f
    \translate #(cons XColTwo YPos) \right-align \italic "Full"
    \translate #(cons XColThree YPos) \right-align 1
    \translate #(cons XColFour YPos) \left-align \line { When the Lord turn'd again the cap- | tivity of | Sion : }
  }
}
\markup {
  \overlay {
    \translate #(cons XColFourb YPos) \left-align \line { then were we | like unto | them that | dream. }
    \vspace #0.7
  }
}
\markup {
  \overlay {
    %% verse 2
    \translate #(cons XColOne YPos) \center-align \dynamic mf
    \translate #(cons XColTwo YPos) \right-align \italic "Full"
    \translate #(cons XColThree YPos) \right-align 2
    \translate #(cons XColFour YPos) \left-align \line { Then was our mouth | fill'd with | laugh- }
    \vspace #1.4
  }
}
\markup {
  \overlay {
    \translate #(cons XColFourb YPos) \left-align \line { ter, | and our | tongue with | joy. }
    \vspace #0.7
  }
}

Viele Grüße,
Klaus

mgd

  • Member
Re: Tabellen template
« Antwort #2 am: Dienstag, 26. Mai 2015, 00:09 »
Hallo Klaus,

vielen Dank für deinen Vorschlag.

Die Gründe, warum ich mir überhaupt dieses Tabellenkonstrukt mit den Variablen für das Spacing ausgedacht hatte sind diese:
  • Ich möchte vollständige Kontrolle über die Ausrichtung meiner Felder in der Tabelle haben
  • Ich möchte das Spacing vorn an zentraler Stelle, am Besten in einem include setzen. Wenn ich in jeder Zeile das Spacing von Hand adjustiere, dann verliere ich genau diesen Punkt

Genau genommen möchte ich auch noch das Alignment (left, right, center) aus der Tabelle herausziehen und vorn an zentraler Stelle setzen, aber das wäre dann die Luxusversion :)

Liebe Grüße,
Michael

Pusteblumi

  • Member
Re: Tabellen template
« Antwort #3 am: Dienstag, 26. Mai 2015, 02:21 »
Hallo Michael,

vollständige Kontrolle ist echt schwierig mit LilyPond... ;-)

Aber du kannst für das Spacing auch deine Variablen verwenden, und das Alignment vorzugeben ist auch kein Problem:
\version "2.18.2"

#(define YPos 0)
#(define YOffset 0.7)
#(define YSpace 1.4)

#(define alignColOne   CENTER)
#(define alignColTwo   RIGHT)
#(define alignColThree RIGHT)
#(define alignColFour  LEFT)

#(define XColOne 0)
#(define XColTwo 11)
#(define XColThree 16)
#(define XColFour 18)
#(define XColFourb 21.5)
#(define XColCont 28)

%% overlay from LSR
%% http://lsr.di.unimi.it/LSR/Item?id=628
%% see also http://lilypond.org/doc/v2.18/Documentation/notation/text-markup-commands.fr.html
#(define-public (stack-stencil-overlay stencils)
   "Recursive function to add stencils together"
   (if (and (pair? stencils)
            (ly:stencil? (car stencils)))

       (if (and (pair? (cdr stencils))
                (ly:stencil? (cadr stencils)))
           (let ((tail (stack-stencil-overlay (cdr stencils)))
                 (head (car stencils)))
             (ly:stencil-add head tail))
           (car stencils))
       point-stencil))

#(define-markup-command (overlay layout props args)
   (markup-list?)
   "Overlay arguments one on top of the next"
   (let ((stencils (interpret-markup-list layout props args)))
     (stack-stencil-overlay
      (remove ly:stencil-empty? stencils))))


\markup {
  \overlay {
    %% verse 1
    \translate #(cons XColOne YPos) \halign #alignColOne \dynamic f
    \translate #(cons XColTwo YPos) \halign #alignColTwo \italic "Full"
    \translate #(cons XColThree YPos) \halign #alignColThree 1
    \translate #(cons XColFour YPos) \halign #alignColFour \line { When the Lord turn'd again the cap- | tivity of | Sion : }
  }
}
\markup {
  \overlay {
    \translate #(cons XColFourb YPos) \halign #alignColFour \line { then were we | like unto | them that | dream. }
    \vspace #YOffset
  }
}
\markup {
  \overlay {
    %% verse 2
    \translate #(cons XColOne YPos) \halign #alignColOne \dynamic mf
    \translate #(cons XColTwo YPos) \halign #alignColTwo \italic "Full"
    \translate #(cons XColThree YPos) \halign #alignColThree 2
    \translate #(cons XColFour YPos) \halign #alignColFour \line { Then was our mouth | fill'd with | laugh- }
    \vspace #YSpace
  }
}
\markup {
  \overlay {
    \translate #(cons XColFourb YPos) \halign #alignColFour \line { ter, | and our | tongue with | joy. }
    \vspace #YOffset
  }
}

Noch eine verrückte Idee, um die Fehlermeldungen loszuwerden: Nimm die Berechnungen aus dem \markup - Block heraus:

\version "2.18.2"

#(define YPos 0)
#(define YOffset 3.4)
#(define YSpace 4.6)

#(define XColOne 0)
#(define XColTwo 11)
#(define XColThree 16)
#(define XColFour 18)
#(define XColFourb 21.5)
#(define XColCont 28)

%% overlay from LSR
%% http://lsr.di.unimi.it/LSR/Item?id=628
%% see also http://lilypond.org/doc/v2.18/Documentation/notation/text-markup-commands.fr.html
#(define-public (stack-stencil-overlay stencils)
   "Recursive function to add stencils together"
   (if (and (pair? stencils)
            (ly:stencil? (car stencils)))

       (if (and (pair? (cdr stencils))
                (ly:stencil? (cadr stencils)))
           (let ((tail (stack-stencil-overlay (cdr stencils)))
                 (head (car stencils)))
             (ly:stencil-add head tail))
           (car stencils))
       point-stencil))

#(define-markup-command (overlay layout props args)
   (markup-list?)
   "Overlay arguments one on top of the next"
   (let ((stencils (interpret-markup-list layout props args)))
     (stack-stencil-overlay
      (remove ly:stencil-empty? stencils))))


\markup {
  \with-dimensions #'(0 . 0) #'(0 . 0)
  \overlay {
    %% verse 1
    \translate #(cons XColOne YPos) \center-align \dynamic f
    \translate #(cons XColTwo YPos) \right-align \italic "Full"
    \translate #(cons XColThree YPos) \right-align 1
    \translate #(cons XColFour YPos) \left-align \line { When the Lord turn'd again the cap- | tivity of | Sion : }
  }
}
#(set! YPos (- YPos YOffset))
\markup {
  \with-dimensions #'(0 . 0) #'(0 . 0)
  \overlay {
    \translate #(cons XColFourb YPos) \left-align \line { then were we | like unto | them that | dream. }
  }
}
#(set! YPos (- YPos YSpace))
\markup {
  \with-dimensions #'(0 . 0) #'(0 . 0)
  \overlay {
    %% verse 2
    \translate #(cons XColOne YPos) \center-align \dynamic mf
    \translate #(cons XColTwo YPos) \right-align \italic "Full"
    \translate #(cons XColThree YPos) \right-align 2
    \translate #(cons XColFour YPos) \left-align \line { Then was our mouth | fill'd with | laugh- }
  }
}
#(set! YPos (- YPos YOffset))
\markup {
  \with-dimensions #'(0 . 0) #'(0 . 0)
  \overlay {
    \translate #(cons XColFourb YPos) \left-align \line { ter, | and our | tongue with | joy. }
  }
}
#(set! YPos (- YPos YSpace))

Liebe Grüße,
Klaus

mgd

  • Member
Re: Tabellen template
« Antwort #4 am: Dienstag, 26. Mai 2015, 10:36 »
Hallo Klaus,

vielen Dank für die tollen Ideen. Das Alignment wäre damit schon mal ebenfalls vorn.

Bei deiner 2. Version scheint es so zu sein, als ob jedes \markup trotz der Angabe von \with-dimensions #'(0 . 0) #'(0 . 0) etwas zusätzlichen vertikalen Platz benötigt, jedenfalls ist das Spacing trotz der ansonsten gleichen Werte ein anderes.

Deine 1. Version sieht allerdings identisch aus, obwohl oder gerade weil deine Werte für YOffset und YSpace andere sind. Gibt es einen systematischen Weg, wie du deine Werte aus meinen erzeugt hast und wie ist der ?

Was mir ferner an deiner 1. Version gut gefällt ist, dass auf diese Weise Seitenumbrüche automatisch erfolgen - in meiner Variante muss ich den Block manuell trennen.

Aus Code ästhetischen Gesichtspunkten missfällt mir, dass eine logische Tabellenzeile in 2 \markup zerstückelt wird (ich meine die erste und 2. Zeile eines Verses). Da ringe ich noch mit mir, dass zu mögen :)

Andererseits gefällt mir, dass es ganz offensichtlich viele Wege gibt, ein identisches optisches Ergebnis zu erhalten.

Großen Dank für deine Mühen, ich bin auf jeden Fall ein gutes Stück weiter.

Liebe Grüße,
Michael

mgd

  • Member
Re: Tabellen template
« Antwort #5 am: Dienstag, 26. Mai 2015, 11:21 »
Ich habe die Version 1 aus Klaus's letztem Vorschlag jetzt in ein echtes Beispiel integriert und es zeigt sich, die in der Komplexität reduzierten Beispiele enthalten nicht alle Nebenbedingungen. Daher ein kompletter Anglikanischer Chant als Anhang Psalm-148.ly. Ferner als Anhang die beiden includierten Dateien.

Es folgt der gleiche Chant unter Verwendung der von Klaus vorgeschlagenen vertikalen Positionierung als Anhang Psalm-148-v2.ly

Die Ursache für das geänderte vertikale Spacing sind die Triolenklammern und die "Unterpunkte", die jeweils zusätzlichen vertikalen Platz verbrauchen. Das mag satztechnisch durchaus begründet sein, aber ich empfinde eine gleichmäßige vertikale Anordnung der Strophen als wichtiger.

Was will ich damit sagen ?

Weiss ich auch nicht so genau. Ich werde das jetzt erst einmal sacken lassen und abwarten, wie ich in ein paar Tagen darüber denke, was mir letztlich wichtiger ist. Zur Not lebe ich einfach mit den Fehlermeldungen - es scheint ja zumindest derzeit grundsätzlich zu klappen :)

Vielen Dank an Klaus und ggf. allen, die diesen Beitrag gelesen haben, sich aber nicht äußern konnten oder wollten. Vllt nützt es ja dem einen oder anderen.

Liebe Grüße,
Michael

Pusteblumi

  • Member
Re: Tabellen template
« Antwort #6 am: Dienstag, 26. Mai 2015, 11:24 »
Hallo Michael,

die markup-Blöcke könnte man auch so zusammenhalten:

\markup {
  \overlay {
    %% verse 2
    \translate #(cons XColOne YPos) \halign #alignColOne \dynamic mf
    \translate #(cons XColTwo YPos) \halign #alignColTwo \italic "Full"
    \translate #(cons XColThree YPos) \halign #alignColThree 2
    \translate #(cons XColFour YPos) \halign #alignColFour \line { Then was our mouth | fill'd with | laugh- }
    \translate #(cons XColFourb (- YPos YOffset)) \halign #alignColFour \line { ter, | and our | tongue with | joy. }
    \box \vspace #YSpace
  }
}

Das hätte auch den Vorteil, dass jeweils die erste und zweite Zeile nicht durch Seitenumbruch voneinander getrennt werden.

Die Werte habe ich übrigens nur durch Ausprobieren gefunden. Wenn man \vspace durch \box \vspace ersetzt, sieht man, wo der Platz liegt, der dadurch geschaffen wird.
Probier auch mal, \with-dimensions durch \box \with-dimensions zu ersetzen...

Viele Grüße,
Klaus

P.S.: Habe gerade die vollständigen Files in deinem neuen Beitrag entdeckt. Mal sehen...

Pusteblumi

  • Member
Re: Tabellen template
« Antwort #7 am: Dienstag, 26. Mai 2015, 11:53 »
Ja, stimmt schon, das vertikale Spacing geht nach Platzbedarf und damit nicht einheitlich...

...aber zumindest das Aufteilen auf zwei Seiten lässt sich verhindern, wenn man in den \paper - Block die Zeile
page-count = 1
einfügt.

Mir ist noch eingefallen, dass man Fehlermeldungen auch unterdrücken kann:
http://comments.gmane.org/gmane.comp.gnu.lilypond.general/93308
Vor dem großen \markup - Block müsste man dann einfügen:

#(define (suppress message x)
  (let loop ((c x))
    (if (> c 0)
       (begin
        (ly:expect-warning message)
        (loop (1- c))))))

#(suppress "Keine Textbeschriftung" 33)

Die einzelnen Fehlermeldungen verschwinden dann. Leider bleibt aber trotzdem am Schluss
Zitat
schwerer Fehler: gescheiterte Dateien: "c:\\users\\klaus\\appdata\\local\\temp\\frescobaldi-awwjez\\tmprml9r0\\Psalm-148.ly"
Wurde mit dem Return-Code 1 beendet.

Viele Grüße,
Klaus

mgd

  • Member
Re: Tabellen template
« Antwort #8 am: Dienstag, 26. Mai 2015, 11:57 »
Ich habe mit deinem letzten Vorschlag eine Version Psalm-148-v3 produziert, die der Version Psalm-148.ly fast pixelgenau gleicht.

ich bin mir nicht im klaren, welche von diesen Versionen (Psalm-148.ly oder Psalm-148-v3.ly) mir besser gefällt. Die erste hat ein exaktes Zeilenspacing, letztere hat subtil mehr Platz, wo Triolenklammern und Unterpunkte sonst vllt marginal zu gedrängt erscheinen.

Wie gesagt...sacken lassen :)

harm6

  • Member
Re: Tabellen template
« Antwort #9 am: Donnerstag, 28. Mai 2015, 01:11 »
Ich hab mich auch mal dran versucht.
Zwar bin ich noch ncht zufrieden aber das (Zwischen-) Ergebnis sei hier schon mal gepostet.
Ein automatischer Zeilenumbruch erfolgt allerdings nicht. Das wäre vielleicht mit einem markup-list-command machbar ...
\overlay ist nicht verwendet aber beim testen hab ich 'stack-stencil-overlay' gleich mit überarbeitet, falls ich nichts übersehen habe kann man auf die Rekursion schlichtweg verzichten.
Die neue Definition ist im Code enthalten aber auskommentiert.

\version "2.18.2"

%{
#(define-public (stack-stencil-overlay stencils) 
  (if (every ly:stencil? stencils)
      (apply ly:stencil-add stencils)
      point-stencil))

#(define-markup-command (overlay layout props args)
  (markup-list?)
  "Overlay arguments one on top of the next"
  (let ((stencils (interpret-markup-list layout props args)))
       (stack-stencil-overlay
         (remove ly:stencil-empty? stencils))))
%}         

#(define-markup-command (row layout props x-offs args)
  (list? markup-list?)
  "Stacks the args horizontally relying on 'x-offs'"
  (let ((stils (interpret-markup-list layout props args)))
   (apply ly:stencil-add
     (map
       (lambda (val stil) (ly:stencil-translate-axis stil val X))
       x-offs stils))))
       
#(define-markup-command (column-rows layout props y-offs args)
  (list? markup-list?)
  "Stacks the args vertically relying on 'y-offs'"
  (let ((stils (interpret-markup-list layout props args)))
   (apply ly:stencil-add
     (map
       (lambda (val stil) (ly:stencil-translate-axis stil (- val) Y))
       y-offs stils))))
       
YPos = 0
YOffset = 3.4
YSpace = 4.6

XColOne = 0
XColTwo = 11
XColThree = 16
XColFour = 18
XColFourb = 21.5

%% ??
XColCont = 28

my-four-column-x-off-list =
#(list XColOne XColTwo XColThree XColFour)

my-y-off-list =
%% The number (here: 7) in (iota 7 1 1) should not be less than the number of
%% args for 'column-rows'
%% Probably set it to a very high number
#(map
   (lambda (i)
     (apply + (list-head (cons YPos (circular-list YOffset YSpace)) i)))
   (iota 7 1 1))
   
\markup
 \column-rows #my-y-off-list {

  \row #my-four-column-x-off-list {
    \center-align \dynamic f
    \right-align \italic "Full"
    \right-align 1
    \left-align \line { When the Lord turn'd again the cap- | tivity of | Sion : }
  }
   
  \row #(list XColFourb) {
    \left-align \line { then were we | like unto | them that | dream. }
  }
   
  \row #my-four-column-x-off-list {
    \center-align \dynamic mf
    \right-align \italic "Full"
    \right-align 2
    \left-align \line { Then was our mouth | fill'd with | laugh- }
  }
   
  \row #(list XColFourb) {
    \left-align \line { ter, | and our | tongue with | joy. }
  }
   
  \row #my-four-column-x-off-list {
    \center-align \dynamic mf
    \right-align \italic "Full"
    \right-align 2
    \left-align \line { Then was our mouth | fill'd with | laugh- }
  }
   
  \row #(list XColFourb) {
    \left-align \line { ter, | and our | tongue with | joy. }
  }
 }

Gruß,
  Harm

Pusteblumi

  • Member
Re: Tabellen template
« Antwort #10 am: Donnerstag, 28. Mai 2015, 01:37 »
Hallo Michael,

ich hab auch gerade noch ein bisschen mit deiner Datei Psalm-148-v3 herumprobiert...
Die vielen ähnlichen \markup-Blöcke könnte man durch Funktionen ersetzen. Damit wird der Code vielleicht etwas übersichtlicher:

% Hello emacs, this is -*- coding:utf-8 -*-
\version "2.18.2"

\include "anglican-chant.ily"
\include "overlay-markup.ily"

\paper {
  print-all-headers = ##t
  print-page-number = ##f
}

\header {
  % The following fields are centered
  %  dedication = "Day 27, Evening"
  title = "Psalm 148"
  %  subtitle = "Subtitle"
  %  subsubtitle = "In convertendo"
  % The following fields are evenly spread on one line
  % the field "instrument" also appears on following pages
  %  instrument = \markup \with-color #green "Instrument"
  poet = "20"
  composer = \markup "Matthew Camidge (1758–1844)"
  % The following fields are placed at opposite ends of the same line
  %  meter = "Meter"
  %  arranger = "TD 2007"
  % The following fields are centered at the bottom
  tagline = ##f
  %  tagline = "tagline goes at the bottom of the last page"
  %  copyright = "copyright goes at the bottom of the first page"
  % The following fields are placed at opposite ends of the same line
  %  piece = "PRAELUDIUM I"
  %  opus = "BWV 248"
}
%}

keyTime = {
  \key es \major
  \time 2/2
}

SopranoMusic = \relative g' {
  \mark \markup { \circle 1 }
  g1 | as2 g | f1 | \bar "||"
  \mark \markup { \circle 2 }
  es1 | c'2 d | es as, | g f | \bar "||"
  \mark \markup { \circle 3 }
  bes1 | d2 bes | es1 | \bar "||"
  \mark \markup { \circle 4 }
  c1 | bes2 g | f f | es1 | \bar "|."
}

AltoMusic = \relative es' {
  es1 | f2 es | d1 |
  es1 | es2 as | g f | es d |
  f1 | f2 f | es1 |
  es1 | f2 es | es d | es1 |
}

TenorMusic = \relative bes {
  bes1 | bes2 bes | bes1 |
  g1 | as2 as | bes c | bes1 |
  d1 | bes2 bes | bes1 |
  as1 | f2 bes | c bes | g1 |
}

BassMusic =  \relative es {
  es1 | d2 es | bes1 |
  c1 | as2 f' | g as | bes1 |
  bes1 | as2 as | g1 |
  as1 | d,2 es | as, bes | es1 |
}


% Use markup to center the chant on the page
\markup {
  \fill-line {
    \score {
      % centered
      %\transpose e es
      <<
        \new ChoirStaff <<
          \new Staff <<
            \keyTime
            \clef "treble"
            \new Voice = "Soprano" <<
              \voiceOne
              \SopranoMusic
            >>
            \new Voice = "Alto" <<
              \voiceTwo
              \AltoMusic
            >>
          >>
          \new Staff <<
            \clef "bass"
            \keyTime
            \new Voice = "Tenor" <<
              \voiceOne
              \TenorMusic
            >>
            \new Voice = "Bass" <<
              \voiceTwo
              \BassMusic
            >>
          >>
        >>
      >>
      \layout {
        \context {
          \Score
          \override SpacingSpanner.base-shortest-duration = #(ly:make-moment 1/2)
        }
        \context {
          \Staff
          \remove "Time_signature_engraver"
        }
        \context {
          \Voice
          \consists "Horizontal_bracket_engraver"
        }
      }
    }  % End score
  }
}  % End markup

\markup {
  \fill-line {
    \column {
      \center-align { \null \null \line \caps { Psalm 148 } \vspace #0.8 }
    }
  } % \fill-line
} % \markup

#(define YPos 0)
#(define YOffset 3.2)
%#(define YSpace 4.4)
%#(define YOffset 0.7)
#(define YSpace 1.13)

#(define alignColOne   CENTER)
#(define alignColTwo   RIGHT)
#(define alignColThree RIGHT)
#(define alignColFour  LEFT)

#(define XColOne 0)
#(define XColTwo 11)
#(define XColThree 16)
#(define XColFour 18)
#(define XColFourb 21.5)
#(define XColCont 28)

#(define-markup-command (TwoLines layout props argOne argTwo argThree argFour argFourb)
   (markup? markup? markup? markup? markup?)
   (interpret-markup layout props
     #{
       \markup {
         %\fontsize #-2
         \overlay {
           %% das folgende \translate #'(x . y) \overlay { <tabelle> } definiert den Abstand der von
           %% \overlay eingeschlossenen Tabelle vom linken Papierrand und der vorherigen Überschrift
           \translate #'(11 . -2) \overlay {
             %% verse 1
             \translate #(cons XColOne YPos) \halign #alignColOne $argOne
             \translate #(cons XColTwo YPos) \halign #alignColTwo \italic $argTwo
             \translate #(cons XColThree YPos) \halign #alignColThree $argThree
             \translate #(cons XColFour YPos) \halign #alignColFour $argFour
             \translate #(cons XColFourb (- YPos YOffset)) \halign #alignColFour $argFourb
             \vspace #YSpace
           }
         }
       }
     #}))

#(define-markup-command (ThreeLines layout props argOne argTwo argThree argFour argFourb argCont)
   (markup? markup? markup? markup? markup? markup?)
   (interpret-markup layout props
     #{
       \markup {
         %\fontsize #-2
         \overlay {
           %% das folgende \translate #'(x . y) \overlay { <tabelle> } definiert den Abstand der von
           %% \overlay eingeschlossenen Tabelle vom linken Papierrand und der vorherigen Überschrift
           \translate #'(11 . -2) \overlay {
             %% verse 1
             \translate #(cons XColOne YPos) \halign #alignColOne $argOne
             \translate #(cons XColTwo YPos) \halign #alignColTwo \italic $argTwo
             \translate #(cons XColThree YPos) \halign #alignColThree $argThree
             \translate #(cons XColFour YPos) \halign #alignColFour $argFour
             \translate #(cons XColFourb (- YPos YOffset)) \halign #alignColFour $argFourb
             \translate #(cons XColCont (- YPos (* 2 YOffset))) \halign #alignColFour $argCont
             \vspace #YSpace
           }
         }
       }
     #}))

#(define-markup-command (FourLines layout props argOne argTwo argThree argFour argCont argFourb argContII)
   (markup? markup? markup? markup? markup? markup? markup?)
   (interpret-markup layout props
     #{
       \markup {
         %\fontsize #-2
         \overlay {
           %% das folgende \translate #'(x . y) \overlay { <tabelle> } definiert den Abstand der von
           %% \overlay eingeschlossenen Tabelle vom linken Papierrand und der vorherigen Überschrift
           \translate #'(11 . -2) \overlay {
             %% verse 1
             \translate #(cons XColOne YPos) \halign #alignColOne $argOne
             \translate #(cons XColTwo YPos) \halign #alignColTwo \italic $argTwo
             \translate #(cons XColThree YPos) \halign #alignColThree $argThree
             \translate #(cons XColFour YPos) \halign #alignColFour $argFour
             \translate #(cons XColCont (- YPos YOffset)) \halign #alignColFour $argCont
             \translate #(cons XColFourb (- YPos (* 2 YOffset))) \halign #alignColFour $argFourb
             \translate #(cons XColCont (- YPos (* 3 YOffset))) \halign #alignColFour $argContII
             \vspace #YSpace
           }
         }
       }
     #}))

\markup \TwoLines ""  "Full"  "1"
\line { O praise the | Lord \emphasize #"*o*f" \vertSep heav'n : }
\line { praise \vertSep ― him \vertSep \emphasize #"*i*n th*e*" \vertSep height. }

\markup \TwoLines  ""  "Full"  "2"
\line { Praise him, all ye \vertSep \single-hbracket \fontsize #-3 \italic " 3 " \line { angels \dot of } \vertSep his : }
\line { praise \vertSep ― him \vertSep all his \vertSep host. }

\markup \TwoLines ""   "Full"  "3"
\line { Praise him, \vertSep sun \emphasize #"*a*nd" \vertSep moon : }
\line { praise him, \vertSep all ye \vertSep stars \emphasize #"*a*nd" \vertSep light. }

\markup \TwoLines ""   "Full"  "4"
\line { Praise him, \vertSep all ye \vertSep heav'ns : }
\line { and ye wáters that \vertSep are a- \vertSep bove \emphasize #"th*e*" \vertSep heav'ns. }

\markup \ThreeLines ""  ""   "5"
\line { Let them praise the \vertSep \single-hbracket \fontsize #-3 \italic " 3 " \line { Name of \dot the } \vertSep Lord : }
\line { for he spake the word and they were made, * he com- \vertSep }
\line { \single-hbracket \fontsize #-3 \italic " 3 " \line { manded \dot and } \vertSep \single-hbracket \fontsize #-3 \italic " 3 " \line { they were \dot cre- } \vertSep ated. }

\markup \TwoLines ""  ""  "6"
\line { He hath made them fást for \vertSep \single-hbracket \fontsize #-3 \italic " 3 " \line { ever \dot and } \vertSep ever : }
\line { he hath given them a \vertSep law which \vertSep \single-hbracket \fontsize #-3 \italic " 3 " \line { shall not \dot be } \vertSep broken. }

\markup \TwoLines ""  ""  "7"
\line { Praise the \vertSep \single-hbracket \fontsize #-3 \italic " 3 " \line { Lord up-on } \vertSep earth : }
\line { \emphasize #"y*e*" \vertSep \single-hbracket \fontsize #-3 \italic " 3 " \line { dragons \dot and } \vertSep all ― \vertSep deeps ; }

\markup \TwoLines "" ""  "8"
\line { Fire and hail, \vertSep snow \emphasize #"*a*nd" \vertSep vapours : }
\line { wind and \vertSep storm ful- \vertSep \single-hbracket \fontsize #-3 \italic " 3 " \line { filling \dot his } \vertSep word ; }

\markup \TwoLines "" ""  "9"
\line { Mountains \emphasize #"*a*nd" \vertSep all ― \vertSep hills : }
\line { fruitful \vertSep trees \emphasize #"*a*nd" \vertSep all ― \vertSep cedars ; }

\markup \TwoLines "" ""  "10"
\line { Beasts \emphasize #"*a*nd" \vertSep all ― \vertSep cattle : }
\line { worms \vertSep ― \emphasize #"*a*nd" \vertSep feath-er'd \vertSep fowls ; }

\markup \TwoLines "" ""  "11"
\line { Kings of the earth \emphasize #"*a*nd" \vertSep all ― \vertSep people : }
\line { princes and all \vertSep \emphasize #"judg-*e*s" \vertSep \emphasize #"*o*f th*e*" \vertSep world ; }

\markup \FourLines "" ""  "12"
\line { Young men and maidens, old men and children, * praise the \vertSep }
\line { \single-hbracket \fontsize #-3 \italic " 3 " \line { Name of \dot the } \vertSep Lord : }
\line { for his Name only is excellent, * and his \vertSep \single-hbracket \fontsize #-3 \italic " 3 " \line { praise a-bove } \vertSep }
\line { heav'n \emphasize #"*a*nd" \vertSep earth. \hspace #4 \bold {[ \concat{2 \super nd} part ➛ ]} }

\markup \TwoLines "" \line { \italic {\concat{2 \super nd} part } }  "13"
\line { He shall exalt the horn of his people, * all his \vertSep saints shall \vertSep praise him : }
\line { even the children of Israel, \vertSep \single-hbracket \fontsize #-3 \italic " 3 " \line { even \dot the } \vertSep \single-hbracket \fontsize #-3 \italic " 3 " \line { people \dot that } \vertSep serveth him. }

\markup \TwoLines "" ""  ""
\line \italic { Glory \vertSep be \dot to the \vertSep father : }
\line { and to the Son, \vertSep and \dot to the \vertSep Ho-ly \vertSep Ghost ; }

\markup \TwoLines "" ""  ""
\line { As it was in the beginning, * is now, and \vertSep ever \dot shall \vertSep be : }
\line { world without \vertSep end, A- \vertSepDot ― \vertSepDot men. }

Viele Grüße,
Klaus

mgd

  • Member
Re: Tabellen template
« Antwort #11 am: Donnerstag, 28. Mai 2015, 03:16 »
Hallo Klaus,

ich glaube, diese weitergehende Modularisierung gefällt mir :)

Vielen Dank,
Michael

PS: Ich sehe gerade, Harm hatte auch noch einen Beitrag geschrieben. Den werde ich mir jetzt, oder vllt doch lieber morgen früh ;) ansehen...
« Letzte Änderung: Donnerstag, 28. Mai 2015, 03:20 von mgd »

mgd

  • Member
Re: Tabellen template
« Antwort #12 am: Donnerstag, 28. Mai 2015, 10:48 »
Lieber Harm, lieber Klaus,

zunächst einmal einen ganz herzlichen Dank, dass ihr euch die Mühe macht, auch noch das letzte Quäntchen an Schönheit und Useability bei diesem "Tabellenproblem" zu finden. Der bisherige Stand gefällt mir klar besser, als alles, was ich vorher produziert hatte :)

Ich habe den (noch vorläufigen) Ansatz von Harm auf den gesamten Psalm angewandt (Anhang Psalm-148-v5.ly). Einige der Y-Abstände speziell bei den Fortsetzungszeilen (das ist die Bedeutung von XColCont - über den Namen lässt sich streiten ;) ) sind noch nicht so, wie es meinem ästhetischen Empfinden entspricht. Aber es ist ja "work-in-progress".

Das Arbeiten mit der modularisierten Form von Klaus habe ich als ausgesprochen angenehm empfunden. Der \markup Code innerhalb der Strophen ist gegenüber den anderen Varianten deutlich reduziert, was mir sehr gefällt. Von der Funktion ThreeLines braucht man zwei Versionen - eine für Fortsetzung im 1. Teil und eine im 2. Teil. Schließlich habe ich noch das geschachtelte \translate \overlay entfernt, indem ich die X-Koordinaten entsprechend angepasst habe. Die fertige Fassung findet sich als Anhang Psalm-148-v4.ly.


Jedenfalls ist eine Modifikation des Tabellenaussehens durch die weitgehende Parameterisierung eine Kleinigkeit und erfordert lediglich die Anpassung einiger
weniger Konstanten. Sehr angenehm.

Liebe Grüße,
Michael

harm6

  • Member
Re: Tabellen template
« Antwort #13 am: Mittwoch, 8. Juli 2015, 03:06 »
Hallo,

ich hab' mich noch mal mit dem Thema befaßt.
Der code unten benutzt jetzt markuplist-commands, somit sind auch Seitenumbrüche möglich.

Ansonsten ist noch einiges geändert.
Ich habe aber darauf verzichtet den Code allzu sehr zu spezialisieren. Er würde dann in seinen Anwendungsmöglichkeiten eingeschränkt sein.

Schau mal was Du davon hälst bzw wie Du damit klar kommst.

\version "2.19.22"

#(define (equal-length-sub-lsts lst to-insert)
  ;; lst is supposed to be a list of lists.
  ;; 'equal-length-sub-lsts' returns a new list adding amounts of 'to-insert'
  ;; where needed to ensure equal length of every sublist.
  (if (every list? lst)
      (let* ((lngth-ordered-lst
               (sort-list lst (lambda (p q) (> (length p) (length q)))))
             (eq-lngth-sub-lsts
               (map
                 (lambda (ll)
                   (let* ((length-ll (length ll))
                          (max-length (length (car lngth-ordered-lst)))
                          (ls-to-add
                            (make-list (- max-length length-ll) to-insert)))
                     (append ll ls-to-add)))
                 lst)))
           eq-lngth-sub-lsts)
      (ly:error "Every element of ~a needs to be a list" lst)))
     
#(define (reorder-list-elements l1 l2)
  ;; l1 is supposed to be a list of list, each sublist of equal length.
  ;; A new list is accumulated in l2 and returned, containing the the first
  ;; elements of every sublist in a new sublist, the second elements, etc
  ;;
  ;; (list-elements '((a b c) (1 2 3) (x y z)) '())
  ;; -> '((a 1 x) (b 2 y) (c 3 z))
  (if (every null? l1)
      (reverse l2)
      (reorder-list-elements (map cdr l1) (cons (unzip1 l1) l2))))
   
#(define-markup-list-command (rows layout props args)
  (markup-list?)
  #:properties ((x-off '()))
  "Stacks the args horizontally relying on 'x-offs', returning multi-columns. 
The displacement of each column may be specified by overriding the
@var{x-off}-property. 
To avoid overlapping, every element of args should have an appropiate
line-width."
  (let* ((stils-list
           (map
             (lambda (arg) (interpret-markup-list layout props (list arg)))
             args))
         (new-listed-stils
           (reorder-list-elements
             (equal-length-sub-lsts stils-list point-stencil) '()))
         (line-width (ly:output-def-lookup layout 'line-width))
         (calculated-x-off
           (if (null? x-off)
               (map
                 (lambda (i) (* i (/ line-width (- (length args) 0))))
                 (iota (length args)))
               x-off))
         (list-of-stils-to-return
           (map
             (lambda (x)
               (apply ly:stencil-add
                 (map
                   (lambda (y e) (ly:stencil-translate-axis y e X))
                   x
                   calculated-x-off)))
             new-listed-stils)))     
    list-of-stils-to-return))
   
#(define-markup-list-command (paragraph layout props args)
  (markup-list?)
  #:properties ((par-indent '(0 . 0))
                (word-space))
  "Returns a markuplist with justified-lines applied.
Overriding par-indent '(<horiznatl> . <vertical>) will create some horizontal
space at begin and/or vertical space to the ptinted object before."
  (interpret-markup-list layout props
    #{
      \markuplist
        \justified-lines {
          \hspace #(+ (- word-space) (car par-indent))
          \vspace #(cdr par-indent)
          #args
        }
    #}))
   
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%

\markup
  \rounded-box
  \column {
    \vspace #2
    \fill-line \fontsize #6 \bold { "TABELLEN - SPALTEN" }
    \vspace #2
  }

%%%%
% 1
%%%%

\markup
  \column {
    \vspace #1
    \fill-line \fontsize #3 \bold { \rounded-box "1. EXAMPLE" \null }
    \vspace #1
  }
     
first-column =
\markuplist
  \center-align \dynamic
  \column-lines  {
    f
    ""
    mf
    ""
  }

second-column =
\markuplist
  \right-align \italic
  \column-lines   {
    Full
    ""
    Full
    ""
  }

third-column =
\markuplist
  \right-align
  \column-lines  {
    1
    ""
    2
    ""
  }

fourth-column =
\markuplist
  \left-align
  \column-lines  {
    \paragraph { When the Lord turn'd again the cap- | tivity of | Sion : }
   
    \override #'(par-indent . (3.5 . 0))
    \paragraph { then were we | like unto | them that | dream. }
   
    \override #'(par-indent . (0 . 1.2))
    \paragraph { Then was our mouth | fill'd with | laugh- }
   
    \override #'(par-indent . (3.5 . 0))
    \paragraph { ter, | and our | tongue with | joy. }
  }
 
fifth-column =
\markuplist
  \score-lines {
    \new Staff { \repeat unfold 20 c''1 }
    \layout {
      indent = 0
      line-width = 50
    }
  }
 
\markuplist
  \override #'(x-off . (0 11 16 18 78))
  %\override #'(baseline-skip . 5)
  %\box
  \rows {
    \first-column
    \second-column
    \third-column
    \fourth-column
    %\fifth-column
  }
 
%%%%
% 2
%%%% 
\markup
  \column {
    \vspace #3
    \fill-line \fontsize #3 \bold { \rounded-box "2. EXAMPLE" \null }
    \vspace #1
  }

#(define (my-lst amount)
  (map
    symbol->string
    (apply append
      (make-list amount
       '(Lorem ipsum dolor sit amet, consectetur adipisicing
         elit, sed do eiusmod tempor incididunt ut labore et dolore magna
         aliqua.  Ut enim ad minim veniam, quis nostrud exercitation ullamco
         laboris nisi ut aliquip ex ea commodo consequat.)))))

\markuplist
%\override #'(baseline-skip . 15)
%\column-lines
  \override #'(line-width . 35)
%  \override #'(x-off . (0 40 80))
  \rows  {
    \justified-lines #(my-lst 3)
    \justified-lines #(my-lst 6)
   
%    \score-lines {
%    \new Staff { \repeat unfold 100 c''1 \break }
%    \layout {
%    indent = 0
%    line-width = 40
%    }
%    }
  }
 

Gruß,
  Harm

mgd

  • Member
Re: Tabellen template
« Antwort #14 am: Mittwoch, 8. Juli 2015, 12:08 »
Du beeindruckst mich einmal mehr :)

Ich habe deinen Code in einen Psalm eingebaut. Er produziert ein prima Ergebnis. Die Unterschiede zu der aktuell von mir verwendeten Version sind zu minimal, als dass ich da entscheiden wollte, welche Fassung mir besser gefällt.

Insbesondere gefällt mir auch, dass diese Tabellen schön allgemein verwendbar sind (lies: ich habe das in meine private Snippetsammlung übernommen :) )

Was mir beim Arbeiten mit dieser Fassung weniger gut gefallen hat ist, dass die Information für die einzelnen Strophen in der Datei an mehreren Stellen verstreut vorliegt. Das ist beim Schreiben und Redigieren fehleranfällig, wie ich quasi sofort selbst habe bemerken können.

Unten angefügt meine aktuelle Version (Psalm-148.ly), die Fassung unter Verwendung von obigem allgemeinen Tabellenlayout (Psalm-148-v6.ly) sowie zwei includierte Dateien.

Liebe Grüße,
Michael