It is one of two:
1. Work in LilyPond, use variables for repeating stuff + Put the LilyPond text/script in a text block (markup as you did). Or 2. The other way around: (As Lucas and Sam support ): Write in lyluatex as explained by them. I would go for that. You could also work with OOoLilyPond (to be used with open office or libreoffice). I don’t know how well it is supported now, at the time I used it, it was OK, for smaller documents. If you choose option 1, I surely am interested in how it works with larger projects. Regards, Eef Van: [email protected] <[email protected]> namens Marc Mouries <[email protected]> Datum: woensdag, 29 oktober 2025 om 04:48 Aan: Lucas Pinke <[email protected]> CC: lilypond-user mailinglist <[email protected]> Onderwerp: Re: markup to render music on left, show code on right) without typing music twice 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]<mailto:[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]<mailto:[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
