Lilypond: sheets with and without tabulature from a single file
tl;dr
Switch from creating notation with and without tabulature from a single file by using custom functions and lilypond includes.
Source Example usage Example output
Motivation
You want to generate sheets for bass (or guitar) notation and need an easy way to provide sheets both with and without tabulature with minimum hassle.
Solution
Write a single lilypond file that includes tabulature and regular notation. Use custom functions to define tabulature. Have two includes, one which expands the tabulature notation to nothing, one which expands it to tabulature. Switch from one to the other by changing the includes.
This will create a sheet without tabs:
// at the beginning of your score
%\include "includes/tabs_engraved.ily"
\include "includes/no_tabs_engraved.ily"
This will create a sheet with tabs:
// at the beginning of your score
\include "includes/tabs_engraved.ily"
%\include "includes/no_tabs_engraved.ily"
Define your score like this, using tabs
for the tabulature staffand \minFret
for controlling fret numbers.
bass = \relative c, {
% notate the music here, including tabulature specific commands like \set TabStaff.minimumFret = 5
% the include files provide a shortcut for this called minFret
% so don't actually use \set TabStaff.minimumFret = 5
% but use \minFret #5 instead
}
\score {
<<
\new Voice {
\clef "bass_8"
\key c \major
\bass
}
% the include files provide a function called tabs
% use #bass-tuning for four string bass or #bass-five-string-tuning for five string bass
\tabs #bass-five-string-tuning { \bass}
>>
}
For all of this to work, the included files need to be found by lilypond. This is simply a matter of proper directory layout. The examples above assume a layout like this:
your_notation_file.ly
includes/tabs_engraved.ily
includes/no_tabs_engraved.ily