Debian Codegraph @

texk/gregorio/gregorio-src/tex/gregoriotex.sty

raw
1 %GregorioTeX LaTeX style.
2 %
3 % Copyright (C) 2007-2025 The Gregorio Project (see CONTRIBUTORS.md)
4 %
5 % This file is part of Gregorio.
6 %
7 % Gregorio is free software: you can redistribute it and/or modify
8 % it under the terms of the GNU General Public License as published by
9 % the Free Software Foundation, either version 3 of the License, or
10 % (at your option) any later version.
11 %
12 % Gregorio is distributed in the hope that it will be useful,
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 % GNU General Public License for more details.
16 %
17 % You should have received a copy of the GNU General Public License
18 % along with Gregorio. If not, see <http://www.gnu.org/licenses/>.
19
20 \NeedsTeXFormat{LaTeX2e}%
21 \ProvidesPackage{gregoriotex}%
22 [2025/02/28 v6.1.0 GregorioTeX system.]% PARSE_VERSION_DATE_LTX
23
24 \RequirePackage{iftex}%
25 \RequireLuaTeX
26
27 % If gregoriosyms has been loaded then there are going to be some conflicts in the definitions made in that package and this one. In order to provide for a more informative error message, we check for that conflict right away
28 \ifcsname gregoriotex@symbols@loaded\endcsname\gre@error{Loading gregoriotex after\MessageBreak gregoriosyms is not supported. Please remove the\MessageBreak loading of gregoriosyms (its contents are loaded\MessageBreak by gregoriotex)}\fi%
29
30 \RequirePackage{xcolor}%
31 \RequirePackage{luacolor}%
32 \RequirePackage{kvoptions}%
33 \RequirePackage{graphicx}% for \resizebox
34 \RequirePackage{luatexbase}%
35 \RequirePackage{luaotfload}%
36 \RequirePackage{luamplib}%
37 \RequirePackage{xstring}%
38
39 \def\gre@error#1{\PackageError{GregorioTeX}{#1}{}}%
40 \def\gre@warning#1{\PackageWarning{GregorioTeX}{#1}}%
41 \def\gre@bug#1{\PackageError{GregorioTeX}{#1 !! This is a bug in Gregorio. Please report it at https://github.com/gregorio-project/gregorio/issues}{}}%
42 \def\gre@typeout{\typeout}
43 \long\def\gre@metapost#1{{%
44 \gre@localleftbox{}%
45 \gre@localrightbox{}%
46 \begin{mplibcode}
47 #1
48 \end{mplibcode}%
49 }}%
50
51 \SetupKeyvalOptions{prefix=gre@}
52 \DeclareStringOption{debug}[all]
53
54 % This option allows the user to transform all deprecation messages
55 % into errors. Allowing one to determine if the TeX file is compliant
56 % with future versions of gregoriotex. To enable, use gregoriotex with
57 % this option: allowdeprecated=false
58 \DeclareBoolOption[true]{allowdeprecated}
59
60 % Define these at first to do nothing because they need to manipulate
61 % flags which are declared in the package.
62 \DeclareVoidOption{nevercompile}{}
63 \DeclareVoidOption{forcecompile}{}
64 \DeclareVoidOption{autocompile}{}
65
66 \ProcessKeyvalOptions*
67
68 \let\gre@strip@pt\strip@pt
69
70 \long\def\gre@iflatex#1{#1}
71 \long\def\gre@ifnotlatex#1{}
72 \input gregoriotex-main.tex
73
74 % Now redefine these after loading the package because the options
75 % manipulate flags which are declared in the package.
76 \let\gre@nevercompile\undefined
77 \let\gre@forcecompile\undefined
78 \let\gre@autocompile\undefined
79
80 % These options control the global behavior of \includescore. The default, forceinclude, is the old behavior (no attempt to compile the score with gregorio is made, it is simply included as is). forcecompile is at the opposite end of the spectrum: all scores are compiled through gregorio at time of inclusion. autocompile strikes a balance by checking to see if the score needs to be recompiled and only doing so if it needs it (see the definition of \includescore in gregoriotex.tex for more details).
81 \DeclareVoidOption{nevercompile}{\gresetcompilegabc{never}}
82 \DeclareVoidOption{forcecompile}{\gresetcompilegabc{force}}
83 \DeclareVoidOption{autocompile}{\gresetcompilegabc{auto}}
84
85 \ExecuteOptions{autocompile}
86
87 \ProcessKeyvalOptions*
88
89 % we need to do this again because we processed the keyval options again
90 \gre@fixdebug%
91
92 % we hide lines only under LaTeX
93 \gresetlinesbehindalteration{invisible}
94 \gresetlinesbehindpunctumcavum{invisible}
95
96 %%%%%%%%%
97 %% Color definitions
98 %%%%%%%%%
99
100 \definecolor{grebackgroundcolor}{RGB}{255,255,255}%
101 \definecolor{gregoriocolor}{RGB}{229,53,44}%
102
103 %%%%%%%%%
104 %% LaTeX specific definitions for fonts
105 %%%%%%%%%
106
107 \def\GreItalic#1{%
108 {\itshape #1}%
109 \relax %
110 }
111
112 \def\GreSmallCaps#1{%
113 {\scshape #1}%
114 \relax %
115 }
116
117 \def\GreBold#1{%
118 {\bfseries #1}%
119 \relax %
120 }
121
122 \def\GreTypewriter#1{%
123 {\ttfamily #1}%
124 \relax %
125 }
126
127 \def\GreUnderline#1{%
128 \underline{#1}%
129 \relax %
130 }
131
132 \def\GreColored#1{%
133 {%
134 \color{gregoriocolor}#1%
135 }%
136 }
137
138
139 \def\gresetlinecolor#1{%
140 \gre@changestyle{normalstafflines}{\color[named]{#1}}[\relax]%
141 }
142
143
144 %%%%%%%%%%%%%%%%%%%%
145 %% Formatting environments
146 %%%%%%%%%%%%%%%%%%%%
147
148 \newenvironment{gre@style@initial}%
149 {\begingroup\fontsize{40}{40}\selectfont}%
150 {\endgroup}%
151
152 \newenvironment{gre@style@translation}%
153 {\begingroup\itshape}%
154 {\endgroup}%
155
156 \newenvironment{gre@style@abovelinestext}%
157 {\begingroup\small\itshape}%
158 {\endgroup}%
159
160 \newenvironment{gre@style@normalstafflines}%
161 {\begingroup}%
162 {\endgroup}%
163
164 \newenvironment{gre@style@additionalstafflines}%
165 {\begingroup\begin{gre@style@normalstafflines}}%
166 {\end{gre@style@normalstafflines}\endgroup}%
167
168 \newenvironment{gre@style@lowchoralsign}%
169 {\begingroup}%
170 {\endgroup}%
171
172 \newenvironment{gre@style@highchoralsign}%
173 {\begingroup}%
174 {\endgroup}%
175
176 \newenvironment{gre@style@firstsyllableinitial}%
177 {\begingroup}%
178 {\endgroup}%
179
180 \newenvironment{gre@style@firstsyllable}%
181 {\begingroup}%
182 {\endgroup}%
183
184 \newenvironment{gre@style@firstword}%
185 {\begingroup}%
186 {\endgroup}%
187
188 \newenvironment{gre@style@modeline}%
189 {\begingroup\begin{scshape}\begin{bfseries}}%
190 {\end{bfseries}\end{scshape}\endgroup}%
191
192 \newenvironment{gre@style@modemodifier}%
193 {\begingroup\begin{bfseries}\itshape\@@italiccorr}%
194 {\@@italiccorr\end{bfseries}\endgroup}%
195
196 \newenvironment{gre@style@modedifferentia}%
197 {\begingroup\begin{bfseries}}%
198 {\end{bfseries}\endgroup}%
199
200 \newenvironment{gre@style@annotation}%
201 {\begingroup}%
202 {\endgroup}%
203
204 \newenvironment{gre@style@commentary}%
205 {\begingroup\footnotesize\itshape}%
206 {\endgroup}%
207
208 \newenvironment{gre@style@elision}%
209 {\begingroup\small\itshape\@@italiccorr}%
210 {\@@italiccorr\endgroup}%
211
212 \newenvironment{gre@style@nabc}%
213 {\begingroup\color{gregoriocolor}}%
214 {\endgroup}%
215
216 \def\gre@changestyle#1#2[#3]{%
217 \renewenvironment{gre@style@#1}{\begingroup#2}{#3\endgroup}%
218 }%
219
220 %%%%%%%%%%%%%%%
221 %% Default Mode Numbering style
222 %%%%%%%%%%%%%%%
223
224 \gresetmodenumbersystem{roman-minuscule}%
225
226 %%%%%%%%%%%%%%%
227 %% protect against fancyhdr conflicts
228 %%%%%%%%%%%%%%%
229
230 \AddToHook{fancyhdr/before}{\directlua{gregoriotex.fancyhdr_toggle_callbacks()}}%
231 \AddToHook{fancyhdr/after}{\directlua{gregoriotex.fancyhdr_toggle_callbacks()}}%