]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/usage/lilypond-book.itely
Doc: clean up @file{} entries
[lilypond.git] / Documentation / usage / lilypond-book.itely
index 5bcd6668fc369e62679868963e4653f6d1d1bdc8..44b2dc0a265bfdea9608448476b8918a9b790ca2 100644 (file)
@@ -8,7 +8,7 @@
     Guide, node Updating translation committishes..
 @end ignore
 
-@c \version "2.12.0"
+@c \version "2.13.36"
 
 @c Note: keep this node named so that `info lilypond-book' brings you here.
 @node lilypond-book
@@ -52,6 +52,7 @@ documents.
 * Invoking lilypond-book::
 * Filename extensions::
 * lilypond-book templates::
+* Sharing the table of contents::
 * Alternate methods of mixing text and music::
 @end menu
 
@@ -84,7 +85,7 @@ For example,
 
 \begin{lilypond}
 \relative c' {
-  c2 g'2 \times 2/3 { f8 e d } c'2 g4
+  c2 e2 \times 2/3 { f8 a b } a2 e4
 }
 \end{lilypond}
 
@@ -99,8 +100,8 @@ Larger examples can be put into a separate file, and introduced with
 
 \lilypondfile[quote,noindent]{screech-boink.ly}
 
-(If needed, replace screech-boink.ly by any .ly file you put in the same
-directory as this file.)
+(If needed, replace @file{screech@/-boink@/.ly} by any @file{@/.ly} file
+you put in the same directory as this file.)
 
 \end{document}
 @end verbatim
@@ -108,7 +109,7 @@ directory as this file.)
 
 @subheading Processing
 
-Save the code above to a file called @file{lilybook.lytex}, then in a
+Save the code above to a file called @file{lilybook@/.lytex}, then in a
 terminal run
 
 @c keep space after @version{} so TeX doesn't choke
@@ -143,7 +144,7 @@ For example,
 
 @lilypond
 \relative c' {
-  c2 g'2 \times 2/3 { f8 e d } c'2 g4
+  c2 e2 \times 2/3 { f8 a b } a2 e4
 }
 @end lilypond
 
@@ -326,7 +327,7 @@ the number of systems you want in the output.
 
 @example
 \def\betweenLilyPondSystem#1@{
-    \ifnum##1<2\else\expandafter\endinput\fi
+    \ifnum#1<2\else\expandafter\endinput\fi
 @}
 @end example
 
@@ -408,7 +409,7 @@ Additionally, @code{@@lilypondversion} displays the current version
 of lilypond.
 
 When @command{lilypond-book} is run on it, this results in a Texinfo
-file (with extension @file{.texi}) containing @code{@@image} tags for
+file (with extension @file{@/.texi}) containing @code{@@image} tags for
 HTML, Info and printed output.  @command{lilypond-book} generates images
 of the music in EPS and PDF formats for use in the printed output, and
 in PNG format for use in HTML and Info output.
@@ -453,6 +454,7 @@ Music is entered using
 \key c \minor c4 es g2
 </lilypond>
 @end example
+
 @noindent
 @command{lilypond-book} then produces an HTML file with appropriate image
 tags for the music fragments:
@@ -468,13 +470,15 @@ are separated by a colon from the music, for example
 Some music in <lilypond relative=2: a b c/> a line of text.
 @end example
 
-
 To include separate files, say
 
 @example
 <lilypondfile @var{option1} @var{option2} ...>@var{filename}</lilypondfile>
 @end example
 
+For a list of options to use with the @code{lilypond} or
+@code{lilypondfile} tags, see @ref{Music fragment options}.
+
 Additionally, @code{<lilypondversion/>} displays the current version
 of lilypond.
 
@@ -488,7 +492,7 @@ of lilypond.
 
 For inserting LilyPond snippets it is good to keep the conformity of our
 DocBook document, thus allowing us to use DocBook editors, validation
-etc. So we don't use custom tags, only specify a convention based on the
+etc.  So we don't use custom tags, only specify a convention based on the
 standard DocBook elements.
 
 @subheading Common conventions
@@ -499,11 +503,11 @@ inline or not inline.  The snippet formatting options are always
 provided in the @code{role} property of the innermost element (see in
 next sections).  Tags are chosen to allow DocBook editors format the
 content gracefully.  The DocBook files to be processed with
-@command{lilypond-book} should have the extension @file{.lyxml}.
+@command{lilypond-book} should have the extension @file{@/.lyxml}.
 
 @subheading Including a LilyPond file
 
-This is the most simple case.  We must use the @file{.ly} extension for
+This is the most simple case.  We must use the @file{@/.ly} extension for
 the included file, and insert it as a standard @code{imageobject}, with
 the following structure:
 
@@ -543,8 +547,8 @@ the @code{programlisting} inside.
 
 @subheading Processing the DocBook document
 
-Running @command{lilypond-book} on our @file{.lyxml} file will create a
-valid DocBook document to be further processed with @file{.xml}
+Running @command{lilypond-book} on our @file{@/.lyxml} file will create a
+valid DocBook document to be further processed with @file{@/.xml}
 extension.  If you use
 @uref{http://@/dblatex@/.sourceforge@/.net@/,dblatex}, it will create a
 PDF file from this document automatically.  For HTML (HTML Help,
@@ -618,7 +622,7 @@ Since this is the default, @code{nofragment} is redundant normally.
 
 @item indent=@var{size}\@var{unit}
 Set indentation of the first music system to @var{size}, using
-@var{unit} as units. @var{unit} is one of the following strings:
+@var{unit} as units.  @var{unit} is one of the following strings:
 @code{cm}, @code{mm}, @code{in}, or @code{pt}.  This option affects
 LilyPond, not the text layout.
 
@@ -687,7 +691,7 @@ will be printed with a verbatim block like
 If you would like to translate comments and variable names in verbatim
 output but not in the sources, you may set the environment variable
 @code{LYDOC_LOCALEDIR} to a directory path; the directory should
-contain a tree of @file{.mo} message catalogs with @code{lilypond-doc}
+contain a tree of @file{@/.mo} message catalogs with @code{lilypond-doc}
 as a domain.
 
 @item addversion
@@ -712,7 +716,7 @@ Assuming the file @file{foo@/.ly} contains
 @end example
 
 @noindent
-and we have this in our Texinfo document @file{test.texinfo}
+and we have this in our Texinfo document @file{test@/.texinfo}
 
 @example
 @@lilypondfile[texidoc]@{foo.ly@}
@@ -727,7 +731,7 @@ lilypond-book --pdf --process="lilypond \
 @end example
 
 Most LilyPond test documents (in the @file{input} directory of the
-distribution) are small @file{.ly} files which look exactly like this.
+distribution) are small @file{@/.ly} files which look exactly like this.
 
 For localization purpose, if the Texinfo document contains
 @code{@@documentlanguage @var{LANG}} and @file{foo@/.ly} header
@@ -773,9 +777,9 @@ directory part of the file path is stripped.
 @section Invoking @command{lilypond-book}
 
 @command{lilypond-book} produces a file with one of the following
-extensions: @file{.tex}, @file{.texi}, @file{.html} or @file{.xml},
-depending on the output format.  All of @file{.tex}, @file{.texi} and
-@file{.xml} files need further processing.
+extensions: @file{@/.tex}, @file{@/.texi}, @file{@/.html} or @file{@/.xml},
+depending on the output format.  All of @file{@/.tex}, @file{@/.texi} and
+@file{@/.xml} files need further processing.
 
 @subheading Format-specific instructions
 
@@ -813,9 +817,9 @@ ps2pdf yourfile.ps
 @end example
 
 @noindent
-The @file{.dvi} file created by this process will not contain
+The @file{@/.dvi} file created by this process will not contain
  note heads.  This is normal; if you follow the instructions, they
-will be included in the @file{.ps} and @file{.pdf} files.
+will be included in the @file{@/.ps} and @file{@/.pdf} files.
 
 Running @command{dvips} may produce some warnings about fonts; these
 are harmless and may be ignored.  If you are running @command{latex} in
@@ -847,7 +851,7 @@ See the documentation of Texinfo for further details.
 Specify the document type to process: @code{html}, @code{latex},
 @code{texi} (the default) or @code{docbook}.  If this option is missing,
 @command{lilypond-book} tries to detect the format automatically, see
-@ref{Filename extensions}. Currently, @code{texi} is the same as
+@ref{Filename extensions}.  Currently, @code{texi} is the same as
 @code{texi-html}.
 
 @c This complicated detail is not implemented, comment it out -jm
@@ -915,7 +919,7 @@ useful if your document is processed with @command{xelatex}, for
 example.
 
 @itemx --left-padding=@var{amount}
-Pad EPS boxes by this much. @var{amount} is measured in millimeters,
+Pad EPS boxes by this much.  @var{amount} is measured in millimeters,
 and is 3.0 by default.  This option should be used if the lines of
 music stick out of the right margin.
 
@@ -971,6 +975,7 @@ selects the output format based on the input filename's extension.
 @item @strong{extension} @tab @strong{output format}
 @item
 @item @file{.html} @tab HTML
+@item @file{.htmly} @tab HTML
 @item @file{.itely} @tab Texinfo
 @item @file{.latex} @tab @LaTeX{}
 @item @file{.lytex} @tab @LaTeX{}
@@ -1126,7 +1131,7 @@ and so on.
 
 The fonts of snippets set with LilyPond will have to be set from
 inside
-of the snippet. For this you should read the AU on how to use
+of the snippet.  For this you should read the AU on how to use
 lilypond-book.
 
 \selectlanguage{ngerman}
@@ -1138,6 +1143,112 @@ unterst__tzt werden.
 @end verbatim
 
 
+@node Sharing the table of contents
+@section Sharing the table of contents
+
+These functions already exist in the OrchestralLily package:
+
+@example
+@url{http://repo.or.cz/w/orchestrallily.git}
+@end example
+
+For greater flexibility in text handling, some users prefer to
+export the table of contents from lilypond and read it into
+@LaTeX{}.
+
+@subsubheading Exporting the ToC from LilyPond
+
+This assumes that your score has multiple movements in the same lilypond
+output file.
+
+@smallexample
+#(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))
+@}
+@end smallexample
+
+@subsubheading Importing the ToC into LaTeX
+
+In LaTeX, the header should include:
+
+@c no, this doesn't require the smallexample, but since the other
+@c two blocks on this page use it, I figured I might as well
+@c user it here as well, for consistency. -gp
+@smallexample
+\usepackage@{pdfpages@}
+\includescore@{nameofthescore@}
+@end smallexample
+
+@noindent
+where @code{\includescore} is defined as:
+
+@smallexample
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \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)
+\newread\readfile@@f
+\def\readfile@@line#1@{%
+@{\catcode`\^^M=10\global\read\readfile@@f to \readfile@@tmp@}%
+\edef\do@{\noexpand\g@@addto@@macro@{\noexpand#1@}@{\readfile@@tmp@}@}\do%
+\ifeof\readfile@@f\else%
+\readfile@@line@{#1@}%
+\fi%
+@}
+\def\readfile#1#2@{%
+\openin\readfile@@f=#1 %
+\ifeof\readfile@@f%
+\typeout@{No TOC file #1 available!@}%
+\else%
+\gdef#2@{@}%
+\readfile@@line@{#2@}%
+\fi
+\closein\readfile@@f%
+@}%
+
+
+\newcommand@{\includescore@}[1]@{
+\def\oly@@fname@{\oly@@basename\@@ifmtarg@{#1@}@{@}@{_#1@}@}
+\let\oly@@addtotoc\undefined
+\readfile@{\oly@@xxxxxxxxx@}@{\oly@@addtotoc@}
+\ifx\oly@@addtotoc\undefined
+\includepdf[pages=-]@{\oly@@fname@}
+\else
+\edef\includeit@{\noexpand\includepdf[pages=-,addtotoc=@{\oly@@addtotoc@}]
+@{\oly@@fname@}@}\includeit
+\fi
+@}
+@end smallexample
+
+
 @node Alternate methods of mixing text and music
 @section Alternative methods of mixing text and music