Back to the schedule
Previous: Introducing N-Angulator
Next: telega.el and the Emacs community on Telegram

Typesetting Gregorian Chant with Emacs

Spencer King

Duration: 8:08

This talk was also streamed at an alternate time for APAC hours:

If you have questions and the speaker has not indicated public contact information on this page, please feel free to e-mail us at and we'll forward your question to the speaker.

00:00 Title 00:10 Roadmap 00:46 Gregorio 01:46 Metadata 02:08 gregorian-mode 02:48 Examples 06:49 Useful links


There are a variety of methods for typesetting gregorian chant scores and outputting high-quality sheet music. One of these is a tool called Gregorio, which integrates with LaTeX allowing scores to be cleanly inserted into other documents. All Gregorio files are plain text, allowing them to easily be shared with other users and managed with a version control system. In this talk, I will give a brief overview of the Gregorio tool and then show how it can be used in Emacs by typesetting a simple score. All code and examples will be made available to help new users get started with typesetting their own scores.


  • what are the advantages of this over lilypond?
  • do you know if there is something similar for byzantine notation?


  • 5-10 minutes: (brief description/outline)
    1. Introduction to chant music
    2. Introduction to Gregorio
    3. Example of typesetting a score in Emacs
    4. Code and example availability


Hello, everyone, my name is Spencer, and today I'm going to tell you all a little bit about how to typeset Gregorian chant sheet music using Emacs and a tool called Gregorio. Now I expect many, if not all, of you are unfamiliar with Gregorio, so we'll start off with a brief overview of the tool and the appropriate syntax. Next, I'll show you how I've automated some of the workflow using some Emacs Lisp functions which I've slowly been turning into a package called gregorian-mode. This will include some live typesetting examples to give you a better idea of how this all works. Finally, I'll share some information with you about how you can contribute to the package if you'd like, and how you can learn more about both Gregorio and gregorian-mode. And of course, all of the examples from this presentation today have been available online so you can review them all at your own pace.

[00:00:46.800] Gregorio is a tool that takes a gabc text file and compiles it into a LaTeX document. Gregorio is included by default with many LaTeX distributions, so you may already have it installed on your machine if you are a user of LaTeX. You can see here on the left an example of some input gabc text, and on the right, what the compiled score will look like. Looking at the gabc, we can see that it starts with the clef in parentheses, and then following this are the syllables of the lyrics and the corresponding notes in parentheses. For example, you can see that "EX," the first syllable, corresponds to a d note in parentheses there, and if you look at the right, you can easily verify that in the output. Now the last thing that I want to note here is that gabc files are all plain text, meaning they can easily be shared and can easily be tracked using your favorite version-control software. Since these are plain text, it's really pretty easy to integrate them into your existing workflows.

[00:01:46.079] The gabc format also supports many optional header fields for adding more information about your score. You can see all the supported fields listed below, along with some placeholder text. These fields are placed at the top of a file and are separated from the actual score by the two percent symbols seen at the bottom. After these symbols, you would have the lines of your score, similar to what you saw on the previous slide.

[00:02:08.560] As I said earlier, I've automated some of the score build steps using Emacs Lisp, and have started turning them into a package called gregorian-mode. This is my first Emacs package, so the code is rather messy at the moment, and for the most part is just a wrapper around the Gregorio build process. However, I have made some quality-of-life improvements to the score writing, and have some more planned for the future. You'll get to see some of that in some live examples in just a little bit.

[00:02:34.319] This package is not currently on MELPA at the time of recording, so if you want it, you will have to clone it manually from GitHub, but it is planned to be on MELPA in the near future. It just needs to go through a little more rigorous cleanup and testing.

[00:02:48.640] Now that we've covered the basics, let's take a look at an actual example. In this example, I'm assuming that my gregorian-mode package is installed. However, there is nothing in these steps that cannot be done manually by just following the official Gregorio documentation. So if you don't want to use a package, you can do all of this pretty easily on your own just by following their documentation.

[00:03:10.000] So first we'll open up Emacs, and in my case, I'm using the GUI version. So now that Emacs is open, we can call the function gregorian-create-new-gabc, and this will prompt us for a file name. So we need to pick out a name for our new score. So I think I'm going to go ahead and name ours emacsconf2021. So you can see here that we now have a new gabc file with all of the optional header fields added, and we can keep whichever of these that we would like, and we can modify them as needed. So for right now, all I'm going to change is this commentary; I'm going to update this source of words to emacsconf, and then at the bottom here, this is where we'd go ahead and add our score. So I don't have time today to typeset an entire score, and I think that would probably be rather boring for most of you to watch, so I'll just demonstrate very briefly with a few syllables and notes here. Okay, so now that we have our first few syllables and notes down, let's take a look at what our score actually looks like so far. So in order to do this, we're going to call the function gregorian-build, and what this function does is it takes this score and creates a LaTeX file for it and then goes ahead and compiles it into a PDF file that we can actually take a look at. And this does take a few seconds to run... and there it goes... so we can see here we have a new buffer with all of the output from that build process, but what we really care about is that PDF. So opening that up, you can see we have a very short score. So far we haven't done a whole lot, but if you go ahead and compare the score on the right with the file on the left, you can really pretty clearly see that those are, in fact, the lyrics that we wrote. You can see at the top right there, the source has, in fact, changed to emacsconf so at this point, we could go ahead and just keep adding more lines, more notes, and so on, and we would end up with a completed score.

[00:05:25.919] Now this process is great and all, but as you can imagine, more complex gabc files can quickly become pretty difficult to read with the notes and the syllables all bunched together. So to get around this, I've been playing around with an alternative format called a greg file. I have an example of that for you right here. So here we can see there are two files side-by-side: on the left, we have a gabc file, and then on the right, we have a greg file, both of them for the same score. Now in my opinion, the gabc on the left is really rather difficult to read at a glance. You can see there the notes and the syllables are really all grouped together pretty tightly. Looking at the greg on the right, you can see that all of the header information is the same, but the score itself is split across several lines. The idea here is that the notes and the corresponding syllables will be on separate lines, one after the other, to help improve readability.

[00:06:20.639] Now the greg file format is still a work-in-progress. It's really not set in stone at all, but already I think this is a pretty substantial quality-of-life improvement, and already gregorian-mode can, in fact, build scores from greg files as long as they follow the conventions that you see in this file here, and I'm planning to have that quite a bit more well-defined moving forward. Like I said, this is really still a work-in-progress.

[00:06:49.520] Finally, I want to end today by sharing some resources where you can learn more. First, you can learn more about the Gregorio project on their official website, and I have the link for that on this slide here, and this site has several detailed examples and a lot of additional information about the project and about chant notation in general. It goes into much more depth than what we covered in this presentation, and overall, it's really a fantastic resource for learning more about how to use the Gregorio software and more about the specifics of chant notation. Second, if you're interested in using or contributing to gregorian-mode, you can check out the project on GitHub with the link here on this slide. And if you're interested in helping out in any way, feel free to open an issue, and we can discuss further. And finally, all of the examples from today are also available on GitHub, and that's the last link on this slide, and you can feel free to experiment with these and really just use them in any way that you'd like. Now that's all that I had for today, but I do want to take a moment to thank you all for checking out my presentation, and I want to thank the organizers for giving me some time to speak with you all. I hope that this was at least a little bit interesting to some of you, and I hope that you all enjoy the rest of the conference. Thank you for your time today. captions by Hannah Miller

Back to the schedule
Previous: Introducing N-Angulator
Next: telega.el and the Emacs community on Telegram