% !TEX root = GregorioRef.tex
% !TEX program = LuaLaTeX+se
%
% Copyright (C) 2006-2021 The Gregorio Project (see CONTRIBUTORS.md)
%
% This file is part of Gregorio.
%
% Gregorio is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Gregorio is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Gregorio.  If not, see <http://www.gnu.org/licenses/>.
%
\section{User Controls}

These functions are available to the user to customize elements of the
score which cannot be controlled from the gabc file. They can be added
to any \verb=.tex= file. Do not add them to any \verb=.gtex= or
\verb=.gabc= file.

\subsection{Using the Package}

To use the Gregorio\TeX\ package in a \LaTeX\ document, include \verb=\usepackage{gregoriotex}=
in the document preamble. This macro has the following form:

\macroname{\textbackslash usepackage}{[\optional{(options)}]\{gregoriotex\}}{gregoriotex.sty}

The optional arguments are:

\bigskip\rowcolors{1}{lightgray}{lightgray}
\begin{tabular}{lp{10cm plus .5cm}}
	Argument & Description \\
	\hline
	\texttt{debug} & Debug messages will be printed to the output log.  Can also be specified as \verb:debug={<types>}:, in which case only messages of the categories (see \nameref{DebugCategory}) listed will be printed to the output log.\\
	\hline
	\texttt{nevercompile} & Default. The classic behavior of Gregorio\TeX. The user is %
		responsible for compiling gabc scores into gtex files.\\
	\texttt{autocompile} & Gregorio\TeX\ will automatically compile gtex files from gabc %
		files when necessary. If the gabc has been modified, or the %
		gtex has an outdated version, or the gtex file does not exist, %
		THEN Gregorio\TeX\ will compile a new gtex file.\\
	\texttt{forcecompile} & Gregorio\TeX\ will compile all scores from their gabc files.\\
	\hline
	\texttt{allowdeprecated=false} & Force all deprecated commands to raise a package error %
		rather than a warning. This allows the user to ensure that their file is %
		compliant with the current version of Gregorio\TeX.\\
\end{tabular}\bigskip

\textbf{Note:} \verb=nevercompile=, \verb=autocompile=, and
\verb=forcecompile= conflict with eachother. Only one should be
specified in the options list.\bigskip

To use the package in a Plain \TeX\ document, include \verb=\input gregoriotex.tex= near the top of the document (the area which would correspond to the preamble in \LaTeX).

To use the \texttt{debug} option in Plain \TeX, you'll need to define \verb=\gre@debug= manually as a string listing the kinds of messages you want printed (or as \verb=all= if you want all messages printed).

To use the \texttt{allowdeprecated=false} option, you'll need \verb=\gre@allowdeprecatedfalse=.

The compilation options can be set using \verb=\gresetcompilegabc= (see below).

\textbf{Important:} Gregorio\TeX{} may require up to two passes (runs of
\texttt{lualatex} or \texttt{luatex}) to compute the line heights correctly.  If a second
pass is required, Gregorio\TeX{} will emit the following
warning:\par\medskip

\begin{scriptsize}
\begin{latexcode}
Module gregoriotex warning: Line heights or variable brace lengths may have changed. Rerun to fix.
\end{latexcode}
\end{scriptsize}

Gregorio\TeX{} two-pass processing is compatible with \texttt{latexmk}.

If you only need the special symbols which Gregorio\TeX\ contains, and not the ability to include scores or musical glyphs, then you can load \texttt{gregoriosyms} instead of \texttt{gregoriotex}.  It supports all of the above options except those specifically related to scores.  \textbf{You should not try to load both packages}.

\subsubsection{Gregorio\TeX{} and \texttt{microtype}}

If you are using the \texttt{microtype} package or a package that itself uses
\texttt{microtype}, please load it after \texttt{gregoriotex}.  If you load
\texttt{microtype} before \texttt{gregoriotex}, you may receive an error about
an ``undefined control sequence'' if you use certain Gregorio\TeX{} features.

\subsection{Commands}

Once you've included the package in your document (as explained above) the following commands allow you to insert scores and manipulate the way they appear in the document.

\subsubsection{Including scores}

