4

In LilyPond, is there a way to highlight one or several bars with a colored box? Similar to this: https://musescore.org/en/node/220071

If it is not possible, it could be done once it has been converted to pdf, with some pdf tuning package. In that case, I would need the start/end "coordinates" of the bar to highlight. Is it possible to obtain this?

1 Answer 1

7

With version v2.23, there is a way to highlight passages.

This can be done with the \staffHighlight command, which takes a colour as an argument.

See: 1.7.1 Inside the staff - Staff highlights

3
  • Thank you! For my particular application, it is possible that the same passage may need to be highlighted with two colors. I would like to get the intersection region to have both colors overlapping (with some opacity). Something like: drive.upm.es/s/QFc58j7vbx7hjiu I think this is not achievable by setting the parameter \staffHighlightsetting. Isn't it?
    – Kikolo
    Nov 10, 2022 at 13:28
  • @Kikolo Not exactly, because each new \staffHighlight implicitly writes \stopStaffHighlight. But, you could easily fake it by choosing an in-between colour for the overlapping region. Nov 10, 2022 at 16:20
  • Thank you, I thought so. However, for my project I would find it much easier to simply set some rectangles in the pdf once it is generated. I will create a new question for this
    – Kikolo
    Nov 11, 2022 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.