<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!-- header_tag --> <html lang="en"> <head> <title>Style sheets - GNU LilyPond Learning Manual</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="description" content="GNU LilyPond Learning Manual"> <meta name="generator" content="makeinfo 4.11"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Suggestions-for-writing-LilyPond-input-files.html#Suggestions-for-writing-LilyPond-input-files" title="Suggestions for writing LilyPond input files"> <link rel="prev" href="Saving-typing-with-variables-and-functions.html#Saving-typing-with-variables-and-functions" title="Saving typing with variables and functions"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1999--2007 by the authors Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections. A copy of the license is included in the section entitled ``GNU Free Documentation License''. --> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } hr { border:0; height:1; color: #000000; background-color: #000000; } /* hr { border: none; height: 1px; color: #666666; background-color: #666666; } body { border-left: 1px solid #666666; border-right: 1px solid #666666; color: #332d28; margin-right: auto; margin-left: auto; width: 60em; list-style-type: square; font-family: Arial,Helvetica,sans-serif; padding-right: 1em; padding-left: 1em; } a { border-bottom: 1px dashed #344242; text-decoration: none; color: #344242; } a:link { text-decoration: none; } a:visited { border-bottom: 1px dashed #666666; color: #666666; } a:active { border-bottom: 1px solid #00cccc; color: #00cccc; } a:hover { border-bottom: 1px solid #1d7b85; color: #1d7b85; } blockquote { border: 1px solid #cccccc; padding: 3px; width: 40em; } .node { border-left: 1px solid #666666; margin: -0.5em 0px 1em; padding: 2px 1px 0px; font-style: italic; } .node a { border: none; text-decoration: underline; font-style: normal; font-weight: bold; } .verbatim { font-family: "Courier New",Courier,monospace; } .unnumberedsubsubsec { font-size: large; color: #1d7b85; } .subsubheading { font-size: large; color: #3b220d; } .contents { border: 1px dashed #339999; margin: 3px 2em; list-style-type: square; padding-right: 1em; width: 40em; background-color: #fcfff9; } .contents a { border-bottom: 1px dashed #423d34; text-decoration: none; color: #423d34; } .contents a:visited { border-bottom: 1px dashed #666666; color: #666666; } .contents a:active { border-bottom: 1px solid #f0d86d; color: #f0d86d; } .contents a:hover { border-bottom: 1px solid #3b220d; color: #3b220d; } .menu { border-left: 1px dashed #339999; margin: 3px 2em 1em; list-style-type: square; padding-left: 1.4em; width: 40em; } .unnumbered { } h2 { font-size: x-large; color: #1d7b85; } */ --></style> </head> <BODY BGCOLOR=WHITE TEXT=BLACK> <div class="node"> <p> <a name="Style-sheets"></a> Previous: <a rel="previous" accesskey="p" href="Saving-typing-with-variables-and-functions.html#Saving-typing-with-variables-and-functions">Saving typing with variables and functions</a>, Up: <a rel="up" accesskey="u" href="Suggestions-for-writing-LilyPond-input-files.html#Suggestions-for-writing-LilyPond-input-files">Suggestions for writing LilyPond input files</a> <hr> </div> <h4 class="subsection">5.1.5 Style sheets</h4> <p>The output that LilyPond produces can be heavily modified; see <a href="Tweaking-output.html#Tweaking-output">Tweaking output</a>, for details. But what if you have many input files that you want to apply your tweaks to? Or what if you simply want to separate your tweaks from the actual music? This is quite easy to do. <p>Let's look at an example. Don't worry if you don't understand the parts with all the <code>#()</code>. This is explained in <a href="Advanced-tweaks-with-Scheme.html#Advanced-tweaks-with-Scheme">Advanced tweaks with Scheme</a>. <blockquote> <pre class="verbatim"> mpdolce = #(make-dynamic-script (markup #:hspace 1 #:translate (cons 5 0) #:line(#:dynamic "mp" #:text #:italic "dolce" ))) tempoMark = #(define-music-function (parser location markp) (string?) #{ \once \override Score . RehearsalMark #'self-alignment-X = #left \once \override Score . RehearsalMark #'extra-spacing-width = #'(+inf.0 . -inf.0) \mark \markup { \bold $markp } #}) \relative c'' { \tempo 4=50 a4.\mpdolce d8 cis4--\glissando a | b4 bes a2 \tempoMark "Poco piu mosso" cis4.\< d8 e4 fis | g8(\! fis)-. e( d)-. cis2 } </pre> <p> <a href="../15/lily-e5e30e86.ly"> <img align="middle" border="0" src="../15/lily-e5e30e86.png" alt="[image of music]"> </a> </p> </blockquote> <p>There are some problems with overlapping output; we'll fix those using the techniques in <a href="Moving-objects.html#Moving-objects">Moving objects</a>. But let's also do something about the <code>mpdolce</code> and <code>tempoMark</code> definitions. They produce the output we desire, but we might want to use them in another piece. We could simply copy-and-paste them at the top of every file, but that's an annoyance. It also leaves those definitions in our input files, and I personally find all the <code>#()</code> somewhat ugly. Let's hide them in another file: <pre class="example">%%% save this to a file called "definitions.ly" mpdolce = #(make-dynamic-script (markup #:hspace 1 #:translate (cons 5 0) #:line(#:dynamic "mp" #:text #:italic "dolce" ))) tempoMark = #(define-music-function (parser location markp) (string?) #{ \once \override Score . RehearsalMark #'self-alignment-X = #left \once \override Score . RehearsalMark #'extra-spacing-width = #'(+inf.0 . -inf.0) \mark \markup { \bold $markp } #}) </pre> <p>Now let's modify our music (let's save this file as <samp><span class="file">"music.ly"</span></samp>). <!-- We have to do this awkward example/lilypond-non-verbatim --> <!-- because we can't do the \include stuff in the manual. --> <pre class="example">\include "definitions.ly" \relative c'' { \tempo 4=50 a4.\mpdolce d8 cis4--\glissando a | b4 bes a2 \once \override Score.RehearsalMark #'padding = #2.0 \tempoMark "Poco piu mosso" cis4.\< d8 e4 fis | g8(\! fis)-. e( d)-. cis2 } </pre> <blockquote> <p> <a href="../11/lily-5b03168d.ly"> <img align="middle" border="0" src="../11/lily-5b03168d.png" alt="[image of music]"> </a> </p> </blockquote> <p>That looks better, but let's make a few changes. The glissando is hard to see, so let's make it thicker and closer to the note heads. Let's put the metronome marking above the clef, instead of over the first note. And finally, my composition professor hates ‘C’ time signatures, so we'd better make that ‘4/4’ instead. <p>Don't change <samp><span class="file">music.ly</span></samp>, though. Replace our <samp><span class="file">definitions.ly</span></samp> with this: <pre class="example">%%% definitions.ly mpdolce = #(make-dynamic-script (markup #:hspace 1 #:translate (cons 5 0) #:line( #:dynamic "mp" #:text #:italic "dolce" ))) tempoMark = #(define-music-function (parser location markp) (string?) #{ \once \override Score . RehearsalMark #'self-alignment-X = #left \once \override Score . RehearsalMark #'extra-spacing-width = #'(+inf.0 . -inf.0) \mark \markup { \bold $markp } #}) \layout{ \context { \Score \override MetronomeMark #'extra-offset = #'(-9 . 0) \override MetronomeMark #'padding = #'3 } \context { \Staff \override TimeSignature #'style = #'numbered } \context { \Voice \override Glissando #'thickness = #3 \override Glissando #'gap = #0.1 } } </pre> <blockquote> <p> <a href="../f4/lily-44dde205.ly"> <img align="middle" border="0" src="../f4/lily-44dde205.png" alt="[image of music]"> </a> </p> </blockquote> <p>That looks nicer! But now suppose that I want to publish this piece. My composition professor doesn't like ‘C’ time signatures, but I'm somewhat fond of them. Let's copy the current <samp><span class="file">definitions.ly</span></samp> to <samp><span class="file">web-publish.ly</span></samp> and modify that. Since this music is aimed at producing a pdf which will be displayed on the screen, we'll also increase the overall size of the output. <pre class="example">%%% definitions.ly mpdolce = #(make-dynamic-script (markup #:hspace 1 #:translate (cons 5 0) #:line( #:dynamic "mp" #:text #:italic "dolce" ))) tempoMark = #(define-music-function (parser location markp) (string?) #{ \once \override Score . RehearsalMark #'self-alignment-X = #left \once \override Score . RehearsalMark #'extra-spacing-width = #'(+inf.0 . -inf.0) \mark \markup { \bold $markp } #}) #(set-global-staff-size 23) \layout{ \context { \Score \override MetronomeMark #'extra-offset = #'(-9 . 0) \override MetronomeMark #'padding = #'3 } \context { \Staff } \context { \Voice \override Glissando #'thickness = #3 \override Glissando #'gap = #0.1 } } </pre> <blockquote> <p> <a href="../66/lily-c4610079.ly"> <img align="middle" border="0" src="../66/lily-c4610079.png" alt="[image of music]"> </a> </p> </blockquote> <p>Now in our music, I simply replace <code>\include "definitions.ly"</code> with <code>\include "web-publish.ly"</code>. Of course, we could make this even more convenient. We could make a <samp><span class="file">definitions.ly</span></samp> file which contains only the definitions of <code>mpdolce</code> and <code>tempoMark</code>, a <samp><span class="file">web-publish.ly</span></samp> file which contains only the <code>\layout</code> section listed above, and a <samp><span class="file">university.ly</span></samp> file which contains only the tweaks to produce the output that my professor prefers. The top of <samp><span class="file">music.ly</span></samp> would then look like this: <pre class="example">\include "definitions.ly" %%% Only uncomment one of these two lines! \include "web-publish.ly" %\include "university.ly" </pre> <p>This approach can be useful even if you are only producing one set of parts. I use half a dozen different ‘style sheet’ files for my projects. I begin every music file with <code>\include "../global.ly"</code>, which contains <pre class="example">%%% global.ly \version "2.11.57"<!-- /@w --> #(ly:set-option 'point-and-click #f) \include "../init/init-defs.ly" \include "../init/init-layout.ly" \include "../init/init-headers.ly" \include "../init/init-paper.ly" </pre> <!-- footer_tag --><br><hr> <div class="node"> <p> Previous: <a rel="previous" accesskey="p" href="Saving-typing-with-variables-and-functions.html#Saving-typing-with-variables-and-functions">Saving typing with variables and functions</a>, Up: <a rel="up" accesskey="u" href="Suggestions-for-writing-LilyPond-input-files.html#Suggestions-for-writing-LilyPond-input-files">Suggestions for writing LilyPond input files</a> </div> <div style="background-color: #e8ffe8; padding: 2; border: #c0ffc0 1px solid;"> <p> <font size="-1"> This page is for LilyPond-2.11.57 (development-branch). <br> <address> Report errors to <a href="http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs">http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs</a>. </address> <br> Your <a href="http://lilypond.org/web/devel/participating/documentation-adding">suggestions for the documentation</a> are welcome. </font> </p> </div> <P> Other languages: <a href="Style-sheets.fr.html">français</a>, <a href="Style-sheets.es.html">español</a>, <a href="Style-sheets.de.html">deutsch</a>. <BR> </P> </BODY></html>