#(define-markup-command (bookTitleMarkupCustom layout props)()
   (interpret-markup layout
     (prepend-alist-chain 'defaultmarkup #{
\markup {
  \override #'(baseline-skip . 3.5)
  \center-column {
    \override #`(font-name . ,songTitleFont) { \fontsize #songTitleSize \fromproperty #'header:title }
    \large \bold \fromproperty #'header:subtitle
    \smaller \bold \fromproperty #'header:subsubtitle
  }
}
                           #}
     (prepend-alist-chain 'songfilename (chain-assoc-get 'header:songfilename props "") props))
     (make-column-markup
       (list
         (make-vspace-markup (chain-assoc-get 'header:titletopspace props 0))
         (make-customEps-markup (chain-assoc-get 'header:titlesize props 3.5) "titel.eps")
     ))
))

#(define-markup-command (category-image layout props size category)(number? string?)
   (interpret-markup layout props
     (if noStandaloneOutput
       (make-epsfileref-markup Y size
         (category-image-path category))
       (make-epsfile-markup Y size
         (category-image-path category)))))

#(define showCategoryImages (if (defined? 'showCategoryImages) showCategoryImages #t))

#(define-markup-command (category-images layout props)()
   (interpret-markup layout props
     (if showCategoryImages
       (make-line-markup (map (lambda (category) (make-category-image-markup 5 category))
           (string-tokenize (chain-assoc-get 'header:categories props ""))))
       (make-null-markup))))

#(define pdf-encode (@@ (lily framework-ps) pdf-encode))
% PDF tags
#(define-markup-command (title-to-pdf-toc layout props title) (string?)
     (ly:make-stencil
      (list 'embedded-ps
             (ly:format
              "[/Action /GoTo /View [/XYZ -4 currentpagedevice /PageSize get 1 get 4 add null] /Title (~a) /OUT pdfmark" (pdf-encode title)))
      empty-interval empty-interval
      ;'(0 . 0) '(0 . 0)
      ))

#(define-markup-command (title-with-category-images layout props right)(boolean?)
   (interpret-markup layout props
     (let* ((title (chain-assoc-get 'header:title props ""))
            (starttext (chain-assoc-get 'header:starttext props #f))
            (pdfbookmark (if starttext (string-append starttext " | " title) title)))
     (if title
       (if right
         #{\markup { \title-to-pdf-toc #pdfbookmark \fill-line \general-align #Y #UP { \null \bookTitleMarkupCustom \category-images } } #}
         #{\markup { \title-to-pdf-toc #pdfbookmark \fill-line \general-align #Y #UP { \category-images \bookTitleMarkupCustom \null } } #})
      #{ \markup { " " } #})
     )))

\paper {
  bookTitleMarkup = \markup \null
  scoreTitleMarkup = \markup \null
  oddHeaderMarkup = \markup { \if \on-first-page-of-part \title-with-category-images ##t }
  evenHeaderMarkup = \markup { \if \on-first-page-of-part \title-with-category-images ##f }
}