Is it possible to left-align the copyright information in Lilypond instead of the default center-alignment?
2 Answers
Taking a cue from this answer on the lilypond-user listserv, how about this?
\version "2.20.0"
#(define-markup-command (forceLeft layout props content) (markup?)
(interpret-markup layout props
#{
\markup \fill-line { #content \null }
#}
))
\header {
copyright = \markup \forceLeft "Left-aligned copyright"
tagline = \markup \forceLeft "Left-aligned tagline"
}
\score {
\new Staff <<
c4
>>
\layout { }
}
It's unclear if you want the copyright or the tagline to be left-aligned, but it can be anything; just precede it with \markup \forceLeft
and you'll be good to go.
Here is the relevant portion in the documentation:
Custom layout for headers and footers
To customize the placement of the text fields, use
either or both of the following \paper variables:
- oddHeaderMarkup
- evenHeaderMarkup
- oddFooterMarkup
- evenFooterMarkup
As of version 2.22.0
, line 172
of ./usr/share/lilypond/current/ly/titling-init.ly
shows where the copyright field is defined:
oddFooterMarkup = \markup {
\column {
\fill-line {
%% Copyright header field only on first page in each bookpart.
\on-the-fly #part-first-page \fromproperty #'header:copyright
}
\fill-line {
%% Tagline header field only on last page in the book.
\on-the-fly #last-page \fromproperty #'header:tagline
}
}
}
It is controlled by the \markup
instructions here, which is to print a single column with two fields, one of top of the other: a copyright, and a tagline. Both are instructed to \fill-line
, which is to evenly space itself out across the page (or other defined area).
You would want to change the instruction of the copyright to not use \fill-line
; as it happens, removing the surrounding \fill-line {
and }
will automatically move it to left-aligned on the page.
If you don't want to override global program defaults, copy and paste that oddFooterMarkup
definition into the \paper {}
block of the file you're compiling, and make the above change there.
Thus, you would end up with:
\header {
copyright = "This is left-aligned"
}
\paper {
oddFooterMarkup = \markup {
\column {
%% Copyright header field only on first page in each bookpart.
\on-the-fly #part-first-page \fromproperty #'header:copyright
\fill-line {
%% Tagline header field only on last page in the book.
\on-the-fly #last-page \fromproperty #'header:tagline
}
}
}
}
music = { d'1 }
\score {
\new Staff \music
}