2

I posted a question on here about two different coding techniques on how to add a table of contents to a LilyPond Book. I am kind of stuck with the solution in the first example, since it gives me the possibility to add multiple table of contents into my book.


First Example (without dotted line):

#(define-markup-command (toc-line layout props label text)
  (symbol? markup?)
  (interpret-markup layout props
   (markup #:fill-line (text #:page-ref label "8" "?"))))

%Table of Contens
\label #'toc
\markup {
  \column {
    \large \fill-line { \null \bold \italic "Table Of Contents" \null }
    \toc-line #'toc "Table Of Contents"
    \toc-line #'firstPart "First Score"
    \toc-line #'secondPart "Second Score"
  }
}

\label #'firstPart
\label #'secondPart

enter image description here

(Reference: taken from the LilyPond Documetory)


Second Example (with dotted line):

\header { tagline = ##f }
\paper {
  tocItemMarkup = \tocItemWithDotsMarkup
}

\book {
  \markuplist \table-of-contents
  \tocItem \markup { Allegro }
  \tocItem \markup { Largo }
  \markup \null
}

enter image description here

(Reference: taken from the LilyPond Documetory)


My question is: How do I add dotted lines using the code in the first example, so I would get an output with dotted lines as shown in the second example?

I can draw a dotted line like this using a postscript:

\markup {
  \postscript #"0.3 setlinewidth 1 setlinecap [0 1] 0 setdash 1 1 moveto 60 0 rlineto stroke"
}

LilyPond Postscript dotted line

How can I add this postscript to fill the space between the text and the page number in the toc definition of the first example?

#(define-markup-command (toc-line layout props label text)
      (symbol? markup?)
      (interpret-markup layout props
       (markup #:fill-line (text #:page-ref label "8" "?"))))

This Project can be found here on GitHub.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.