Thanks for the answer and suggestion. If possible I'd like to keep things
simple and not have to deal with the installation and learning curve of
other software, even if i know how to use LateX.

On Tue, Oct 28, 2025 at 11:35 PM Lucas Pinke <[email protected]> wrote:

> I guess you can write that only in Lilypond. Markups' column and verbatim
> could work, but I'd rather go with writing everything on a lualatex
> document and using the lyluatex package. Specially because you are not
> writing a score, per se, but a document.
>
> Em ter., 28 de out. de 2025, 23:29, Marc Mouries <[email protected]>
> escreveu:
>
>> Hi all,
>> I’m building a visual guide (“How to write music for violin with
>> LilyPond”) for my violin friends and I’d like each example line to look
>> like this:
>>
>>    -
>>
>>    *Left:* rendered staff (the result)
>>    -
>>
>>    *Middle:* small arrow
>>    -
>>
>>    *Right:* the *LilyPond source text* that produced the staff (wrapped,
>>    typewriter font)
>>
>> I’d like to define helper markup commands so I can write compact examples
>> and (ideally) avoid repeating the same fragment twice.
>>
>> If anyone has ideas, best practices, or knows of an existing helper or
>> snippet that does this, I’d be super grateful!
>>
>> Thanks so much,
>> Marc
>>
>>
>> Here’s what I’ve tried so far:
>>
>>
>> \version "2.24.4"
>>
>> % --- Helper: render music inside markup (no % inside the Scheme form) ---
>> #(define-markup-command (writeMusic layout props music) (ly:music?)
>>   (let* ((score (ly:make-score music))
>>          (lydef (ly:output-def-clone $defaultlayout)))
>>     (ly:score-add-output-def! score lydef)
>>     (interpret-markup layout props (markup #:score score))))
>>
>> % --- Example row: left = music object, right = code string  ---
>> #(define-markup-command (example_A layout props mus codestr)
>>   (ly:music? string?)
>>   (interpret-markup layout props
>>     #{
>>       \markup \fill-line {
>>         \column { \writeMusic #mus }
>>         \column { \typewriter "⇨" }
>>         \column { \typewriter \wordwrap-string #codestr }
>>       }
>>     #}))
>>
>>
>> #(define-markup-command (example_B layout props mus) (ly:music?)
>>   (let ((musicAsString (format #f "~S" mus)))
>>     (interpret-markup layout props
>>       #{
>>         \markup \fill-line {
>>           \column { \writeMusic #mus }
>>           \column {  "=>" }
>>           \column { \typewriter  #musicAsString  }
>>         }
>>       #})))
>>
>> % ====== Function example_A forces to type music TWICE ======
>> example_bowing = \relative c'' { c4(\downbow d) e(\upbow f) }
>> \markup \example_A #example_bowing "c''4(\\downbow d) e(\\upbow f)"
>>
>> % ====== Function example_B shows scheme code and not lilypond music
>> notes ======
>> \markup \example_B #example_bowing
>>
>>

-- 
-- Marc

Reply via email to