Am Mi., 23. Juli 2025 um 19:33 Uhr schrieb Todd Hesla <[email protected]>:
>
> I'm using LilyPond 2.25.26.
>
> I'm trying to draw an arrow in \markup by first drawing a line for the arrow
> shaft--using either \draw-line or \path--and then drawing the arrowhead using
> \arrow-head. Unfortunately, both attempts result in a gap between the arrow
> shaft and the arrow head.
>
> Here is the code, showing both results side by side:
>
> \markup {
> \draw-line #'(2.0 . 0.0)
> \arrow-head #X #RIGHT ##t
> }
> \markup {
> \path #0.25 #'((lineto 2.0 0))
> \arrow-head #X #RIGHT ##t
> }
Doing \markup { foo bar } is equivalent to \markup \line { foo bar }.
The line-markup-command inserts some space between its elements. This
space is determined by `word-space`. Even elements with negative
extend are spaced this way. See:
\markup { \path #0.25 #'((lineto 2.0 0)) \path #0.25 #'((lineto -3.0 0)) }
Exceptions are h/vspace-markup-commands.
You now could reduce the ẁord-space` to zero. Though, we have a
built-in markup-command (with even more features) doing so.
Alas, you'll notice still a gap, due to the actual printing of the
arrow-head, better visible with unfilled arrow-head:
\markup \concat { \draw-line #'(2 . 0) \arrow-head #X #RIGHT ##f }
Could be cured by inserting negative space (hspace-markup, see above):
\markup \concat { \draw-line #'(2 . 0) \hspace #-1 \arrow-head #X #RIGHT ##f }
Or you could use \combine or \overlay:
\markup
\combine
\draw-line #'(2 . 0)
\translate #'(2 . 0) \arrow-head #X #RIGHT ##f
\markup
\overlay {
\draw-line #'(2 . 0)
\translate #'(2 . 0) \arrow-head #X #RIGHT ##f
}
>
> I tried to eliminate the gap by "moving back" a little before drawing the
> arrow
> head, but that didn't work either:
"moving back" is the way to go, but not applied to the line, but to
the arrow-head (see above).
>
> \markup {
> \path #0.25 #'((lineto 2.0 0))
> \arrow-head #X #RIGHT ##t
> }
> \markup {
> \path #0.25 #'((lineto 2.0 0) (rlineto -1.0 0))
> \arrow-head #X #RIGHT ##t
> }
>
> The "rlineto" command doesn't seem to even have been executed at all.
(rlineto -1.0 0) _is_ executed, but going back on the already printed
line will not change the extent. Why should it?
You could change the dimensions of the line:
\markup {
\with-dimensions #'(0 . 1) #'(-0.125 . 0.125)
\path #0.25 #'((lineto 2.0 0))
\arrow-head #X #RIGHT ##f
}
This is weird, though.
> If I
> understood how these drawing commands work--including how the reference point
> changes with each command, and where exactly _is_ the reference point for an
> "\arrow-head"--I might be able to solve the problem.
Below some code summarizing above, also displaying the reference points:
#(define-markup-command (print-zero-point layout props arg) (markup?)
(let* ((stil (interpret-markup layout props arg))
(y-ext (ly:stencil-extent stil Y))
(x-ext (ly:stencil-extent stil X))
(dot-stil
(centered-stencil
(stencil-with-color
(ly:font-get-glyph
(ly:paper-get-font
layout
(cons '((font-encoding . fetaMusic) (font-size . -4)) props))
"dots.dot")
red)))
(dot
(if (and (interval-sane? y-ext) (interval-sane? x-ext))
dot-stil
empty-stencil)))
(ly:stencil-add stil dot)))
\markup
\column {
\concat
\print-zero-point {
\draw-line #'(2.0 . 0.0) \arrow-head #X #RIGHT ##f
}
\concat
\print-zero-point {
\draw-line #'(2.0 . 0.0) \hspace #-1.05 \arrow-head #X #RIGHT ##f
}
\combine
\print-zero-point \draw-line #'(2 . 0)
\translate #'(2 . 0) \print-zero-point \arrow-head #X #RIGHT ##f
\overlay {
\print-zero-point \draw-line #'(2 . 0)
\translate #'(2 . 0) \print-zero-point \arrow-head #X #RIGHT ##f
}
\line
\print-zero-point {
\with-dimensions #'(0 . 0.4) #'(-0.1 . 0.1)
\draw-line #'(2.0 . 0.0)
\arrow-head #X #RIGHT ##f
}
}
> But so far I've been
> unable to find any documentation that explains this.
Apart from the reference points (and you don't need to know to get the
work done) its all documented.
Mostly in the doc-strings of the markup-commands, see NR Appendix A
Markup commands.
>
> I'd be very grateful for any insights/clarification that the community can
> offer.
>
> Thanks!
>
> --
> Todd Hesla
> Minneapolis, Minnesota
>
HTH,
Harm