Jump to content

Aligning objects created with the \mark command (obsolete in 2.23)

From LilyPond wiki
Revision as of 18:26, 14 November 2025 by Jean Abou Samra (talk | contribs) (Import snippet from LSR)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

By default the \mark command centers objects over a bar line. This behavior can be modified to align at right or left.

This snippet is less necessary starting from LilyPond version 2.23.14, where the \textMark and \textEndMark commands have been introduced as an alternative to \mark used with markup. To obtain a left-aligned text mark, use \textMark, and \textEndMark for a right-aligned mark. In most cases, this interface is enough. If you would like to fine-tune the alignment nevertheless, you can still use the override in this snippet, replacing RehearsalMark with TextMark.

Furthermore, using self-alignment-X is explained multiple times in NR. Thus I unapprove it. --Harm

\version "2.24.0"

\relative c' {
  c1 \mark "(Center)"
  c1
  \once \override Score.RehearsalMark.self-alignment-X = #LEFT
  \mark "(Left)"
  % In 2.23.14 and later, do this instead:
  % \textMark "(Left)"
  c4 c c c
  c4 c c c
  \once \override Score.RehearsalMark.self-alignment-X = #RIGHT
  \mark "(Right)"
  % In 2.23.14 and later, do this instead:
  % \textEndMark "(Right)"
  c1
}