lilypond-user
[Top][All Lists]
Advanced

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

Re: How to display table of contents in two columns?


From: Reinhold Kainhofer
Subject: Re: How to display table of contents in two columns?
Date: Wed, 20 May 2009 22:54:18 +0200
User-agent: KMail/1.11.3 (Linux/2.6.28-11-generic; KDE/4.2.3; i686; ; )

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Mittwoch, 20. Mai 2009 21:42:53 schrieb fiëé visuëlle:
> Am 2009-05-20 um 19:13 schrieb Reinhold Kainhofer:
> > Actually, both don't really help, since the automatic table of
> > contents is one
> > large markup list and you don't know beforehand where it should flow
> > to the
> > second column (so you can't automatically split it in half, either).
> > What is
> > actually needed is a proper two-column text layout for lilypond with
> > automatic
> > text flow to the second column. Unfortunately, this is not
> > available...
>
> And if you implement all this into LilyPond, you re-created TeX...
>
> I'd suggest using LaTeX with lilypond-book or ConTeXt with its LilyPond
> module for stuff like that - at least that's what I do for my songbooks.

At least lilypond-book is not suited for page-wise scores, since the vertical 
layout is absolutely terrible. However, I have now switched to plain latex 
files for the full scores, where I use the pdfpages package (the \includepdf 
command) to include the PDF generated by lilypond. This way, I first run 
lilypond to create the raw score and then run latex to compile all desired 
files together to one large full score (including nice Cover page, title page, 
TOC, appendix, preface with biographies etc.), which can be immediately 
printed. For example (2.2MB!): 
http://www.fam.tuwien.ac.at/~reinhold/LilyPond/Tex_Schubert_StabatMater_D383_LongScore.pdf

If the score has multiple movements in the same liliypond output file, I have a 
lilypond function to write out the toc entries (with the correct page 
numbers), so I can then read it in into the addtotoc argument list of the 
\includepdf command.

In particular, I use Lilypond's \tocItem to build up the TOC and then write it 
out to NameOfTheLilypondInput.toc using the following function:

#(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))))
               (format #f "~a, section, 1, {~a}, ~a" page text label))))
             (formatted-toc-items (map format-line (toc-items)))
             (whole-string (string-join formatted-toc-items ",\n"))
             (output-name (ly:parser-output-name parser))
             (outfilename (format "~a.toc" output-name))
             (outfile (open-output-file outfilename)))
        (if (output-port? outfile)
            (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))
}

In my LaTex file I then include the score with 
\usepackage{pdfpages}
\includescore{nameofthescore}

where the \includescore is defined as:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  \includescore{PossibleExtension}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Read in the TOC entries for a PDF file from the corresponding .toc file.
% This requires some heave latex tweaking, since reading in things from a file
% and inserting it into the arguments of a macro is not (easily) possible

% Solution by Patrick Fimml on #latex on April 18, 2009:
% \readfile{filename}{\variable}
% reads in the contents of the file into \variable (undefined if file doesn't 
exist)
address@hidden
address@hidden
  address@hidden to address@hidden
  address@hidden@address@hidden
  address@hidden
    address@hidden
  \fi%
}
\def\readfile#1#2{%
  address@hidden %
  address@hidden
    \typeout{No TOC file #1 available!}%
  \else%
    \gdef#2{}%
    address@hidden
  \fi
  address@hidden
}%


\newcommand{\includescore}[1]{
  address@hidden@address@hidden
  address@hidden
  address@hidden@addtotoc}
  address@hidden
    address@hidden
  \else
    \edef\includeit{\noexpand\includepdf[pages=-,address@hidden
address@hidden
  \fi
}


BTW, all these functions are already in the development version of my 
OrchestralLily package (also the latex style file) at 
http://repo.or.cz/w/orchestrallily.git, but everything is still undocumented.


> I really appreciate to be able to typeset two-column lyrics on
> leadsheets, but for stuff that needs a t.o.c. I prefer a text engine.

Me, too.

Cheers,
Reinhold
- -- 
- ------------------------------------------------------------------
Reinhold Kainhofer, address@hidden, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFKFG36TqjEwhXvPN0RAh6NAKCvdUWPm2jUxKsWVLvIghLdPB8VygCeJwqZ
KzwEY04NdLzuhO9swZ2Fcf0=
=Xe0c
-----END PGP SIGNATURE-----




reply via email to

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