openlilylib / scholarly

ScholarLY, a library for annotating LilyPond scores
GNU General Public License v3.0
24 stars 6 forks source link

Two editions from the same source #71

Open benjamingeer opened 4 years ago

benjamingeer commented 4 years ago

Hello again,

How should I make two editions from the same LilyPond source:

  1. a critical edition with scholarLY annotations indicated by colours in the score
  2. a performance edition printed only in black and white, and therefore without the annotation colours, and with different footnotes instead, as well as fingerings

I’m trying to do this with \tag but I can’t get it to work. In the attached small example, I have two tags, #'crit and #'perf, for content that is specific to one edition or the other. I want the note gis, to appear in both editions. In the critical edition, that note should have a green \criticalRemark. In the performance edition, the note should instead have a footnote (referring to the critical edition) and a fingering.

The way I’ve written it in the attached file, the critical edition (with \keepWithTag #'crit \removeWithTag #'perf) is rendered correctly. But in the performance edition (with \removeWithTag #'crit \keepWithTag #'perf), the note gis, is missing:

    \tag #'perf \footnote #'(-1 . -3)
      \markup { G\sharp or G\natural? See critical edition. }
      NoteHead
    \tag #'crit \criticalRemark \with {
      message = "A critical remark. Applies to the accidental"
      item = Accidental
    }
    gis,-\tag #'perf _3

I guessed that this is because the note is actually wrapped inside the \criticalRemark, so if the tag removes the \criticalRemark, it removes the note, too. So I tried using a post-event instead, like this:

    gis,-\tag #'crit \criticalRemark \with {
      message = "A critical remark. Applies to the accidental"
      item = Accidental
    }-\tag #'perf _3

But then the \criticalRemark doesn't produce any output.

The only way I can get it to work is to encode the note twice:

    \tag #'perf \footnote #'(-1 . -3)
      \markup { G\sharp or G\natural? See critical edition. }
      NoteHead
    \tag #'crit \criticalRemark \with {
      message = "A critical remark. Applies to the accidental"
      item = Accidental
    } gis,
    \tag #'perf gis,_3

But I would rather not encode the same note redundantly. Is there a better way?

A-Composer-One-Bar-of-Music.ly.zip

uliska commented 4 years ago

Disclaimer: I have never really liked \tag and its functionality. But the code of stylesheets.span, scholarly.annotate and scholarly.choice has explicitly been developed for this use case. Please allow me to simply refer you to the documentation chapters for now, and come back if that doesn't (fully) help you.

scholarLY annotations can also be directly be created from a span (see "Creating scholarLY Annotations" in the stylesheets manual), and they can implicitly create footnotes from their arguments (see "Creating Footnotes" in the same manual).

Making annotations invisible is a matter of \setOption scholarly.use-colors ##f. However, there's no way (currently) to switch off the generation of footnotes. This would be a good option to have (https://github.com/openlilylib/stylesheets/issues/6).

Finally (although not really relevant to your example) you can encode alternatives using \choice rather than using \tag, which may be conceptually cleaner and often more powerful. For example: each alternative encoding may carry their own annotations.

stylesheets.pdf scholarly.pdf

benjamingeer commented 4 years ago

Thanks, but I don't quite understand, because it looks like \choice is meant for choosing between readings, rather than to make different editions with the same reading. I ended up with this:

    \tag #'crit \footnote #'(-1 . -3)
      \markup { G\sharp or G\natural? See Comments. }
      NoteHead
    \tag #'perf \footnote #'(-1 . -3)
      \markup { G\sharp or G\natural? See the critical edition. }
      NoteHead

    \choice variants {
      \editorialMarkup lemma \with {
        ann-type = critical-remark
        source = "A"
        message = "Something about the accidental."
        item = Accidental
      }{
    gis,-\tag #'perf _3
      }
      \editorialMarkup reading \with {
        source = "B"
      }{ g, }
    }

I still had to use \tag to produce different footnotes for the different editions, and to deal with the fingering that only appears in the performance edition. Is it possible to handle those two things with \choice as well, or is \tag the only way? From the choice module documentation, I get the impression that maybe it could be done with custom Scheme functions.

I'd also be interested to know why you don't like \tag and its functionality.