lilypond-usage: An example of a musicological document

 
 3.1 An example of a musicological document
 ==========================================
 
 Some texts contain music examples.  These texts are musicological
 treatises, songbooks, or manuals like this.  Such texts can be made by
 hand, simply by importing a PostScript figure into the word processor.
 However, there is an automated procedure to reduce the amount of work
 involved in HTML, LaTeX, Texinfo and DocBook documents.
 
    A script called ‘lilypond-book’ will extract the music fragments,
 format them, and put back the resulting notation.  Here we show a small
 example for use with LaTeX.  The example also contains explanatory text,
 so we will not comment on it further.
 
 Input
 -----
 
      \documentclass[a4paper]{article}
      
      \begin{document}
      
      Documents for \verb+lilypond-book+ may freely mix music and text.
      For example,
      
      \begin{lilypond}
      \relative c' {
        c2 e2 \tuplet 3/2 { f8 a b } a2 e4
      }
      \end{lilypond}
      
      Options are put in brackets.
      
      \begin{lilypond}[fragment,quote,staffsize=26,verbatim]
        c'4 f16
      \end{lilypond}
      
      Larger examples can be put into a separate file, and introduced with
      \verb+\lilypondfile+.
      
      \lilypondfile[quote,noindent]{screech-and-boink.ly}
      
      (If needed, replace @file{screech-and-boink.ly} by any @file{.ly} file
      you put in the same directory as this file.)
      
      \end{document}
 
 Processing
 ----------
 
 Save the code above to a file called ‘lilybook.lytex’, then in a
 terminal run
 
      lilypond-book --output=out --pdf lilybook.lytex
      _lilypond-book (GNU LilyPond) 2.18.2 _
      _Reading lilybook.lytex..._
      _...lots of stuff deleted..._
      _Compiling lilybook.tex..._
      cd out
      pdflatex lilybook
      _...lots of stuff deleted..._
      xpdf lilybook
      _(replace xpdf by your favorite PDF viewer)_
 
    Running ‘lilypond-book’ and ‘latex’ creates a lot of temporary files,
 which would clutter up the working directory.  To remedy this, use the
 ‘--output=DIR’ option.  It will create the files in a separate
 subdirectory ‘dir’.
 
    Finally the result of the LaTeX example shown above.(1)  This
 finishes the tutorial section.
 
 Output
 ------
 
 Documents for ‘lilypond-book’ may freely mix music and text.  For
 example,
 
 [image src="" alt="[image of music]" text="image of music"]
    Options are put in brackets.
 
      c'4 f16
      [image src="" alt="[image of music]" text="image of music"]
 
    Larger examples can be put into a separate file, and introduced with
 ‘\lilypondfile’.
 
      [image src="" alt="[image of music]" text="image of music"]
 
    If a ‘tagline’ is required, either default or custom, then the entire
 snippet must be enclosed in a ‘\book { }’ construct.
 
 \book{
   \header{
     title = "A scale in LilyPond"
   }
 
   \relative c' {
     c d e f g a b c
   }
 }
 [image src="" alt="[image of music]" text="image of music"]
    ---------- Footnotes ----------
 
    (1) This tutorial is processed with Texinfo, so the example gives
 slightly different results in layout.