Conditional printing of sections of a gabc file.

Skip to first unread message

Rob Leduc

Feb 7, 2022, 11:56:14 AMFeb 7
to Gregorio Users

I'm wondering if there is a way to use macros or some other built-in Gregorio TeX feature to conditionally "turn on" or "turn off" sections of a gabc file so they do or do not appear.

For example, in some documents a particular chant may occur on several occasions (in my own work, one responsory appears 4 times).  Sometimes this is with or without an alleluia for Paschaltide, or with or without a Gloria Patri at ending, or some other seasonal variation.  Or maybe an antiphon is doubled and so printed both before and after a long psalm, but you only want to print the EUOUAE in the copy at the beginning and suppress it at the end.

If such a feature existed, one could keep the chant in a single file and maybe turn portions on or off by setting a TeX \if switch to true or false and testing for that within the tex macro within the gabc file to turn on or off printing of a group of syllables. So set \ifalleluia to true if you want the alleluia portion to print for Paschaltide or set \ifgloria to true to get the Gloria Patri to print.  

This would be desirable in large works to cut down on possible typos and discrepancies by having a single electronic version of something used in multiple locations.

I tried to do this with the "comment" package, but that is trying to use a blunderbuss.  Comment will treat everything between \begin{comment} and \end{comment} as if it were a comment (e.g. line starts with %); but since it is an environment, it quite predictably falls afoul of parenthesis grouping in the Gregorio TeX internals when I try to use it. 

My basic example (without even getting to adding any \if switches yet) is below.  I've ignorantly tried the macros at every level ([em1], [gm1],[nm1]) or with <v> tags and it's a no go.

% !TEX TS-program = lualatex





% Hopefully only prints syllables on the note f without any weird extra spaces.
(c4) Test(f) this(f)  now([em1]h) and(h) hope(h) to([em2]f) continue(f) (::)

R. Padraic Springuel

Feb 8, 2022, 8:13:42 AMFeb 8
We don’t currently support this kind of sectioning, but it would make a reasonable feature request. 

Fr. Samuel, OSB
(R. Padraic Springuel)
St. Anselm’s Abbey 
4501 South Dakota Ave, NE
Washington, DC, 20017


On Feb 7, 2022, at 11:56 AM, Rob Leduc <> wrote:

Gregorio homepage:
Archives for the old mailing list:
To report a bug, please post to:
You received this message because you are subscribed to the Google Groups "Gregorio Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages