A large project may be split up into separate files. To refer to another file, use
\include "otherfile.ly"
The line \include "otherfile.ly"
is equivalent to pasting the
contents of otherfile.ly into the current file at the place
where the \include
appears. For example, in a large
project you might write separate files for each instrument part
and create a “full score” file which brings together the
individual instrument files. Normally the included file will
define a number of variables which then become available
for use in the full score file. Tagged sections can be
marked in included files to assist in making them usable in
different places in a score, see Different editions from one source.
Files in the current working directory may be referenced by
specifying just the file name after the \include
command.
Files in other locations may be included by giving either a full
path reference or a relative path reference (but use the UNIX
forward slash, /, rather than the DOS/Windows back slash, \, as the
directory separator.) For example, if stuff.ly is located
one directory higher than the current working directory, use
\include "../stuff.ly"
or if the included orchestral parts files are all located in a subdirectory called parts within the current directory, use
\include "parts/VI.ly" \include "parts/VII.ly" ... etc
Files which are to be included can also contain \include
statements of their own. These second-level
\include
statements are not interpreted until they have
been brought into the main file, so the file names they specify
must all be relative to the directory containing the main file,
not the directory containing the included file.
Files can also be included from a directory in a search path specified as an option when invoking LilyPond from the command line. The included files are then specified using just their file name. For example, to compile main.ly which includes files located in a subdirectory called parts by this method, cd to the directory containing main.ly and enter
lilypond --include=parts main.ly
and in main.ly write
\include "VI.ly" \include "VII.ly" ... etc
Files which are to be included in many scores may be placed in
the LilyPond directory ../ly. (The location of this
directory is installation-dependent - see of information
Other sources of information). These files can then be included simply by
naming them on an \include
statement. This is how the
language-dependent files like english.ly are included.
LilyPond includes a number of files by default when you start
the program. These includes are not apparent to the user, but the
files may be identified by running lilypond --verbose
from
the command line. This will display a list of paths and files that
LilyPond uses, along with much other information. Alternatively,
the more important of these files are discussed in sources of information
Other sources of information. These files may be edited, but changes to
them will be lost on installing a new version of LilyPond.
Some simple examples of using \include
are shown in
Scores and parts.
Learning Manual: Other sources of information, Scores and parts.
If an included file is given a name which is the same as one in LilyPond's installation files, LilyPond's file from the installation files takes precedence.
This page is for LilyPond-2.11.58 (development-branch).
Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.
Your suggestions for the documentation are welcome.