\macroname{\textbackslash gregorioscore}{[\optional{\#1}]\{\#2\}}{gregoriotex-main.tex}
Macro for including scores.  Works on both gabc and gtex files.

\begin{argtable}
	\#1 & \texttt{n} & Optional. \#2 will be included as is. \\
			& \texttt{a} & Optional. Gregorio\TeX\ will automatically compile gabc files if necessary.\\
			& \texttt{f} & Optional. Forces Gregorio\TeX\ to compile the gabc file.\\
	\#2 & string & Relative or absolute path to the score.\\
\end{argtable}

Example:\par\medskip
\begin{latexcode}
	\gregorioscore[n]{TecumPrincipium.gtex}
	\gregorioscore{Chant/VirgoVirginum.gabc}
	\gregorioscore{/home/user/chant/AdTeLevavi}
	\gregorioscore[a]{AveMaria}

	%The following lines include the same score:
	\gregorioscore{Christus}
	\gregorioscore{Christus.gtex}
	\gregorioscore{./Christus}
	\gregorioscore{./Christus.gabc}

	%With the optional arg [f], #2 must be a file usable by \TeX.
	\gregorioscore[f]{TecumPrincipium.gabc} % Wrong
\end{latexcode}

\textbf{Important:} For the sake of clarity it is recommended that the
file extension be omitted from \texttt{\#2} unless using the \texttt{nevercompile} option. When the \texttt{nevercompile}
option is in effect (either via package option
\texttt{[nevercompile]}, or \verb=\gresetcompilegabc{never}=, or
\verb=\gregorioscore[n]=) \#2 must be a \TeX\ file that exists and
the file extension (normally gtex) must be given.

When called with the optional argument \texttt{[a]} Gregorio\TeX\ will
automatically generate a \texttt{gtex} file in this format:
\texttt{\textit{scorename}-x\_x\_x.gtex} where \texttt{x\_x\_x} is the
gregorio version. This resulting file is not intended to be modified
by the user and will be removed when the gabc file is recompiled. The
rules that Gregorio\TeX\ uses to determine if a gabc file needs to be
compiled are:

\begin{itemize}
\item If a gtex file does not exist.
\item If the modification time of the gabc file is newer than its
	corresponding gtex file.
\item If the version of the gtex file is outdated.
\end{itemize}

When called with the optional argument \texttt{[n]} Gregorio\TeX\ will
include the score without doing anything else. This is the same as the
old behavior of Gregorio\TeX\ and therefore the default behavior.

When called with the optional argument \texttt{[f]} Gregorio\TeX\ will
compile the gabc file into a gtex file. This is similar to
\texttt{[a]} except the gabc is compiled every time.

\macroname{\textbackslash gresetgregpath}{\{\#1\}}{gregoriotex-main.tex}
Set a list of additional directories which should be searched for scores.  Directories may be absolute or relative, but must end with a slash (\verb=/=) and enclosed in braces (\verb={}=), even if there is only one additional directory.  For example, to look in a directory called “Scores” which is alongside the main project directory, one could use the following:

\begin{latexcode}
	\gresetgregpath{{../Scores/}}
\end{latexcode}

Note that these directories are not searched recursively.  If you want to include subdirectories, then each subdirectory must be included individually.


\macroname{\textbackslash gresetcompilegabc}{\{\#1\}}{gregoriotex-main.tex}
A macro to change the behavior of the way Gregorio\TeX\ includes scores.  This is similar to using the package options \verb=[forcecompile]=, \verb=[autocompile]=, and \verb=[nevercompile]=, but does not necessarly apply to the entire document.


\begin{argtable}
	\#1 & \texttt{force} & all later calls of \verb=\gregorioscore= will compile the gabc
file into a gtex file.\\
	& \texttt{auto} & all later calls of \verb=\gregorioscore= will use Gregorio\TeX's
automatic compilation of gabc files.\\
	& \texttt{never} & all later calls of \verb=\gregorioscore= will include the score
without doing anything else.
\end{argtable}

\medskip This macro can be combined in the same document with different arguments to
switch between different behaviors: \par\medskip
\begin{latexcode}
	\usepackage{gregoriotex} % [autocompile] is the default.
	----
	\gregorioscore{TecumPrincipium} % gabc auto compiled.
	\gregorioscore[n]{TecumPrincipium} % gabc never compiled.
	\gregorioscore[f]{TecumPrincipium} % gabc always compiled.

	\gresetcompilegabc{never}
	\gregorioscore{TecumPrincipium} % gabc never compiled.
	\gregorioscore[f]{TecumPrincipium} % gabc always compiled.
	\gregorioscore[a]{TecumPrincipium} % gabc auto compiled.

	\gresetcompilegabc{force}
	\gregorioscore{TecumPrincipium} % gabc always compiled.
	\gregorioscore[n]{TecumPrincipium} % gabc never compiled.
	\gregorioscore[a]{TecumPrincipium} % gabc auto compiled.
\end{latexcode}

\macroname{\textbackslash gabcsnippet}{\{\#1\}}{gregoriotex-main.tex}
Converts the gabc notation specified in \texttt{\#1} to Gregorio\TeX\ and
includes it directly in the document.

\begin{argtable}
	\#1 & string & The gabc to insert into the document.\\
\end{argtable}

\medskip For example:\par\medskip
\begin{latexcode}
	\gabcsnippet{(c3) Al(eg~)le(gv.fhg)lu(efe___)ia(e.) (::)}
\end{latexcode}


\subsubsection{Point-and-click}

Gregorio can add Lilypond-like point-and-click links into the output PDF
file.  The URLs added to the PDF conform with Lilypond and will use the
Lilypond scripts if they are enabled on your system.  To configure your
system for this feature, please see the documentation for Lilypond since
they established the feature.\bigskip

In addition to switching this feature on in \TeX{}, you must also pass the
\texttt{-p} option to \texttt{gregorio} when converting your gabc files to
Gregorio\TeX{} for inclusion.  This will automatically be done for auto- and
force-compiled scores, but if an auto-compiled score was compiled without the
option, Gregorio\TeX{} will not realize it has changed to recompile it.  In
this case, remove the corresponding \texttt{.gtex} file to force it to
recompile.\bigskip

\textbf{Important:} As with LilyPond, you should always turn off
point-and-click before producing gtex and/or PDF files for distribution.
This feature embeds absolute filenames from your computer as links in
the PDF, which can pose a security risk.  This is why this feature is
disabled by default.

\macroname{\textbackslash gresetpointandclick}{\{\#1\}}{gregoriotex-syllable.tex}
Macro to enable or disable the point-and-click feature.

\begin{argtable}
	\#1 & \texttt{on}  & Enable point-and-click link generation.\\
	& \texttt{off} & Disable point-and-click link generation (default).
\end{argtable}

This feature may be switched on and off as desired between scores.


\subsubsection{Overall Size}
While the default size for Gregorio scores is designed to approximate that found in most liturgical books, Gregorio\TeX\ also provides mechanisms for changing the size of your scores for use in any application.

\macroname{\textbackslash grechangestaffsize}{\{\#1\}}{gregoriotex-main.tex}
Macro to adjust the size of the staff.

\begin{argtable}
	\#1 & integer & The size of the staff lines.  Default value is 17.  Higher numbers yield larger staves.
\end{argtable}

\macroname{\textbackslash grechangestafflinethickness}{\{\#1\}}{gregoriotex-spaces.tex}
Macro to adjust the thickness of the staff lines.

\begin{argtable}
	\#1 & integer & The thickness of the staff lines.  The default value is same as staff size.
\end{argtable}


\subsubsection{Fine Tuning Dimensions}
In addition to providing control over the overall size of your scores, Gregorio\TeX\ allows you to fine tune the spacings around and between the various elements using the following functions.

\macroname{\textbackslash grechangedim}{\{\#1\}\{\#2\}\{\#3\}}{gregoriotex-spaces.tex}
Macro to change one of Gregorio\TeX’s distances.  This function will check to make sure the distance you are trying to change exists first.

\begin{argtable}
	\#1 & string & The name of the distance to be changed.  See \nameref{distances} below.\\
	\#2 & string & The distance in string format.  \textbf{Note:} You cannot use a length register for this argument.  You \emph{must} use a string because of the way that Gregorio\TeX\ handles spaces.\\
	\#3 & \texttt{fixed} & Distance will not scale when staff size is changed.\\
	& \texttt{scalable} & Distance will scale when staff size is changed.\\
	& \texttt{inherited} & Distance will inherit its value from another distance.  When this argument is used, then \#2 should be the name of another Gregorio\TeX\ distance.
\end{argtable}

\macroname{\textbackslash grechangenextscorelinedim}{\{\#1\}\{\#2\}\{\#3\}\{\#4\}}{gregoriotex-spaces.tex}
Changes one of Gregorio\TeX’s distances for a given line in the next included score.  This works with \texttt{spaceabovelines}, \texttt{spacebeneathtext}, and \texttt{spacelinestext}.

\begin{argtable}
	\#1 & list of integers & A comma-separated list of line numbers in the next
													 score to be adjusted.\\
	\#2 & string & The name of the distance to be changed.  See
								 \nameref{distances} below.\\
	\#3 & string & The distance in string format.  \textbf{Note:} You cannot use
								 a length register for this argument.  You \emph{must} use a
								 string because of the way that Gregorio\TeX\ handles spaces.\\
	\#4 & \texttt{fixed} & Distance will not scale when staff size is changed.\\
	& \texttt{scalable} & Distance will scale when staff size is changed.\\
	& \texttt{inherited} & Distance will inherit its value from another
												 distance.  When this argument is used, then \#3 should
												 be the name of another Gregorio\TeX\ distance.
\end{argtable}

\macroname{\textbackslash grescaledim}{\{\#1\}\{\#2\}}{gregoriotex-spaces.tex}
Macro to turn on or off scaling with the staff size for a particular distance.

\begin{argtable}
	\#1 & string & The name of the distance for which scaling is to changed.  See \nameref{distances} below.\\
	\#2 & \texttt{yes}/\texttt{true}/\texttt{on}/\texttt{scalable} & Choose just one of the given keywords.  Scale the distance when changing the size of the staff.\\
	& string not in list above & Do not scale the distance when changing the size of the staff.
\end{argtable}

\textbf{Nota bene:} This macro also can be used to change whether or not the staff line thickness scales with the staff size by specifying \texttt{stafflinefactor} for the first argument.

\macroname{\textbackslash grechangecount}{\{\#1\}\{\#2\}}{gregoriotex-spaces.tex}
Macro to change one of Gregorio\TeX’s counts or penalities (numeric values).

\begin{argtable}
	\#1 & string & The name of the count to be changed.  See \nameref{counts} and \nameref{penalties} below.\\
	\#2 & integer & The new value.\\
\end{argtable}

\macroname{\textbackslash grechangenextscorelinecount}{\{\#1\}\{\#2\}\{\#3\}}{gregoriotex-spaces.tex}
Changes one of Gregorio\TeX’s counts or penalties for a given line in the next included score.

\begin{argtable}
	\#1 & list of integers & A comma-separated list of line numbers in the next
													 score to be adjusted.\\
	\#2 & string & The name of the count to be changed.  See \nameref{counts} and
								 \nameref{penalties} below.\\
	\#3 & integer & The new value.\\
\end{argtable}

\macroname{\textbackslash greloadspaceconf}{\{\#1\}}{gregoriotex-spaces.tex}
Macro to load a space configuration file.  Space configuration file names have the format \verb=gsp-identifier.tex= and must be in the same directory as your project or in your texmf directory.  See \verb=gsp-sample.tex= for an example file.

\begin{argtable}
	\#1 & string & The identifier of the space configuration file.
\end{argtable}

Example:\par\medskip
\begin{latexcode}
	% loads gregoriotex-gsp-default.tex, the default configuration file
	\greloadspaceconf{default}
	% loads a custom configuration called gsp-myspaces.tex
	\greloadspaceconf{myspaces}
\end{latexcode}

\macroname{\textbackslash greconffactor}{}{gregoriotex-gsp-default.tex}
A count which indicates the staff size that a space configuration file is designed for.  Each space configuration file must have this value set as Gregorio\TeX\ will compare it to the current staff size to determine if the configuration file being loaded needs to be rescaled.

\macroname{\textbackslash gresetlineheightexpansion}{\{\#1\}}{gregoriotex-main.tex}
Macro to configure line height expansion behavior when notes appear
above or below the staff lines.

\begin{argtable}
		\#1 & \texttt{variable} & Expand lines within a score independently
															of each other \\
				& \texttt{uniform}  & Expand all lines within a score uniformly
\end{argtable}

By default, Gregorio\TeX{} uses \texttt{variable} line expansion.  This
produces output similar to modern liturgical books.  However, this
feature imposes a slight performance impact and typically requires a
second pass (run of \texttt{lualatex}) to get the heights right.\bigskip

The older behavior of Gregorio\TeX{}, \texttt{uniform} line expansion,
does not have this performance impact.  However, the extra space it adds
below the staff lines may look out-of-place in a section where there are
no notes below the staff lines.\bigskip

This behavior may be switched as needed within a \TeX{} document and
affects all the scores which follow.  However, if \texttt{variable} line
expansion is enabled anywhere in the document, the second pass will be
necessary.

\begin{small}
\begin{framed}
		\textit{For experts only:}\bigskip

		It is possible to suppress the line height computation and just use
		whatever has been computed from the previous run.  If you are sure
		that the score line heights haven't changed from the previous run,
		define the \verb=\greskipheightcomputation= control sequence before
		including the Gregorio\TeX{} package.  This will save a little bit
		of time per run.
\end{framed}
\end{small}

\macroname{\textbackslash gresetledgerlineheuristic}{\{\#1\}}{gregoriotex-spaces.tex}
Macro which enables or disables ledger line heuristics.  Currently, ledger
line heuristics allow Gregorio to reduce the space between a note and a
horizontal episema that surround a line on which a ledger line may appear
when the ledger line \textit{does not} appear.

\begin{argtable}
		\#1 & \texttt{enable}  & Ledger line heuristics will be used in placing
														 the horizontal episema \\
				& \texttt{disable} & Ledger line heuristics will not be used in
														 placing the horizontal episema \\
\end{argtable}

Because of the complexity of computing distances exactly, the heuristic may
guess incorrectly, causing the horizontal episema to be placed incorrectly.
This may be overridden on a note-by-note basic by using the
\texttt{[hl:\textit{n}]} and \texttt{[ll:\textit{n}]} gabc directives.  The
\texttt{hl} directive sets an explicit high ledger line (above the staff),
and the \texttt{ll} directive sets an explicit low ledger line (below the
staff).  The \texttt{\textit{n}} should be set to indicate whether the
system should act as if the ledger line exists (\texttt{1}) or not
(\texttt{0}).

\macroname{\textbackslash gresetnoteadditionalspacelinestext}{\{\#1\}}{gregoriotex-main.tex}
Macro which determines how much additional space between the notes and the lyrics for really low notes.

\begin{argtable}
	\#1 & \texttt{automatic} & additional space between the notes and the lyrics is computed automatically (default)\\
	& \texttt{manual} & additional space between the notes and the lyrics is based on the user setting of \texttt{noteadditionalspacelinestext} (a spacing adjustable using \verb=\grechangedim=)
\end{argtable}

\subsubsection{Staff Lines}

\macroname{\textbackslash gresetlinecolor}{\{\#1\}}{gregoriotex.sty \textup{and} gregoriotex.tex}
Macro for changing the color of the staff lines.   The two most common colors you're going to want to use are \texttt{gregoriocolor} (see \nameref{colors}) and \texttt{black} (the default).

\begin{argtable}
	\#1 & color name & The color of the staff lines
\end{argtable}

\macroname{\textbackslash gresetlines}{\{\#1\}}{gregoriotex-main.tex}
Macro for setting whether the staff lines should be rendered or not.

\begin{argtable}
	\#1 & \texttt{visible} & The staff lines should be printed (default)\\
	& \texttt{invisible} & The staff lines should not be printed
\end{argtable}

\macroname{\textbackslash gresetlinesbehindpunctumcavum}{\{\#1\}}{gregoriotex-signs.tex}
Macro for setting whether the staff lines behind a punctum cavum should be shown or not.

\begin{argtable}
	\#1 & \texttt{visible} & The staff lines behind a punctum cavum should be printed (Plain \TeX\ default)\\
	& \texttt{invisible} & The staff lines behind a punctum cavum should not be printed (\LaTeX\ default)
\end{argtable}

\macroname{\textbackslash gresetlinesbehindalteration}{\{\#1\}}{gregoriotex-signs.tex}
Macro for setting whether the staff lines behind an alternation (\ie, an accidental) should be shown or not.

\begin{argtable}
	\#1 & \texttt{visible} & The staff lines behind an alteration should be printed (Plain \TeX\ default)\\
	& \texttt{invisible} & The staff lines behind an alteration should not be printed (\LaTeX\ default)
\end{argtable}

\macroname{\textbackslash gresetlinesbehinddottedbar}{\{\#1\}}{gregoriotex-signs.tex}
Macro for setting whether the staff lines behind a dotted bar should be shown or not.

\begin{argtable}
	\#1 & \texttt{visible} & The staff lines behind a dotted bar should be printed\\
	& \texttt{invisible} & The staff lines behind a dotted bar should not be printed (default)
\end{argtable}


\subsubsection{Score Font}
Gregorio\TeX\ currently supports 3 different fonts for the glyphs in a score (neumes, clefs, alterations, \etc): Greciliae (a customized version of Caeciliae by Fr.\ Matthew Spencer, OSJ), Gregorio, and Grana Padano (née Parmesan, developed for Lilypond by Juergen Reuter).

\macroname{\textbackslash gresetgregoriofont}{[\optional{\#1}]\{\#2\}}{gregoriotex-main.tex}
Set the font used for the neumes.  The optional argument \texttt{[\#1]}
may be used to specify an alternate font/rule set.  Currently, the only
available alternate font/rule set is \texttt{op} for Dominican neumes.

Note that the font will be looked up by name through luaotfload, see the documentation of luaotfload for what it implies.

\begin{argtable}
	\#1 & \textit{(omitted)} & Use the normal font and rule set (default).\\
	& \texttt{op} & Use the alternate Dominican font/rule set.\\
	\#2 & \texttt{greciliae} & Use the Greciliae font (default).\\
	& \texttt{gregorio} & Use the Gregorio font.\\
	& \texttt{granapadano} & Use the Grana Padano font.\\
\end{argtable}

\textbf{Nota Bene:} The Gregorio and Grana Padano fonts are not included by default in a basic installation.  To get them you need to download and install them from the \verb=supp-fonts-##.zip= file (where \#\# is the version number of your release).  See \url{https://github.com/gregorio-project/gregorio/releases} for the list of releases.

\macroname{\textbackslash gresetgregoriofontscaled}{[\optional{\#1}]\{\#2\}\{\#3\}}{gregoriotex-main.tex}

This function is the same as above, with a third argument to scale the font. The fonts shipped with Gregorio do not need to use this function, but some custom fonts do. Note that you cannot use this to scale glyphs up or down, as they would not be placed correctly on the staff.

The two first arguments are the same as \texttt{\textbackslash gresetgregoriofont}. The third argument is an integer representing the scaling factor, where the one used by \texttt{\textbackslash gresetgregoriofont} is 100000.

\macroname{\textbackslash greloadholehollowfonts}{\{\#1\}}{gregoriotex-main.tex}

If set to false, will not load the \texttt{hollow} and \texttt{hole} variants of the next font to load. Use it before loading third party fonts not having these variants (rare case).

\begin{argtable}
	\#1 & string & \texttt{true} or \texttt{false}.\\
\end{argtable}

\subsubsection{Glyph Alteration}
In addition to the normal glyphs loaded by the choice of font, Gregorio\TeX\ also supports several methods for fine tuning the choice of glyphs.  Using the below functions, you can choose from alternative glyphs which are already built into Gregorio\TeX\ or import custom glyphs you have designed yourself.

\macroname{\textbackslash grechangeglyph}{\{\#1\}\{\#2\}\{\#3\}}{gregoriotex-main.tex}
Substitutes the given Gregorio\TeX\ score glyph with the specified glyph
from the specified font.

\begin{argtable}
	\#1 & string & The name of the Gregorio\TeX\ glyph to replace.\\
	\#2 & string & The name of the font to use.\\
	\#3 & number & The code point of the glyph to use.\\
	& \texttt{.}string & The name of the variant (appended to \#1) to use.\\
	& string & (any other string) The name of the glyph to use.
\end{argtable}

\medskip If \texttt{\#1} has a wildcard (a \texttt{*}) in it, then \texttt{\#3}
must be empty or start with a dot, and all glyphs matching \texttt{\#1} will be
replaced with corresponding glyphs whose names have \texttt{\#3} appended.

\medskip If \texttt{\#2} is \texttt{*}, then the substitution is assumed
to be available in all score fonts.

\medskip For example, to use the old glyphs (from Caeciliae) for the
strophicus, use the following:\par\medskip
\begin{latexcode}
	\grechangeglyph{Stropha}{greciliae}{.caeciliae}
	\grechangeglyph{StrophaAucta}{greciliae}{.caeciliae}
\end{latexcode}

\medskip To replace all torculus resupinus glyphs with their alternate
versions, use the following:\par\medskip
\begin{latexcode}
	\grechangeglyph{TorculusResupinus*}{*}{.alt}
\end{latexcode}

\textbf{Nota Bene:} Because the bar glyphs vary based on number of score lines,
substituting them is more complicated.  To cover all numbers of score lines,
you will need to substitute all of the glyphs for the same (like
\texttt{VirgulaTwo} through \texttt{VirgulaSix} for all available virgula
glyphs).  For example:

\medskip To replace all "dotted divisio maior" glyphs with their same-named
variants from the \texttt{gregorio} font, use the following:\par\medskip
\begin{latexcode}
	\grechangeglyph{DivisioMaiorDotted*}{gregorio}{}
\end{latexcode}

\macroname{\textbackslash greresetglyph}{\{\#1\}}{gregoriotex-main.tex}
Removes a Gregorio\TeX\ score glyph substitution, restoring it back to
its original form.

\begin{argtable}
	\#1 & string & The name of the Gregorio\TeX\ glyph to restore.\\
\end{argtable}

\medskip If \texttt{\#1} has a wildcard (a \texttt{*}) in it, then
all glyphs matching \texttt{\#1} will be restored.

\medskip For example, to restore the strophicus back to the new glyphs,
use the following:\par\medskip
\begin{latexcode}
	\greresetglyph{Stropha}
	\greresetglyph{StrophaAucta}
\end{latexcode}

\medskip To restore all torculus resupinus glyphs to their original
form, use the following:\par\medskip
\begin{latexcode}
	\greresetglyph{TorculusResupinus*}
\end{latexcode}

\macroname{\textbackslash grechangecavumglyph}{\{\#1\}\{\#2\}\{\#3\}[\optional{\#4}][\optional{\#5}]}{gregoriotex-main.tex}
Substitutes the given Gregorio\TeX\ score cavum glyphs with the specified glyphs
from the specified font.

\begin{argtable}
	\#1 & string & The name of the Gregorio\TeX\ glyph to replace.\\
	\#2 & string & The name of the font to use for the cavum glyph.\\
	\#3 & number & The code point of the cavum glyph to use.\\
	& \texttt{.}string & The name of the variant (appended to \#1) to use for the cavum glyph.\\
	& string & (any other string) The name of the cavum glyph to use.\\
	\#4 & string & The name of the font to use for the glyph to fill in the cavum hole.\\
	\#5 & number & The code point of the glyph to use to fill in the cavum hole.\\
	& \texttt{.}string & The name of the variant (appended to \#1) to use to fill in the the cavum hole.\\
	& string & (any other string) The name of the glyph to use to fill in the cavum hole.\\
\end{argtable}

\textbf{Nota Bene:} The usage of wildcards (\texttt{*}s) for \texttt{\#1},
\texttt{\#2}, and \texttt{\#4} is similar to \verb=\grechangeglyph=.

\macroname{\textbackslash greresetcavumglyph}{\{\#1\}}{gregoriotex-main.tex}
Removes a pair of Gregorio\TeX\ score cavum glyph substitution, restoring them
back to their original form.

\begin{argtable}
	\#1 & string & The name of the Gregorio\TeX\ cavum glyph to restore.\\
\end{argtable}

\textbf{Nota Bene:} The usage of wildcards (\texttt{*}s) for \texttt{\#1} is
similar to \verb=\greresetcavumglyph=.

\macroname{\textbackslash gredefsymbol}{\{\#1\}\{\#2\}\{\#3\}}{gregoriotex-symbols.tex}
Defines (or redefines) a \TeX\ control sequence to be a non-score symbol.
If defined this way, the symbol will scale with the text font.

\begin{argtable}
	\#1 & string & The name of the \TeX\ control sequence (without leading backslash).\\
	\#2 & string & The name of the font to use.\\
	\#3 & number & The code point of the glyph to use.\\
	& string & The name of the glyph to use.
\end{argtable}

\macroname{\textbackslash gredefsizedsymbol}{\{\#1\}\{\#2\}\{\#3\}}{gregoriotex-symbols.tex}
Defines (or redefines) a \TeX\ control sequence to be a non-score symbol
which requires a single numeric argument (in points) to which the symbol
will be scaled.

\begin{argtable}
	\#1 & string & The name of the \TeX\ control sequence (without leading backslash).\\
	\#2 & string & The name of the font to use.\\
	\#3 & number & The code point of the glyph to use.\\
	& string & The name of the glyph to use.
\end{argtable}

\macroname{\textbackslash gresethepisema}{\{\#1\}}{gregoriotex-signs.tex}
Determines whether Gregorio\TeX\ should join (bridge) horizontal episemata on adjacent notes.

\begin{argtable}
	\#1 & \texttt{bridge} & Adjacent horizontal episemata are joined together (default).\\
	& \texttt{break} & Adjacent horizontal episemata are not joined.
\end{argtable}

\macroname{\textbackslash gresetpunctumcavum}{\{\#1\}}{gregoriotex-signs.tex}
A shortcut for switching to the alternative punctum cavum and back.

\begin{argtable}
	\#1 & \texttt{alternate} & use the alternate punctum cavum\\
	& \texttt{normal} & use the normal punctum cavum
\end{argtable}

Using the alternate punctum cavum is the equivalent of issuing the following commands:

\begin{latexcode}
	\grechangeglyph{PunctumCavum}{greciliae}{.caeciliae}%
	\grechangeglyph{LineaPunctumCavum}{greciliae}{.caeciliae}%
	\grechangeglyph{PunctumCavumHole}{greciliae}{.caeciliae}%
	\grechangeglyph{LineaPunctumCavumHole}{greciliae}{.caeciliae}%
\end{latexcode}

\macroname{\textbackslash gresetglyphstyle}{\{\#1\}}{gregoriotex-chars.tex}
Gregorio\TeX\ supports several glyph styles which can be changed with this macro.  These style replace some non-note glyphs with alternatives.

\begin{argtable}
	\#1 & \texttt{default} & Use the default style\\
	& \texttt{medicaea} & Use a Medicaea style\\
	& \texttt{hufnagel} & Use the hufnagel style\\
	& \texttt{mensural} & Use the mensural style
\end{argtable}

%%%  Should there be a table here or in the appendix which shows the affected glyphs in each of the styles?


\subsubsection[Barred letters (A/, etc.)]{Barred letters (\Abar, etc.)}

\macroname{\textbackslash gresimpledefbarredsymbol}{\{\#1\}\{\#2\}}{gregoriotex-symbols.tex}
Redefines a \TeX\ control sequence to be a a barred symbol.

\begin{argtable}
	\#1 & character & must be \texttt{A}, \texttt{R}, or \texttt{V}.\\
	\#2 & dimension & how much the bar will be shifted left.\\
\end{argtable}

Gregorio\TeX\ does not have precomposed barred letters, instead, it has bars that you
can use to composed barred letters in your text font. This command is the most
simple version.

For example:

\medskip \begin{latexcode}
	\gresimpledefbarredsymbol{A}{0.3em}
\end{latexcode}

Will define \texttt{\textbackslash Abar} to be a A with a bar shifted right
of \texttt{0.3em} from the beginning of the glyph. This is the default definition
and fits well with the Linux Libertine font. If you use another font, you'll
certainly have to change this value by calling the \texttt{\textbackslash gresimpledefbarglyph} command.

\macroname{\textbackslash gredefbarredsymbol}{\{\#1\}\{\#2\}\{\#3\}\{\#4\}\{\#5\}\{\#6\}}{gregoriotex-symbols.tex}
Redefines a \TeX\ control sequence to be a barred symbol.

\begin{argtable}
	\#1 & string & the name of the command you want to define.\\
	\#2 & string & command to typeset the text.\\
	\#3 & string & symbol of the bar (must be defined through \texttt{gredefsizedsymbol}).\\
	\#4 & number & the size of greextra to use (in pt).\\
	\#5 & dimension & horizontal right shift of the bar.\\
	\#6 & dimension & vertical shift of the bar glyph.\\
\end{argtable}

This is a more complete version of the previous command, it allows you to define
barred letters with a different style. For example you can choose another bar
drawing, or take a bar more adapted to small font size.

For example:

\begin{footnotesize}
\begin{latexcode}
	\gredefbarredsymbol{RBarBold}{\textbf{R}}{greRBarSmall}{13}{1.7mm}{0.1mm}
\end{latexcode}
\end{footnotesize}

\gredefbarredsymbol{RBarBold}{\textbf{R}}{greRBarSmall}{13}{1.7mm}{0.1mm}
Will define \texttt{\textbackslash RBarBold} to be a bold \textbf{R} with
the bar made for small text (a bit bolder, named \texttt{RBarSmall} in greextra)
, at 12pt, shifted right of \texttt{1.7mm} from the beginning of the glyph, and lowered down
by \texttt{0.1mm}. The result is that \texttt{\textbackslash RBarBold} will typeset \RBarBold .

See Appendix \ref{subsec:greextra} for a list of bars and other
symbols present in the greextra font.

\macroname{\textbackslash grelatexsimpledefbarredsymbol}{\{\#1\}\{\#2\}\{\#3\}\{\#4\}\{\#5\}}{gregoriotex-symbols.tex}
Redefines a \TeX\ control sequence to be a barred symbol.

\bigskip\textbf{Only available in \LaTeX.}

\begin{argtable}
	\#1 & character & must be \texttt{A}, \texttt{R}, or \texttt{V}.\\
	\#2 & dimension & how much the bar will be shifted left when upright and medium weight.\\
	\#3 & dimension & how much the bar will be shifted left when italic/slanted and medium weight.\\
	\#4 & dimension & how much the bar will be shifted left when upright and bold.\\
	\#5 & dimension & how much the bar will be shifted left when italic/slanted and bold.\\
\end{argtable}

This is like \verb=\gresimpledefbarglyph=, but allows setting different shifts
for different font shapes and weights.  If you need something more elaborate,
you will need to redefine the bar macro(s) manually.  This macro is only
available in \LaTeX{} because it depends upon the \LaTeX{} font system.

\macroname{\textbackslash grebarredsymbol}{\{\#1\}\{\#2\}\{\#3\}\{\#4\}\{\#5\}}{gregoriotex-symbols.tex}
Generates a barred symbol.  This macro does not change any barred symbol
definitions.  Instead, it actually generates the code that would show the
barred symbol.

\begin{argtable}
	\#1 & string    & command to typeset the text.\\
	\#2 & string    & symbol of the bar (must be defined through \texttt{gredefsizedsymbol}).\\
	\#3 & number    & the size of greextra to use (in pt).\\
	\#4 & dimension & horizontal right shift of the bar.\\
	\#5 & dimension & vertical shift of the bar glyph.\\
\end{argtable}

\macroname{\textbackslash gothRbar}{}{gregoriotex-symbols.tex}
Prints \gothRbar.  Defined with \verb=\gredefsymbol=.

\macroname{\textbackslash gothVbar}{}{gregoriotex-symbols.tex}
Prints \gothVbar.  Defined with \verb=\gredefsymbol=.

\macroname{\textbackslash grealtcross}{}{gregoriotex-symbols.tex}
Prints \grealtcross.  Defined with \verb=\gredefsymbol=.

\macroname{\textbackslash grecross}{}{gregoriotex-symbols.tex}
Prints \grecross.  Defined with \verb=\gredefsymbol=.

\macroname{\textbackslash greheightstar}{}{gregoriotex-symbols.tex}
Prints \greheightstar.  Defined with \verb=\gredefsymbol=.

\macroname{\textbackslash gresixstar}{}{gregoriotex-symbols.tex}
Prints \gresixstar.  Defined with \verb=\gredefsymbol=.

\macroname{\textbackslash greseparator}{\{\#1\}\{\#2\}}{gregoriotex-symbols.tex}
A macro for invoking one of the five separators (fancy lines) which are contained in the greextra font.

\begin{argtable}
	\#1 & \texttt{1}--\texttt{5} & Choose the number of the line desired\\
	\#2 & integer & the point size at which to print the line\\
\end{argtable}

\macroname{\textbackslash greornamentation}{\{\#1\}\{\#2\}}{gregoriotex-symbols.tex}
A macro for invoking one of the ornamentation elements which are contained in the greextra font.

\begin{argtable}
	\#1 & \texttt{1}--\texttt{2} & Choose the number of the ornamentation desired\\
	\#2 & integer & the point size at which to print the line\\
\end{argtable}


\subsubsection{Special Characters}

% this is defined in gregoriotex-symbols.texx as having one argument, but the
% lua code generates a \gdef\<something> which then requires a second argument
\macroname{\textbackslash gresetspecial}{\{\#1\}\{\#2\}}{gregoriotex-symbols.tex}
Sets a special character.  Special characters are used from gabc within
\texttt{<sp>} and \texttt{</sp>}.

\begin{argtable}
	\#1 & string & The text between \texttt{<sp>} and \texttt{</sp>}.\\
	\#2 & \TeX\ code & The \TeX\ code to substitute when \texttt{<sp>\#1</sp>}
										 is used in gabc.\\
\end{argtable}

\textbf{Nota Bene:} If you need to use a character in \#1 that is made special
by \TeX{} (\ie, \textbackslash, \%, \etc), you should instead use
\verb=\string\nnn=, where \texttt{nnn} is a three-digit, zero-padded number
representing the ASCII code of the character (\ie, \textbackslash{} would be
\verb=\string\092=).

\macroname{\textbackslash greunsetspecial}{\{\#1\}}{gregoriotex-symbols.tex}
Un-sets a special character.  Using an unset special character will use its
text directly.

\begin{argtable}
	\#1 & string & The text between \texttt{<sp>} and \texttt{</sp>}.\\
\end{argtable}

\textbf{Nota Bene:} The same rules apply for \#1 as in \verb=\gresetspecial=.

\macroname{\textbackslash gretilde}{}{gregoriotex-main.tex}
Macro to print $\sim$.  This macro is set using the above for \texttt{<sp>$\sim$</sp>}.



\subsubsection{Styling}
Different elements of an include score have different styles applied.  These elements and their defaults are listed below:

\begin{adjustbox}{center}
\let\stylename\texttt
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\bigskip\rowcolors{1}{lightgray}{lightgray}
\begin{tabular}{lp{7cm plus .5cm}r}
	Element Name & Description & Default\\
	\hline
	\stylename{abovelinestext} & above line text (\texttt{<alt></alt>} in gabc, appears above the staff) & normal\\
	\stylename{additionalstafflines} & short lines behind notes above or below the staff & special\footnotemark[1]\\
	\stylename{annotation} & the annotation & none\\
	\stylename{commentary} & the commentary & {\footnotesize\it footnote-size italics} (\LaTeX)\\
	&& {\textit{italics}} (Plain \TeX)\\
	\stylename{elision} & elisions (\texttt{<e></e>} in gabc) & {\textit{\small small-size italics}} (\LaTeX)\\
											&& {\textit{italics}} (Plain \TeX)\\
	\stylename{firstsyllable} & the first syllable of the score excluding the score initial & none\\
	\stylename{firstsyllableinitial} & the first letter of the first syllable of a score which is not the score initial & none\\
	\stylename{firstword} & the first word of the first score excluding the score initial & none\\
	\stylename{highchoralsign} & high choral signs & none\\
	\stylename{initial} & Score initial (the first letter of the score, when offset from the rest of the text) & 40 pt font\\
	\stylename{lowchoralsign} & low choral signs & none\\
	\stylename{modedifferentia} & the rendered annotation from the \texttt{mode-differentia: ;} header in the gabc file & \parbox[t]{2.2cm}{\raggedleft\textbf{bold}}\\
	\stylename{modeline} & the rendered annotation from the \texttt{mode: ;} header in the gabc file & \parbox[t]{2.2cm}{\raggedleft\textsc{\textbf{bold small capitals}}} (\LaTeX)\\
	& & \textbf{bold} (Plain\TeX)\\
	\stylename{modemodifier} & the rendered annotation from the \texttt{mode-modifier: ;} header in the gabc file & \parbox[t]{2.2cm}{\raggedleft\textit{\textbf{bold italics}}}\\
	\stylename{nabc} & ancient notation & {\color{gregoriocolor}gregoriocolor}\\
	\stylename{normalstafflines} & Full length staff lines & none\\
	\stylename{translation} & Translation text (appears below lyrics) & {\it italics}\\
\end{tabular}
\end{adjustbox}

\footnotemark[1]\textit{Special:} By default, \texttt{additionalstafflines} inherits its properties from \texttt{normalstafflines}.  To decouple these environments, you must manually change \texttt{additionalstafflines} using \texttt{\textbackslash grechangestyle}.
\renewcommand{\thefootnote}{\arabic{footnote}}\breakabletrue

\macroname{\textbackslash grechangestyle}{\{\#1\}\{\#2\}[\optional{\#3}]}{gregoriotex.sty \textup{and} gregoriotex.tex}
Command to change styling of a score element.

\begin{argtable}
	\#1 & string & element whose styling is to be changed (see list above for options)\\
	\#2 & \TeX\ code & the code necessary to turn on the styling\\
	\#3 & \TeX\ code & Optional.  The code necessary to turn off the styling (\eg, if the code to turn on the styling contains a \verb=\begin{environment}= then the code to turn it off must have the matching \verb=\end{environment}=.
\end{argtable}

Examples:\par\medskip
\begin{latexcode}
	% This one works for both PlainTeX and LaTeX this would make
	% the translations bold and italic
	\grechangestyle{translation}{\it\bf}

	% This one is LaTeX only, and would make the above lines
	% text small and italic
	\grechangestyle{abovelinestext}{\begin{small}\begin{itshape}}%
		[\end{itshape}\end{small}]

	% This would make the initial print in 36pt font.
	\grechangestyle{initial}{\fontsize{36}{36}\selectfont}
\end{latexcode}

\bigskip
Each element will be typeset within an isolated group to prevent styling commands from leaking from one element to the next.  As a result, if a styling command has an ``on-switch'' but no ``off-switch'' (like \verb=\it= or \verb=\bf= in the first example above) it is not necessary to encapsulate them within \verb=\begingroup= and \verb=\endgroup=.  As a result, the third argument is only necessary for styling commands which come in pairs (like the environments in the second example).

\subsubsection{Text Elements}
While the gabc headers provide support for some of the text elements commonly found on chant scores, Gregorio\TeX\ provides the following functions to allow you to enter and control those elements with a greater degree of precision than the gabc headers.

\macroname{\textbackslash greannotation}{[\optional{\#1}]\{\#2\}}{gregoriotex-main.tex}
Macro to add annotations (the text which appears above the initial) to a score.  While a single call of the function does not support multiple lines, successive calls to the function will be added to the annotation as a new line below what is already there.

\begin{argtable}
	\#1 & \texttt{c} & When adding a new line, align the center of the new line with the center of the existing lines\\
	& \texttt{l} & When adding a new line, align the left side of the new line with the left side of the existing lines\\
	& \texttt{r} & When adding a new line, align the right side of the new line with the right side of the existing lines\\
	\#2 & string & the text of the annotation
\end{argtable}

\textbf{Nota Bene:} The first argument does not affect the alignment of lines already in the annotation, only the way the new line aligns with the existing lines as a whole.

\macroname{\textbackslash grecommentary}{[\optional{\#1}]\{\#2\}}{gregoriotex-main.tex}
Macro to add commentary (the text flush right at the top, usually a scripture reference) to a score.  While a single call of this function does not support multiple lines, successive calls to the function will add a new line to the commentary directly below the previous.

\begin{argtable}
	\#1 & distance & Optional.  Additional distance to be placed between the commentary and the top staff line for the next score only.\\
	\#2 & string & The text of the commentary.\\
\end{argtable}

\textbf{Nota Bene:} If your commentary is multi-lined, then the optional argument of the last line, and only the last line, will be taken into account.  Further, pay attention to the fact that the optional argument is \emph{additional} distance, \ie, it will be added to \texttt{commentaryraise} to determine the distance from the baseline of the commentary to the top line of the staff.

\macroname{\textbackslash greillumination}{\{\#1\}}{gregoriotex-main.tex}
Macro to add an illuminated initial.

\begin{argtable}
	\#1 & \TeX\ code & the code necessary to make the illuminated initial appear\\
\end{argtable}

\textbf{Nota Bene:} Usually the argument of this command should be an \verb=\includegraphics= command, but you may use what ever you want as the illuminated initial.

\macroname{\textbackslash gresetinitiallines}{\{\#1\}}{gregoriotex-syllable.tex}
Sets the number of lines the score initial requires.

\begin{argtable}
	\#1 & number & The number of lines required by the initial.  If \texttt{0}, the score will have no separated initial.\\
\end{argtable}

\textbf{Nota Bene:} As currently implemented, you cannot set an initial which is larger than 2 lines and in order to do so you must set manual line breaks in the gabc for the first two lines.

\macroname{\textbackslash gresetmodenumbersystem}{\{\#1\}}{gregoriotex-main.tex}
Sets the number system used for the mode number.

\begin{argtable}
	\#1 & \texttt{roman-minuscule} & Use lower-case Roman numerals (the default in \LaTeX, good for small capitals).\\
			& \texttt{roman-majuscule} & Use upper-case Roman numerals (the default in Plain\TeX).\\
			& \texttt{arabic} & Use Arabic numerals.\\
\end{argtable}

\macroname{\textbackslash gresetlyrics}{\{\#1\}}{gregoriotex-syllable.tex}
Sets the visibility of the lyrics.

\begin{argtable}
	\#1 & \texttt{visible} & Lyrics are visible (default).\\
	& \texttt{invisible} & Lyrics are not visible.\\
\end{argtable}

\macroname{\textbackslash gresettranslation}{\{\#1\}}{gregoriotex-main.tex}
Sets the visibility of the translations.

\begin{argtable}
	\#1 & \texttt{visible} & Translations are visible (default).\\
	& \texttt{invisible} & Translations are not visible.\\
\end{argtable}

\macroname{\textbackslash gresetabovelinestext}{\{\#1\}}{gregoriotex-main.tex}
Sets the visibility of the above lines text.

\begin{argtable}
	\#1 & \texttt{visible} & Above lines text are visible (default).\\
	& \texttt{invisible} & Above lines text are not visible.\\
\end{argtable}


\subsubsection{Text Alignment}
Gregorio\TeX\ allows you to manipulate the global alignment behavior of some text elements using the following commands.

\macroname{\textbackslash gresetlyriccentering}{\{\#1\}}{gregoriotex-syllable.tex}
Macro to set how the text of the lyrics aligns with the alignment point of its respective neumes.  The alignment point of the neumes is determined as follows:

\begin{itemize}
\item If the first glyph is only one note, or is a normal pes, or is composed of three or more notes, the alignment point is the middle of the first note.
\item If the first glyph is composed of two notes (other than a normal pes), the alignment point is the middle of the glyph.
\item In the case of a porrectus, the alignment point is the middle of an imaginary square punctum beginning at the same point as the porrectus.
\end{itemize}

\begin{argtable}
	\#1 & \texttt{vowel} & The center of the vowel in the syllable will align with the alignment point of the neumes\\
	& \texttt{syllable} & The center of the syllable will align with the alignment point of the neumes\\
	& \texttt{firstletter} & The center of the first letter/character of the syllable will align with the alignment point of the neumes\\
\end{argtable}

\textbf{Nota Bene:} What constitutes the ``vowel'' of the syllable is determined by the language the lyric text is written in, as specified by the use of the \texttt{language} header in the gabc file.  Out of the box, Gregorio\TeX\ explicitly supports Latin, English, Church Slavonic and Hungarian.  Polish, Czech, and Slovak are supported as aliases for Church Slavonic.  Furthermore the rules for Latin have a high degree of overlap with many Romance languages, allowing them to fall back on the Latin rules with acceptable results.

You can also define your own languages in \texttt{gregorio-vowels.dat} (see \nameref{customvowels} for details).  If you do define a language, please consider sharing your work by submitting it to the project (see CONTRIBUTING.md for instructions).

Finally, in cases where you want some sort of exceptional alignment, you can force Gregorio to consider a particular part of the syllable to be the ``vowel'' by enclosing it in curly braces (``\{'' and ``\}'') in your gabc file.  Curly braces only affect alignment when using vowel centering.  Syllable centering will always use the entire syllable, and firstletter centering will always use the first character of the syllable --- regardless of curly braces in the gabc file.

\macroname{\textbackslash gresetgabcforcecenters}{\{\#1\}}{gregoriotex-syllable.tex}
Macro to determine whether a forced center (\ie, one specified by curly braces (``\{'' and ``\}'') in your gabc file) should influence the alignment of that syllable when \texttt{syllable} and \texttt{firstletter} alignments are in effect.

\begin{argtable}
	\#1 & \texttt{allow} & Forced centers in gabc are allowed to influence the syllable alignment (default).\\
	& \texttt{prohibit} & Forced centers in gabc do not influence the syllable alignment.\\
\end{argtable}

\macroname{\textbackslash gresettranslationcentering}{\{\#1\}}{gregoriotex-main.tex}
Macro to specify how the translation text should be aligned with it respective syllable text.

\begin{argtable}
	\#1 & \texttt{left} & The translation text is left aligned with its respective syllable text.\\
	& \texttt{center} & The translation text is centered under its respective syllable.
\end{argtable}

\macroname{\textbackslash gresetannotationby}{\{\#1\}}{gregoriotex-main.tex}
Macro to specify which line of the annotation should be used to determine its starting placement (i.e. before \texttt{annotationraise} is applied).

\begin{argtable}
	\#1 & \texttt{topline} & Annotation placement is determined by the first line (default)\\
	& \texttt{bottomline} & annotation placement is determined by the last line\\
\end{argtable}

\macroname{\textbackslash gresetannotationvalign}{\{\#1\}}{gregoriotex-main.tex}
Macro to specify which part of the control line in the annotation should be aligned with the top line of the staff before \texttt{annotationraise} is applied.

\begin{argtable}
	\#1 & \texttt{top} & The top of the annotation control line will align with the top line of the staff\\
	& \texttt{baseline} & The baseline of the control line is used (default)\\
	& \texttt{bottom} & The bottom of the control line is used\\
\end{argtable}

\textbf{Nota Bene:} These variable refer to the actual contents of the line and not to the ``hypothetical'' limits for the font.  As a result if the top of an annotation containing only short letters will be different from one which contains tall ones even if both use the same font.  Likewise, if the annotation contains no descenders, then baseline and bottom will be the same.  If this is a problem, then the use of struts within the annotation can be used to control the line height (distance from baseline to top) and depth (distance from baseline to bottom).

\macroname{\textbackslash gresetsyllablerewriting}{\{\#1\}}{gregoriotex-syllable.tex}
Sets whether the last part of a non-final syllable of a word is moved to the
next syllable when there is no hyphen.  The ``last part'' of a syllable is
the part that comes after the part that is centered under the first note of
the syllable.  This feature may allow Lua\TeX{} to find better opportunities
for ligaturing based on \TeX{} and font settings.

\begin{argtable}
	\#1 & \texttt{auto} & Gregorio\TeX{} will move the last part of a syllable
												to the next syllable in a word when there is no
												hyphen (default).\\
			& \texttt{off}  & Gregorio\TeX{} will not attempt to rewrite any
												syllables.\\
\end{argtable}

\macroname{\textbackslash gresetprotrusionfactor}{\{\#1\}\{\#2\}}{gregoriotex-spaces.tex}
Sets a global protrusion factor.  Depending on the first argument, these
protrusion factors will be used for various characters as well as for
\verb=<pr>= tags with no specified protrusion factor.  A protrusion factor of 0
means no protrusion and 1 means full protrusion.  Any floating-point value from
0 to 1 is allowed.  All of these global protrusion factors may be set in
a spacing configuration file (gsp-*.tex) or in the project \TeX\ file.

\begin{argtable}
	\#1 & \texttt{,}         & Sets the automatic protrusion factor for a comma at
														 the end of a syllable.  Default is
														 \GreProtrusionFactor{comma}.\\
			& \texttt{;}         & Sets the automatic protrusion factor for a
														 semicolon at the end of a syllable.  Default is
														 \GreProtrusionFactor{semicolon}.\\
			& \texttt{:}         & Sets the automatic protrusion factor for a colon at
														 the end of a syllable.  Default is
														 \GreProtrusionFactor{colon}.\\
			& \texttt{.}         & Sets the automatic protrusion factor for a period
														 at the end of a syllable.  Default is
														 \GreProtrusionFactor{period}.\\
			& \texttt{eolhyphen} & Sets the protrusion factor for a hyphen at
														 the end of a line.  Default is
														 \GreProtrusionFactor{eolhyphen}.  This protrusion
														 factor only applies to hyphens inserted by the Lua
														 pass), so use it with caution.\\
			& \texttt{default}   & Sets the default protrusion factor for a
														 \verb=<pr>= tag in gabc.  Default is
														 \GreProtrusionFactor{default}.\\
	\#2 & factor             & The desired protrusion factor, a floating point
														 value from 0 (no protrusion) to 1 (full
														 protrusion).  See defaults above.\\
\end{argtable}

\subsubsection{End of Line Behavior}
While Gregorio\TeX\ will automatically wrap scores to fit your page, there are several ways to fine tune that line breaking behavior with the following commands.

\macroname{\textbackslash gresetbreakbeforeeuouae}{\{\#1\}}{gregoriotex-main.tex}
Macro to determine whether an automatic linebreak before a EUOUAE area is justified or not.

\begin{argtable}
	\#1 & \texttt{justified} & Automatic line breaks before EUOUAE areas should be justified (default)\\
	& \texttt{ragged} & Automatic line breaks before EUOUAE areas should be ragged\\
\end{argtable}

\textbf{Important:} When set to \texttt{ragged}, Gregorio\TeX{} will require a
second pass (run of \texttt{lualatex} or \texttt{luatex}) to typeset the line
endings correctly.  When an additional pass is required, Gregorio\TeX{} will
emit the following warning:\par\medskip

\begin{scriptsize}
\begin{latexcode}
Module gregoriotex warning: Line heights or variable brace lengths may have changed. Rerun to fix.
\end{latexcode}
\end{scriptsize}

\macroname{\textbackslash gresetbreakineuouae}{\{\#1\}}{gregoriotex-main.tex}
Macro to determine whether line breaks are allowed inside a EUOUAE area (delimited by \texttt{<eu></eu>} tags in gabc).

\begin{argtable}
	\#1 & \texttt{allow} & Line breaks are allowed\\
	& \texttt{prohibit} & Line breaks are prohibited, the entire EUOUAE area should appear on one line
\end{argtable}

\macroname{\textbackslash gresetbreakintranslation}{\{\#1\}}{gregoriotex-main.tex}
Macro to determine whether line breaks are allowed inside a translation.

\begin{argtable}
	\#1 & \texttt{allow} & Line breaks are allowed\\
	& \texttt{prohibit} & Line breaks are prohibited, the entire translation should appear on one line
\end{argtable}

\macroname{\textbackslash gresetcustosalteration}{\{\#1\}}{gregoriotex-signs.tex}
Macro for setting whether an alteration (flat, sharp, or natural) should be
rendered before a custos or not.

\begin{argtable}
	\#1 & \texttt{visible} & The custos alteration should be printed (default)\\
			& \texttt{invisible} & The custos alteration should not be printed
\end{argtable}

\macroname{\textbackslash greseteolcustos}{\{\#1\}}{gregoriotex-main.tex}
Macro to determine whether Gregorio\TeX\ should automatically place the custos at a line break.

\begin{argtable}
	\#1 & \texttt{auto} & Custos will be automatically placed at each line break\\
	& \texttt{manual} & Custos will only be placed at line breaks if they are specified in the gabc (\eg \texttt{(g+z)})
\end{argtable}

\textbf{Nota Bene:} This command only effects the custos that appears at the end of a line.  Custos which are placed at a key change are unaffected.  Further, if custos are specified in the gabc file manually and Gregorio\TeX\ is set to place custos automatically, you will get two custos at the line breaks.

\macroname{\textbackslash greseteolcustosbeforeeuouae}{\{\#1\}}{gregoriotex-main.tex}
Macro to determine whether Gregorio\TeX\ should automatically place the custos at a line break before a EUOUAE.  Since the EUOUAE block is typically not a continuation of the melody but rather a reminder of the end of the tone that follows, this is set to \texttt{suppressed} (no custos) by default.

\begin{argtable}
	\#1 & \texttt{suppressed} & Custos will not automatically be placed at a line break before a EUOUAE block (the default)\\
	& \texttt{auto} & Custos will behave according to \verb=greseteolcustos= at a line break before a EUOUAE block\\
\end{argtable}

\textbf{Nota Bene:} If \verb=\greseteolcustos= is set to \texttt{manual}, this setting is effectively ignored.

\macroname{\textbackslash greseteolshifts}{\{\#1\}}{gregoriotex-main.tex}
Macro to determine whether Gregorio\TeX\ should apply a small shift at the end of each line which allows lyrics to stretch under the final custos.

\begin{argtable}
	\#1 & \texttt{enable} & The shifts are applied (default)\\
	& \texttt{disable} & The shifts are not applied.
\end{argtable}

\macroname{\textbackslash gresetbolshifts}{\{\#1\}}{gregoriotex-main.tex}
Macro to determine whether Gregorio\TeX\ should apply a small shift at the beginning of each line so that lines are aligned on the notes rather than the syllable text.

\begin{argtable}
	\#1 & \texttt{enable} & The shifts are applied (default)\\
	& \texttt{disable} & The shifts are not applied.
\end{argtable}

\macroname{\textbackslash grebolshiftcleftype}{\{\#1\}}{gregoriotex-spaces.tex}
Macro to determine how notes should be left aligned in the case where clefs of different widths appear in the same score.

\begin{argtable}
	\#1 & \texttt{largest} & The notes are aligned as if all clefs had the width of the largest clef (default)\\
	& \texttt{current} & The notes are aligned on the current clef, which leads to unaligned notes. This was the default of Gregorio < \texttt{5.0}.
\end{argtable}

\macroname{\textbackslash grelocalbolshiftcleftype}{\{\#1\}}{gregoriotex-spaces.tex}
Equivalent of \verb=\grebolshiftcleftype= but valid only until the next end of a score, and with more options. This can be used before a score or even inside a \verb=<v>verbatim</v>= in gabc for corner cases like different alignment on a score taking two pages.

\begin{argtable}
	\#1 & \texttt{largest} & The notes are aligned as if all clefs had the width of the largest clef (default)\\
	& \texttt{current} & The notes are aligned on the current clef, which leads to unaligned notes\\
	& \texttt{f} & Force left alignment of notes as if all clef were f clef\\
	& \texttt{c} & Idem with c clef\\
	& \texttt{fb} & Idem with flatted f clef\\
	& \texttt{cb} & Idem with flatted c clef\\
\end{argtable}

\macroname{\textbackslash gresetlastline}{\{\#1\}}{gregoriotex-main.tex}
Macro to determine whether the last line of the score should be justified or not.

\begin{argtable}
	\#1 & \texttt{justified} & Set the last line justified with the rest of the score\\
	& \texttt{ragged} & Set the last line ragged (default)
\end{argtable}

\macroname{\textbackslash gresetunbreakablesyllablenotes}{\{\#1\}\{\#2\}\{\#3\}}{gregoriotex-syllable.tex}
Configures how notes should be kept together on line breaks.

\begin{argtable}
	\#1 & integer & The minimum number of notes in the syllable before the
									syllable may be broken across lines.  Defaults to
									\getgrecount{unbreakabletotalnotes}.\\
	\#2 & integer & The minimum number of notes at the start of a syllable that
									must be kept together when the syllable is broken across
									lines.  Defaults to \getgrecount{unbreakableinitialnotes}.\\
	\#3 & integer & The minimum number of notes at the end of a syllable that
									must be kept together when the syllable is broken across
									lines.  Defaults to \getgrecount{unbreakablefinalnotes}.\\
\end{argtable}


\subsubsection{Bar spacing}

\macroname{\textbackslash gresetshiftaftermora}{\{\#1\}}{gregoriotex-signs.tex}
Macro to change the behaviour for separation between notes of two syllables when the first ends with a punctum mora. The argument changes the cases in which punctum mora are ignored in space computation:

\begin{argtable}
	\#1 & \texttt{always} & punctum mora are always ignored (default)\\
	& \texttt{notesonly} & punctum mora are ignored before notes, not bars\\
	& \texttt{barsonly} & punctum mora are ignored before bars, not notes\\
	& \texttt{notextonly} & punctum mora are ignored only before bars inside syllables, or bars having their own syllable without text\\
	& \texttt{insideonly} & punctum mora are ignored only before bars inside syllables\\
	& \texttt{never} & punctum mora are never ignored\\
\end{argtable}

When a punctum mora is ignored, the bar will also be shifted by \texttt{moraadjustmentbar} (zero by default), see its description in the \nameref{distances} section.

\macroname{\textbackslash gresetbarspacing}{\{\#1\}}{gregoriotex-syllable.tex}
Macro to activate the new bar spacing algorithm.  The new algorithm attempts to place the bar line exactly midway between its surrounding notes.  Any text associated with the bar is placed midway between its surrounding text.  Since this might result in the bar line and the text being widely separated, there are also a limits to the distance between their respective centers: \texttt{maxbaroffsettextleft} and \texttt{maxbaroffsettextright} (when text center is respectively on the left or on the right of bar center).

\begin{argtable}
	\#1 & \texttt{new} & Activates the new spacing algorithm (Default)\\
	& \texttt{old} & Activates the old behavior\\
\end{argtable}

\subsubsection{Sign printing}

\macroname{\textbackslash gresetnotes}{\{\#1\}}{gregoriotex-syllable.tex}
Sets the visibility of the notes.

\begin{argtable}
	\#1 & \texttt{visible} & Notes are visible (default).\\
	& \texttt{invisible} & Notes are not visible.\\
\end{argtable}

\textbf{Nota Bene:} If the notes are set to be invisible, then bar lines, rythmic signs, and the like will also be invisible.  However, the staff lines and clefs will still show up (since their visibility is controlled by other settings).

\macroname{\textbackslash gresetnabc}{\{\#1\}\{\#2\}}{gregoriotex-nabc.tex}
Sets the visibility of a nabc voice.

\begin{argtable}
	\#1 & integer & The nabc voice number.\\
	\#2 & \texttt{visible} & Notes are visible (default).\\
	& \texttt{invisible} & Notes are not visible.\\
\end{argtable}

\macroname{\textbackslash greprintsigns}{\{\#1\}\{\#2\}}{gregoriotex-signs.tex}
Macro to prevent rythmic signs from printing (all signs are printed by default):

\begin{argtable}
	\#1 & \texttt{vepisema} & sets the printing of vertical episema\\
	& \texttt{hepisema} & sets the printing of horizontal episema\\
	& \texttt{mora} & sets the printing of punctum mora and auctum duplex\\
	& \texttt{all} & set the printing of all of these\\
	\#2 & \texttt{enable} & enable the printing\\
	& \texttt{disable} & disable the printing\\
\end{argtable}

Note that punctum mora and auctum duplex have an influence on spacings, so removing them will have an impact on that matter.

\subsubsection{Hyphenation}

\macroname{\textbackslash gresethyphen}{\{\#1\}}{gregoriotex-main.tex}
Tells Gregorio\TeX\ how to place a hyphen between syllables in polysyllabic words in a score.

\begin{argtable}
	\#1 & \texttt{force} & Hyphens will appear between all syllables in polysyllabic words.\\
	& \texttt{auto} & Hyphens will appear based on the setting of \texttt{maximumspacewithoutdash} (default)
\end{argtable}

\macroname{\textbackslash gresetemptyfirstsyllablehyphen}{\{\#1\}}{gregoriotex-syllable.tex}
Tells Gregorio\TeX\ how to place a hyphen after an empty first syllable (\ie, when the first syllable consists only of the big initial).

\begin{argtable}
	\#1 & \texttt{force} & A hyphen will appear after an empty first syllable. (default)\\
	& \texttt{auto} & A hyphen will appear after an empty first syllable based on the setting of \texttt{maximumspacewithoutdash}
\end{argtable}

\macroname{\textbackslash greseteolhyphen}{\{\#1\}}{gregoriotex-main.tex}
Marco to determine how much space the hyphen at the end of a line occupies for the purposes of spacing calculations (the visible appearance of the hyphen is unchanged).

\begin{argtable}
	\#1 & \texttt{normal} & The hyphen occupies its normal space\\
	& \texttt{zero} & The hyphen is considered to take up no space
\end{argtable}

\subsubsection{Clef Visibility}

\macroname{\textbackslash gresetclef}{\{\#1\}}{gregoriotex-signs.tex}
Macro to tell Gregorio\TeX\ whether the clefs should be printed or not.

\begin{argtable}
	\#1 & \texttt{visible} & Clefs will be printed (default)\\
	& \texttt{invisible} & Clefs will not be printed
\end{argtable}


\subsubsection{Clivis Alignment}
Since the center of the clivis is different from most neumes, Gregorio\TeX\ supports several behaviors for determining how to align it with its lyrics.

\macroname{\textbackslash gresetclivisalignment}{\{\#1\}}{gregoriotex-syllable.tex}
Macro to determine the method used for aligning the clivis with its lyrics.

\begin{argtable}
	\#1 & \texttt{always} & Align on the real center of the clivis\\
	& \texttt{never} & align on the center of the first punctum in the clivis\\
	& \texttt{special} & align on the real center of the clivis except when (1) notes would go left of text or (2) consonants after vowels are larger than \verb=\gre@dimen@clivisalignmentmin= (default)
\end{argtable}



\subsubsection{Braces}

\macroname{\textbackslash gresetbracerendering}{[\optional{\#1}]\{\#2\}}{gregoriotex-signs.tex}
Macro to tell Gregorio\TeX{} whether to use \MP{} or fonts to render
braces.  \MP{} braces, the default, are tailored to better maintain
optical line weight when stretched.  \MP{} braces are designed to
harmonize (and thus match best) with greciliae, but they still look good
with the other score fonts.

\begin{argtable}
	\#1 & \textit{(omitted)} & change all braces\\
			& \texttt{brace} & change round braces that appear over the staff\\
			& \texttt{underbrace} & change round braces that appear under the staff\\
			& \texttt{curlybrace} & change curly braces\\
			& \texttt{barbrace} & change round braces that appear over divisio bars\\
	\#2 & \texttt{metapost} & \MP{} will be used to render braces\\
			& \texttt{font} & The score font will be used to render braces\\
\end{argtable}

\macroname{\textbackslash grebarbracewidth}{}{gregoriotex-signs.tex}
Returns the em-relative width of a bar brace when braces are rendered by
\MP{} (as opposed to fonts).  The value is scaled by the Gregorio\TeX\ score
size factor and thus is a score-relative value with a precise (but
obscure) mathematical meaning.  Suffice it to say that larger numbers
make the bar brace wider and smaller numbers make the brace narrower.
This must be a positive number, defaults to \texttt{.58879}, and
harmonizes with the greciliae font.  This macro must be redefined should
a different value be desired.


\subsubsection{Headers}

\macroname{\textbackslash gresetheadercapture}{\{\#1\}\{\#2\}\{\#3\}}{gregoriotex-main.tex}
Macro to tell Gregorio\TeX{} to capture a given header of the gabc file, passing it to a
specified \TeX{} macro.  Passing an empty \#2 will cancel capture of the given header.

\begin{argtable}
	\#1 & string & The name of the gabc header\\
	\#2 & string & The name of the macro to use (without the leading backslash)
								 or empty to stop capturing the given header\\
	\#3 & string & a comma-separated list of options\\
\end{argtable}

The options are:

\begin{tabular}{ll}
	\texttt{name}   & The header name should also be passed to the macro\\
	\texttt{string} & The header value should be passed to the macro as a string\\
\end{tabular}

If the \texttt{name} option is not supplied, the macro is called with one
argument: the value of the header.

If the \texttt{name} option is supplied, the macro is called with two
arguments: the name and the value of the header (in that order).

If the \texttt{string} option is supplied, the value will be passed with
catcode 12 associated with all non-space characters (and catcode 10 for all spaces).
If not, the value will be evaluated as regular \TeX{} input.

Other than the headers that define macros, which are not passed to \TeX{},
the headers will be processed in the order they were presented in the gabc
file.  Headers will be processed in the \TeX{} state at the point of the
\verb=\gregorioscore= call.  This means, for example, that should the
capturing macro produce something, it will be typeset within the same
paragraph as the \verb=\gregorioscore= call.

As an example, you can use

\verb=\gresetheadercapture{commentary}{grecommentary}{string}=

\noindent to capture the
\texttt{commentary} header of gabc files and feed it to \verb=\grecommentary=,
thus automatically printing the content of the header above the score.

\macroname{\textbackslash grebeforeheaders}{\{\#1\}}{gregoriotex-main.tex}
Specifies \TeX{} code processed before the processing of the headers of a score.
Defaults to nothing.  If this is called multiple times, the most recent call
will define the behavior at the next set of headers.

\begin{argtable}
		\#1 & \TeX\ code & The code to process before a set of headers.\\
\end{argtable}

\macroname{\textbackslash greafterheaders}{\{\#1\}}{gregoriotex-main.tex}
Specifies \TeX{} code processed after the processing of the headers of a score.
Defaults to nothing.  If this is called multiple times, the most recent call
will define the behavior at the next set of headers.

\begin{argtable}
		\#1 & \TeX\ code & The code to process after a set of headers.\\
\end{argtable}


\subsubsection{Ancient Notation}
For a full description of how to make use of the ancient notation capabilities of Gregorio and Gregorio\TeX, look at the GregorioNabcRef documentation.  The commands listed here allow the manipulation of settings related to that notation.

\macroname{\textbackslash gresetnabcfont}{\{\#1\}\{\#2\}}{gregoriotex-nabc.tex}
Macro to set the font to be used for the ancient notation.

\begin{argtable}
	\#1 & string & the name of the font, either \texttt{gregall}, \texttt{grelaon}, or \texttt{gresgmodern}\\
	\#2 & integer & point size at which the font should be loaded\\
\end{argtable}

\subsection{Counts}\label{counts}

Each of the following counts controls some aspect of the configuration of the Gregorio\TeX\ score.  They are changed using \verb=\grechangecount=, documented above.

\begin{gcount}{additionaltopspacethreshold}
The threshold above which we start accounting notes above lines for additional
vertical space. For instance with a threshold of \texttt{2} and four line
staves, notes with a pitch of \texttt{k} and \texttt{l} will not interfere with
the space above lines.  Set it to a high value if you don't want high notes to
interfere with space above lines.
\end{gcount}

\begin{gcount}{additionaltopspacealtthreshold}
Same as \texttt{additionaltopspacethreshold} but setting the threshold for
notes taken into account with above lines text vertical placement.
\end{gcount}

\begin{gcount}{additionaltopspacenabcthreshold}
Same as \texttt{additionaltopspacethreshold} but setting the threshold for
notes taken into account with above lines nabc neume vertical placement
baseline.
\end{gcount}

\begin{gcount}{noteadditionalspacelinestextthreshold}
The number of low notes which will add space between the lines and the lyrics.  For instance, with a threshold of
\texttt{2}, every note below \texttt{c} will add space for each pitch needed below \texttt{c}, accounting for the various signs.
\end{gcount}

\subsection{Distances}\label{distances}

Each of the following distances controls some aspect of the spacing of the Gregorio\TeX\ score.  They are changed using \verb=\grechangedim=, documented above.  If the distance permits a rubber value, then the default value will indicate the stretch and shrink (even if they are zero by default).  Distances whose default value does not include a stretch or shrink may not take a rubber value.

While it may seem strange that many of these distances are defined to 5 decimal places in centimeters (much smaller than most people can see) this is a legacy of how these distances were originally defined in small points.  Since most people don’t know what small points are, the distances were converted to a unit more familiar to most people, but no rounding was applied to the conversions so that scores wouldn’t change their appearance as a result of the conversion.  Users should feel under no obligation to maintain this level of precision when adjusting them to suit their own tastes.

\textbf{Nota Bene:} Because of the way Gregorio\TeX\ handles distances, these cannot be manipulated as if they were normal \TeX\ dimensions or skips.  As a result they should only be changed using the command defined by Gregorio\TeX\ for this purpose.

\begin{gdimension}{additionallineswidth}
The additional width of the additional lines (\ie, the value added to the width of the glyph with which they're associated to get the width of the line).
\end{gdimension}

\begin{gdimension}{alterationspace}
Space between an alteration (flat or natural) and the next glyph.
\end{gdimension}

\begin{gdimension}{beforealterationspace}
When beginning of line shifts (bolshifts) are enabled, minimum space between a clef at the beginning of the line and a leading alteration glyph.  This distance should be larger than \texttt{clefflatspace} so that a flatted clef can be distinguished from a flat which is part of the first glyph on a line, but also smaller than \texttt{spaceafterlineclef}, the distance from the clef to the first notes.
\end{gdimension}

\begin{gdimension}{beforelowchoralsignspace}
Space before a low choral sign.
\end{gdimension}

\begin{gdimension}{clefflatspace}
Space between a clef and a flat (for clefs with flat).
\end{gdimension}

\begin{gdimension}{interglyphspace}
Space between glyphs in the same element.
\end{gdimension}

\begin{gdimension}{zerowidthspace}
Null space.
\end{gdimension}

\begin{gdimension}{halfspace}
Half-space between elements.
\end{gdimension}

\begin{gdimension}{interelementspace}
Space between elements.
\end{gdimension}

\begin{gdimension}{largerspace}
Larger space between elements.
\end{gdimension}

\begin{gdimension}{glyphspace}
Space between elements which has the size of a note.
\end{gdimension}

\begin{gdimension}{spacebeforeeolcustos}
Space before custos at the end of a line.
\end{gdimension}

\begin{gdimension}{spacebeforeinlinecustos}
Space before custos within a line.
\end{gdimension}

\begin{gdimension}{spacebeforesigns}
Space before punctum mora and augmentum duplex.
\end{gdimension}

\begin{gdimension}{moraadjustment}
When a syllable (bar or not) is shifted left because of a preceding punctum
mora, this space is also added. Use it to make the syllable a bit further from
the punctum mora if you want.
\end{gdimension}

\begin{gdimension}{moraadjustmentbar}
Same as previous one but specific to cases where puntum mora precedes a bar.
\end{gdimension}

\begin{gdimension}{spaceaftersigns}
Space after punctum mora and augmentum duplex.
\end{gdimension}

\begin{gdimension}{spaceafterlineclef}
Space after a clef at the beginning of a line.
\end{gdimension}

\begin{gdimension}{intersyllablespacenotes}
Minimum space between notes of different syllables.
\end{gdimension}

\begin{gdimension}{intersyllablespacestretchhyphen}
Stretching added in the case where the text of two syllables of the same word are
separated with an automatic hyphen.
\end{gdimension}

\begin{gdimension}{interwordspacenotes}
Minimum space between notes of syllables from different words.
\end{gdimension}

\begin{gdimension}{interwordspacetext}
Minimum space between texts of different words. Please keep the same \texttt{plus} and \texttt{minus} as \texttt{interwordspacenotes}.
\end{gdimension}

\begin{gdimension}{interwordspacenotes@alteration}
Same as \texttt{interwordspacenotes} for the case where the second syllable starts with an alteration.
\end{gdimension}

\begin{gdimension}{intersyllablespacenotes@alteration}
Same as \texttt{intersyllablespacenotes} for the case where the second syllable starts with an alteration.
\end{gdimension}

\begin{gdimension}{interwordspacenotes@euouae}
Same as \texttt{interwordspacenotes} for \texttt{euouae} blocks.
\end{gdimension}

\begin{gdimension}{interwordspacetext@euouae}
Same as \texttt{interwordspacetext} for \texttt{euouae} blocks.
\end{gdimension}

\begin{gdimension}{bitrivirspace}
Space between notes of a bivirga or trivirga.
\end{gdimension}

\begin{gdimension}{bitristrospace}
Space between notes of a bistropha or tristrophae.
\end{gdimension}

\begin{gdimension}{punctuminclinatumshift}
Space between two descending puncta inclinata.
\end{gdimension}

\begin{gdimension}{punctuminclinatumunisonshift}
Space between two unison puncta inclinata.
\end{gdimension}

\begin{gdimension}{beforepunctainclinatashift}
Space before puncta inclinata.
\end{gdimension}

\begin{gdimension}{punctuminclinatumanddebilisshift}
Space between a punctum inclinatum and a punctum inclinatum deminutus,
descending.
\end{gdimension}

\begin{gdimension}{punctuminclinatumdebilisshift}
Space between two punctum inclinatum deminutus.
\end{gdimension}

\begin{gdimension}{punctuminclinatumbigshift}
Space between descending puncta inclinata, larger ambitus (range=3rd).
\end{gdimension}

\begin{gdimension}{punctuminclinatummaxshift}
Space between descending puncta inclinata, larger ambitus (range=4th or 5th).
\end{gdimension}

\begin{gdimension}{descendingpunctuminclinatumascendingshift}
Space between descending puncta inclinata shapes in an ascent of pitch.
\end{gdimension}

\begin{gdimension}{ascendingpunctuminclinatumshift}
Space between two ascending puncta inclinata.
\end{gdimension}

\begin{gdimension}{ascendingpunctuminclinatumanddebilisshift}
Space between a punctum inclinatum and a punctum inclinatum deminutus,
ascending.
\end{gdimension}

\begin{gdimension}{ascendingpunctuminclinatumbigshift}
Space between ascending puncta inclinata, larger ambitus (range=3rd).
\end{gdimension}

\begin{gdimension}{ascendingpunctuminclinatummaxshift}
Space between ascending puncta inclinata, larger ambitus (range=4th or 5th).
\end{gdimension}

\begin{gdimension}{ascendingpunctuminclinatumdescendingshift}
Space between ascending puncta inclinata shapes in a descent of pitch.
\end{gdimension}

\begin{gdimension}{descendinginclinatumtonobarshift}
Space between a punctum inclinatum and a no-bar (stemless) glyph one pitch
below.
\end{gdimension}

\begin{gdimension}{descendinginclinatumtonobarbigshift}
Space between a punctum inclinatum and a no-bar (stemless) glyph two pitches
below.
\end{gdimension}

\begin{gdimension}{descendinginclinatumtonobarmaxshift}
Space between a punctum inclinatum and a no-bar (stemless) glyph three or four
pitches below.
\end{gdimension}

\begin{gdimension}{ascendinginclinatumtonobarshift}
Space between a punctum inclinatum and a no-bar (stemless) glyph one pitch
above.
\end{gdimension}

\begin{gdimension}{ascendinginclinatumtonobarbigshift}
Space between a punctum inclinatum and a no-bar (stemless) glyph two pitches
above.
\end{gdimension}

\begin{gdimension}{ascendinginclinatumtonobarmaxshift}
Space between a punctum inclinatum and a no-bar (stemless) glyph three or four
pitches above.
\end{gdimension}

\begin{gdimension}{ascendinginclinatumtonobarmaxshift}
Space between a punctum inclinatum and a no-bar (stemless) glyph three or four
pitches above.
\end{gdimension}

\begin{gdimension}{uprightpunctuminclinatumshift}
Space after after a non-punctum inclinatum and before the upright punctum inclinatum.
\end{gdimension}

\begin{gdimension}{maximumspacewithoutdash}
Maximal space between two syllables for which we consider a dash is not needed.
\end{gdimension}

\begin{gdimension}{afterclefnospace}
An extensible space for the beginning of lines.
\end{gdimension}

\begin{gdimension}{additionalcustoslineswidth}
Width of the additional lines, used only for the custos.  The width is the one for the custos at end of lines, the line for custos in the middle of a score is the same multiplied by 2.
\end{gdimension}

\begin{gdimension}{afterinitialshift}
Space between the initial and the beginning of the score.
\end{gdimension}

\begin{gdimension}{beforeinitialshift}
Space between the initial and the beginning of the score.
\end{gdimension}

\begin{gdimension}{minimalspaceatlinebeginning}
Minimal space in front of the lyrics at the beginning of a line when \texttt{bolshift}s are enabled.
\end{gdimension}

\begin{gdimension}{manualinitialwidth}
Space to force the initial width to.  Ignored when 0.
\end{gdimension}

\begin{gdimension}{minimalinitialwidth}
Minimum width of the initial.  Ignored when \texttt{manualinitialwidth} is non-zero.
\end{gdimension}

\begin{gdimension}{annotationseparation}
This space is the one between lines in the annotation (text above the initial).

\textbf{Nota Bene:} This is the absolute space.  If the lower line contains only short letters then it will get moved up so only this space shows (not the space above the letters on a normal line plus this space).  You should use struts to control the line height of the lower line if this is a problem.
\end{gdimension}

\begin{gdimension}{annotationraise}
Amount to raise (positive) or lower (negative) the annotation from its normal position (set with \verb=\gresetannotationby= and \verb=\gresetannotationvalign=).
\end{gdimension}

\begin{gdimension}{commentaryseparation}
This space is the one between lines in the commentary (text above the first staff line on the right).

\textbf{Nota Bene:} This is the absolute space.  If the lower line contains only short letters then it will get moved up so only this space shows (not the space above the letters on a normal line plus this space).  You should use struts to control the line height of the lower line if this is a problem.
\end{gdimension}

\begin{gdimension}{commentaryraise}
Distance from the commentary to the top line of the staff.
\end{gdimension}

\begin{gdimension}{noclefspace}
Space at the beginning of the lines if there is no clef.
\end{gdimension}

\begin{gdimension}{choralsigndownshift}
The distance to shift choral signs down.  The following choral signs are shifted down:

\begin{itemize}
	\item Low choral signs that are not lower than the note
	\item High choral signs which are in a space
	\item Low choral signs that are lower than the note which are in a space
\end{itemize}
\end{gdimension}

\begin{gdimension}{choralsignupshift}
The distance to shift choral signs up.  The following choral signs are shifted up:

\begin{itemize}
	\item High choral signs which are on a line
	\item Low choral signs that are lower than the note which are on a line
\end{itemize}
\end{gdimension}

\begin{gdimension}{translationheight}
The space for the translation.
\end{gdimension}

\begin{gdimension}{spaceabovelines}
The space above the lines.
\end{gdimension}

\begin{gdimension}{spacelinestext}
The space between the lines and the bottom of the text.
\end{gdimension}

\begin{gdimension}{spacebeneathtext}
The space beneath the text.
\end{gdimension}

\begin{gdimension}{abovelinestextraise}
Height of the text above the note line.
\end{gdimension}

\begin{gdimension}{abovelinestextheight}
Height that is added at the top of the lines if there is text above the lines (it must be bigger than the text for it to be taken into consideration).
\end{gdimension}

\begin{gdimension}{braceshift}
An additional shift you can give to the brace above the staff.
\end{gdimension}

\begin{gdimension}{curlybraceaccentusshift}
A shift you can give to the accentus above the curly brace.
\end{gdimension}

\begin{gdimension}{nabcinterelementspace}
Space between elements in ancient notation.
\end{gdimension}

\begin{gdimension}{nabclargerspace}
Larger space between elements in ancient notation.
\end{gdimension}

\begin{gdimension}{clivisalignmentmin}
When \verb=\gre@clivisalignment= is 2, this distance is the maximum length of the consonants after vowels for which the clivis will be aligned on its center.
\end{gdimension}

\begin{gdimension}{clefchangespace}
Space around a clef change.
\end{gdimension}

\begin{gdimension}{initialraise}
Distance the initial will be raised above its default baseline.  The default baseline for the initial coincides with the baseline for the text below the staff.
\end{gdimension}

\begin{gdimension}{overslurshift}
Distance an over-the-notes slur will be raised above the baseline of a note at the same height.
\end{gdimension}

\begin{gdimension}{underslurshift}
Distance an under-the-notes slur will be raised above the baseline of a note at the same height.
\end{gdimension}

\begin{gdimension}{divisiofinalissep}
Space separating the two bars of a divisio finalis.
\end{gdimension}

\begin{gdimension}{overhepisemalowshift}
Distance to place a a horizontal episema over a note in a low position in the space.
\end{gdimension}

\begin{gdimension}{overhepisemahighshift}
Distance to place a horizontal episema over a note in a high position in the space.
\end{gdimension}

\begin{gdimension}{underhepisemalowshift}
Distance to place a horizontal episema under a note in a low position in the space.
\end{gdimension}

\begin{gdimension}{underhepisemahighshift}
Distance to place a horizontal episema under a note in a high position in the space.
\end{gdimension}

\begin{gdimension}{hepisemamiddleshift}
Distance to place a horizontal episema in the middle of a space.
\end{gdimension}

\begin{gdimension}{vepisemalowshift}
Distance to place a vertical episema in a low position in the space.
\end{gdimension}

\begin{gdimension}{vepisemahighshift}
Distance to place a vertical episema in a high position in the space.
\end{gdimension}

\begin{gdimension}{linepunctummorashift}
Vertical distance to place a punctum mora for a note on a line.
\end{gdimension}

\begin{gdimension}{spacepunctummorashift}
Vertical distance to place a punctum mora for a note in a space.
\end{gdimension}

\begin{gdimension}{spaceamonepespunctummorashift}
Vertical distance to place a punctum mora for the second note (in a space) of a pes with ambitus one.
\end{gdimension}

\begin{gdimension}{lineporrectuspunctummorashift}
Vertical distance to place a punctum mora for the second note in a porrectus (or similar figure), on a line
\end{gdimension}

\begin{gdimension}{spaceporrectuspunctummorashift}
Vertical distance to place a punctum mora for the second note in a porrectus (or similar figure), in a space
\end{gdimension}

\begin{gdimension}{raresignshift}
Distance to place a ``rare'' sign above the top space in a score.
\end{gdimension}

\begin{gdimension}{bracketupshift}
Distance to shift a bracket up when the lowest note in the brackets is on a
line or below the staff.
\end{gdimension}

\begin{gdimension}{bracketdownshift}
Distance to shift a bracket down when the lowest note in the brackets is
neither on a line nor below the staff.
\end{gdimension}

\begin{gdimension}{parskip}
The effective \verb=\parskip= inside of a score.
\end{gdimension}

\begin{gdimension}{lineskip}
The effective \verb=\lineskip= inside of a score.
\end{gdimension}

\begin{gdimension}{baselineskip}
The effective \verb=\baselineskip= inside of a score.
\end{gdimension}

\begin{gdimension}{lineskiplimit}
The effective \verb=\lineskiplimit= inside of a score.
\end{gdimension}

\begin{gdimension}{shortspaceafterlineclef}
Space after a clef at the beginning of a line, when the clef and first note are vertically distant.
\end{gdimension}

\subsubsection{Bar distances}

\begin{gdimension}{bar@finalfinalis}
This space is added before the final divisio final of a score (old bar spacing algorithm only).
\end{gdimension}

Spaces around bars when they are typeset inside a syllable. The \verb=@short=
suffix for virgula and divisio minima indicates the space used when the notes
surrounding the bar are strictly lower than \texttt{g} (in a four-line score).
For divisio minimis, the \verb=@short= suffix is for notes lower than
\texttt{h}.  When applied to ``high'' positions (on the ledger line above
the staff), the \verb=@short= distances will be used for up to two pitches
higher.

\begin{gdimension}{bar@virgula}
\end{gdimension}

\begin{gdimension}{bar@virgula@short}
\end{gdimension}

\begin{gdimension}{bar@virgulaparen}
\end{gdimension}

\begin{gdimension}{bar@virgulaparen@short}
\end{gdimension}

\begin{gdimension}{bar@minimis}
\end{gdimension}

\begin{gdimension}{bar@minimis@short}
\end{gdimension}

\begin{gdimension}{bar@minima}
\end{gdimension}

\begin{gdimension}{bar@minima@short}
\end{gdimension}

\begin{gdimension}{bar@minimaparen}
\end{gdimension}

\begin{gdimension}{bar@minimaparen@short}
\end{gdimension}

\begin{gdimension}{bar@minor}
\end{gdimension}

\begin{gdimension}{bar@dominican}
\end{gdimension}

\begin{gdimension}{bar@maior}
\end{gdimension}

\begin{gdimension}{bar@finalis}
\end{gdimension}

Spaces around bars in standalone syllables, when these have text (new bar spacing algorithm only):

\begin{gdimension}{bar@virgula@standalone@text}
\end{gdimension}

\begin{gdimension}{bar@virgula@standalone@text@short}
\end{gdimension}

\begin{gdimension}{bar@virgulaparen@standalone@text}
\end{gdimension}

\begin{gdimension}{bar@virgulaparen@standalone@text@short}
\end{gdimension}

\begin{gdimension}{bar@minimis@standalone@text}
\end{gdimension}

\begin{gdimension}{bar@minimis@standalone@text@short}
\end{gdimension}

\begin{gdimension}{bar@minima@standalone@text}
\end{gdimension}

\begin{gdimension}{bar@minima@standalone@text@short}
\end{gdimension}

\begin{gdimension}{bar@minimaparen@standalone@text}
\end{gdimension}

\begin{gdimension}{bar@minimaparen@standalone@text@short}
\end{gdimension}

\begin{gdimension}{bar@minor@standalone@text}
\end{gdimension}

\begin{gdimension}{bar@dominican@standalone@text}
\end{gdimension}

\begin{gdimension}{bar@maior@standalone@text}
\end{gdimension}

\begin{gdimension}{bar@finalis@standalone@text}
\end{gdimension}

\begin{gdimension}{bar@finalfinalis@standalone@text}
\end{gdimension}

Spaces around bars in standalone syllables, when these have no text (new bar spacing algorithm only):

\begin{gdimension}{bar@virgula@standalone@notext}
\end{gdimension}

\begin{gdimension}{bar@virgula@standalone@notext@short}
\end{gdimension}

\begin{gdimension}{bar@virgulaparen@standalone@notext}
\end{gdimension}

\begin{gdimension}{bar@virgulaparen@standalone@notext@short}
\end{gdimension}

\begin{gdimension}{bar@minimis@standalone@notext}
\end{gdimension}

\begin{gdimension}{bar@minimis@standalone@notext@short}
\end{gdimension}

\begin{gdimension}{bar@minima@standalone@notext}
\end{gdimension}

\begin{gdimension}{bar@minima@standalone@notext@short}
\end{gdimension}

\begin{gdimension}{bar@minimaparen@standalone@notext}
\end{gdimension}

\begin{gdimension}{bar@minimaparen@standalone@notext@short}
\end{gdimension}

\begin{gdimension}{bar@minor@standalone@notext}
\end{gdimension}

\begin{gdimension}{bar@dominican@standalone@notext}
\end{gdimension}

\begin{gdimension}{bar@maior@standalone@notext}
\end{gdimension}

\begin{gdimension}{bar@finalis@standalone@notext}
\end{gdimension}

\begin{gdimension}{bar@finalfinalis@standalone@notext}
\end{gdimension}

\begin{gdimension}{spacearoundclefbars}
Additional space that will appear around bars that are preceded by a custos and followed by a key.
\end{gdimension}

\begin{gdimension}{bar@rubber}
A rubber value applied on both sides of all bars in standalone syllables, in new bar spacing algorithm only.

\textbf{Nota Bene:} This distance should always have a base value of 0pt.
\end{gdimension}

\begin{gdimension}{interwordspacetext@bars}
Minimum space between texts of different words when one of the syllable contains only a bar (new bar spacing algorithm only).
\end{gdimension}

\begin{gdimension}{interwordspacetext@bars@euouae}
Same as \texttt{interwordspacetext@bars} for \texttt{euouae} blocks (so quite rare).
\end{gdimension}

\begin{gdimension}{interwordspacetext@bars@notext}
Minimum space between texts of adjacent words when they are separated by a bar syllable which has no text associated with it (new bar spacing algorithm only).
\end{gdimension}

\begin{gdimension}{interwordspacetext@bars@notext@euouae}
Same as \texttt{interwordspacetext@bars@notext} for \texttt{euouae} blocks (so quite rare).
\end{gdimension}

\begin{gdimension}{textbartextspace}
Space between the text of previous syllable and the text associated with the bar (old bar spacing algorithm only).
\end{gdimension}

\begin{gdimension}{notebarspace}
Minimal space between a note and a bar.
\end{gdimension}

\begin{gdimension}{maxbaroffsettextleft}
Maximum distance by which the center of a bar and the center of its associated text can be separated, when the center of the text goes left of the center of the bar (new bar spacing algorithm only).
\end{gdimension}

\begin{gdimension}{maxbaroffsettextright}
Same as \texttt{maxbaroffsettextleft} but when the center of the text goes right of the center of the bar.
\end{gdimension}

\begin{gdimension}{maxbaroffsettextleft@nobar}
Maximum distance by which the center of a “no-bar” (\ie something like \texttt{*()} in gabc) and the center of its associated text can be separated, when the center of the text goes left of the center of the no-bar (new bar spacing algorithm only).
\end{gdimension}

\begin{gdimension}{maxbaroffsettextright@nobar}
Same as \texttt{maxbaroffsettextleft@nobar} but when the center of the text goes right of the center of the no-bar.
\end{gdimension}

\begin{gdimension}{maxbaroffsettextleft@eol}
Maximum distance by which the center of a bar and the center of its associated text can be separated, when the center of the text goes left of the center of the bar and the bar syllable contains a manual line break (new bar spacing algorithm only).
\end{gdimension}

\begin{gdimension}{maxbaroffsettextright@eol}
Same as \texttt{maxbaroffsettextleft@eol} but when the center of the text goes right of the center of the bar.
\end{gdimension}

\begin{gdimension}{alterationadjustmentbar}
In the case of an alteration after a bar, the alteration will go a bit left of this value. This can be compared to \texttt{moraadjustmentbar}.
\end{gdimension}

\subsection{Penalties}\label{penalties}
Penalties are used by \TeX\ to determine where line and page breaks should occur.  Gregorio\TeX\ modifies or defines a few of its own to help with that process in scores.  With the exception of \texttt{emergencystretch} (which should be changed using \verb=\grechangedim=) these should be changed using \verb=\grechangecount=, described above.

\begin{gcount}{brokenpenalty}
The vertical penalty inserted after a break on a clef change.
\end{gcount}

\begin{gcount}{clubpenalty}
The club penalty (determines how important it is to prevent orphans from occurring).
\end{gcount}

\begin{gcount}{widowpenalty}
The widow penalty (determines how important it is to prevent widows from occurring).
\end{gcount}

\macroname{emergencystretch}{}{gregoriotex-gsp-default.tex}
The value of the last ditch stretch for overfull boxes.  This should be set using \verb=\grechangedim=.

Default: \verb=\emergencystretch=

\begin{gcount}{endafterbarpenalty}
The end after bar penalty.
\end{gcount}

\begin{gcount}{endafterbaraltpenalty}{}{gregoriotex-gsp-default.tex}
The alternate end after bar penalty (used when there is no text under the bar).
\end{gcount}

\begin{gcount}{endofelementpenalty}{}{gregoriotex-gsp-default.tex}
The end of element penalty.
\end{gcount}

\begin{gcount}{endofsyllablepenalty}{}{gregoriotex-gsp-default.tex}
The end of element penalty.
\end{gcount}

\begin{gcount}{endofwordpenalty}{}{gregoriotex-gsp-default.tex}
The end of element penalty.
\end{gcount}

\begin{gcount}{hyphenpenalty}{}{gregoriotex-gsp-default.tex}
The hyphen penalty.
\end{gcount}

\begin{gcount}{nobreakpenalty}{}{gregoriotex-gsp-default.tex}
Penalty to prevent a line break.
\end{gcount}

\begin{gcount}{newlinepenalty}
Penalty to force a line break.
\end{gcount}

\begin{gcount}{finalpenalty}
The penalty applied after the final element of a score.
\end{gcount}

\macroname{looseness}{}{gregoriotex-gsp-default.tex}
The \TeX\ looseness within a score.

Default: \verb=\looseness=

\begin{gcount}{tolerance}
The \TeX\ tolerance within a score.  See \url{https://en.wikibooks.org/wiki/TeX/tolerance} for an explanation of what tolerance is.
\end{gcount}

\macroname{pretolerance}{}{gregoriotex-gsp-default.tex}
The \TeX\ pretolerance within a score.  See \url{https://en.wikibooks.org/wiki/TeX/pretolerance} for an explanation of what pretolerance is.

Default: $-1$ (Lua\TeX\ versions prior to 0.80) or \verb=\pretolerance= (versions after, and including, 0.80)]

\textit{Nota bene:} For more details on why this is necessary see the comments in gregoriotex-gsp-default.tex.





\subsection{Colors}\label{colors}
All colors can be redefined using \verb=\definecolor=.  See the
\verb=xcolor= (\LaTeX) or \verb=color= (Plain\TeX) package for documentation.

Example:\par\medskip
\begin{latexcode}
	\definecolor{gregoriocolor}{RGB}{229,53,44}
\end{latexcode}

\macroname{grebackgroundcolor}{}{gregoriotex.sty}
The color Gregorio\TeX\ uses to block out elements which have been printed,
but shouldn't show (\eg, the staff line going through the interior of
a punctum cavum).  The default is white.

\macroname{gregoriocolor}{}{gregoriotex.sty}
A red similar to that found in liturgical documents.  This is the color that Gregorio\TeX\ uses for text formatted with \texttt{<c></c>} tags in gabc.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "GregorioRef"
%%% End:
