[Top][All Lists]

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

Re: Importing the ToC into LaTeX

From: Thomas Morley
Subject: Re: Importing the ToC into LaTeX
Date: Thu, 26 May 2016 21:39:22 +0200

2016-05-26 20:42 GMT+02:00 Stefan-W. Hahn <address@hidden>:
> David Kastrup <dak <at> gnu.org> writes:
>> Stefan-W. Hahn <stefan.hahn <at> s-hahn.de> writes:
>> > Example of importing toc not working.
>> > Getting following error:
>> > (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty)))
>> > ! Undefined control sequence.
>> > \AM <at> findfile <at> i ...docname \relax \AM <at> IfFileExists
>> >                                                   {#1.#2}{\edef \AM <at>
> currentd...
>> > l.25 \includescore{test.toc}
>> >
>> >
>> > Didn't found an help.
>> > can anyone tell me what is wrong?
>> No, since nobody knows how you defined \includescore, presumably in your
>> own macros.sty.
> Sorry, was a little in a hurry.
> My original problem is, that I haven't found a way to print a book with
> lilypond where I begin with a front page, an empty page on the left and the
> first page on the right. If switching on double sided page 1 should get an
> extra amount of space on the left. But this is not working.

Not sure I understand, could you provide an example?

> So I tried to use lilypond-book. With this I have the problem to get a
> table of contents. After searching the internet I found:
> http://lilypond.org/doc/v2.18/Documentation/usage/sharing-the-table-of-contents
> (this is inside my macros.sty) together with a not
> mentioned but necessary
> \usepackage{ifmtarg}
> Today I come a little further and found out that the problem is
> the missing file. After adding a little debug the name I gave to the
> macro was not right. The macro wants to read a "_name.toc".

I rarely use lilypond-book, but maybe the following is of some help:

> With this there is another problem together with lilypond-book. The
> toc file is generated with a not predictable name, because it is
> generated. But to test it I copied the generated toc file.

Don't understand. The .toc-file gets its name from the .ly-file where
it is called.
If it's called in qwerty.ly it will be named qwerty.toc
That's coded in the function you linked to.

> This leads me to the next problem. the content of the toc file is
> not accepted by LaTeX. The toc file contains of lines such as:
> 1, section, 1, {(#<procedure line-markup (layout props args)> (Test
> piece))}, toc80

This output is created by the function. Though, you can change this ofcourse.
Below you'll find a little extended code.
Drawback: you'll need a recent devel-version. Back in 2.18.
markup->string didn't work sufficiently.
Also, it formats the output-lines a bit different (maybe you can
adjust this even more to fit your needs,) and prints to terminal how
the .toc-file is named.

\version "2.19.41"

#(define (oly:create-toc-file layout pages)
  (let* ((label-table (ly:output-def-lookup layout 'label-page-table)))
    (if (not (null? label-table))
      (let* ((format-line (lambda (toc-item)
             (let* ((label (car toc-item))
                    (text  (caddr toc-item))
                    (label-page (and (list? label-table)
                                     (assoc label label-table)))
                    (page (and label-page (cdr label-page))))
               ;;;; changed
               ;(format #f "~a, section, 1, {~a}, ~a" page text label)
               (format #f "Page ~a \t\t ~a" page (markup->string text) label)
             (formatted-toc-items (map format-line (toc-items)))
             (whole-string (string-join formatted-toc-items "\n"))
             (output-name (ly:parser-output-name))
             (outfilename (format "~a.toc" output-name))
             (outfile (open-output-file outfilename)))
        (if (output-port? outfile)
              ;;;; added
              (format #t "\n\tWriting to ~a" outfilename)
              (display whole-string outfile))
            (ly:warning (_ "Unable to open output file ~a for the TOC
information") outfilename))
        (close-output-port outfile)))))

\paper {
  #(define (page-post-process layout pages) (oly:create-toc-file layout pages))

\book {
    \bookpart { \markup "TITLE" }
    \bookpart { \markuplist \table-of-contents }
    \bookpart {
      \tocItem \markup \with-color #red "First score"
      \score {
          c'4  % ...
          \tocItem \markup \fontsize #3 "Some particular point in the
first score"
          d'4  % ...
    \bookpart {
      \tocItem \markup \with-color #cyan "Second score"
      \score {
          e'4 % ...


For further questions about _usage_ please use the user-list

reply via email to

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