Debian Codegraph @

texmf-dist/source/latex/guitar/guitar.dtx

raw
1 % \def\fileversion{1.6}\def\filedate{2009/03/17}\def\docdate{2013/11/26}
2 %\iffalse These lines are necessary for the doc and docstrip utilities
3 %<*asciidocu>
4
5 %%#
6 %%# Author and copyright 2001,2009,2013:
7 %%#
8 %%# M. V\"ath [email protected]
9 %%#
10 %%# The author thanks
11 %%# Donald Arseneau <[email protected]>
12 %%# Dan Luecking <[email protected]>
13 %%# Heiko Oberdiek <[email protected]>
14 %%# and a colleague who does not want to be named here.
15
16 %%# The package may be distributed and/or modified under the conditions of
17 %%# the LaTeX Project Public License (version 1.3c or later).
18
19 %%#############################################################################
20 %%#
21 %%# guitar.sty - typesetting guitar chords over song texts.
22 %%#
23 %%#############################################################################
24
25 %%#
26 %%# This package should run with plain TeX, LaTeX 2.09, and LaTeX 2e.
27 %%# Actually, it should run with all TeX formats.
28 %%#
29
30 %%# This is not the only package available for typesetting guitar songs.
31 %%# The following packages are also available (and possibly also others:
32 %%# I do not claim that this list is complete).
33 %%#
34 %%# 1. gchords.sty http://www.damtp.cam.ac.uk/user/kp229/gchords/
35 %%# 2. songbook.sty http://www.rath.ca/Misc/Songbook/
36 %%# or on CTAN: macros/latex/contrib/supported/songbook/
37 %%# 3. guitarTeX (which is not a `pure' (La)TeX solution):
38 %%# http://rz-home.de/~jmiltz/guitartex/
39 %%#
40 %%# The packages 1. and 2. have somewhat different intentions.
41 %%# It should be possible to combine them with the current package
42 %%# without any severe problems.
43
44 % If you have access to (reasonable new) docstrip TeXfiles, you should run
45 % tex/latex on the file
46 % `guitar.ins'
47 % to produce the files `guitar.sty', `guitar.txt' and `guitar.tex'.
48 % (In case `guitar.ins' is lost: You can find its content in the last
49 % few lines of the file you are currently reading between the
50 % lines %<*insfile> and %</insfile>;
51 % BTW: You should name this file here `guitar.dtx' before you run tex
52 % on guitar.ins).
53 %
54 % The file `guitar.txt' contains a `brief' (but complete) ascii
55 % documentation. If you have additionally access to LaTeX 2e, you may run
56 % latex on the generated file `guitar.tex' to produce `guitar.dvi' which
57 % contains a more luxury documentation.
58 %
59 % If you do not have access to the docstrip TeXfiles you may simply
60 % copy/rename this file here into
61 % `guitar.sty'
62 % to use the package and read the ascii documentation in this file.
63 % The ascii documentation (the content of `guitar.txt') consists of all
64 % lines in this file which start with %%# (this is the above block and another
65 % (very large) block which follows soon).
66 %
67 % But I do not recommended this, because TeX will need more time to read this
68 % longer file, and because there might be a (very slight) incompatibility if
69 % you use it (namely if you load `guitar.sty' with some *extremely* strange
70 % catcodes).
71 % I recommend in this case instead to generate the file `guitar.sty' as
72 % anything between the lines %<*package> and %</package> by hand.
73 % (This is not precisely the file which you get with the docstrip TeXfiles,
74 % but a reasonable good substitute. To speed up loading, you may also
75 % eliminate all lines starting with `% ' in `guitar.sty').
76 % For your information: The file `guitar.tex' produced by the docstrip
77 % TeXfiles is anything between the lines %<*driver> and %</driver>
78 % (with a line containing \endinput and two comment lines appended)
79 %
80 %
81 % In any case, you end up with the file `guitar.sty'.
82 %
83 % If you can generate `guitar.tex', you will probably want to stop
84 % reading now and instead read the `luxury' documentation in `guitar.dvi'.
85 %
86 % Otherwise, you have to make due with the following ascii documentation.
87 %
88 %
89 % \fi\catcode\#14\relax\iffalse (This line is needed for the doc utility)
90 %
91
92 %%# To use guitar, you have to put `guitar.sty' in a path where TeX looks
93 %%# for its input files. The TeX documents using guitar need the
94 %%# following modifications in their header:
95 %%#
96 %%# a) If you use LaTeX2.09, use guitar as a style option, e.g.
97 %%# \documentstyle[guitar]{article}
98 %%# or
99 %%# \documentstyle[guitar,12pt]{article}
100 %%# b) If you use LaTeX2e, put in the preamble the command
101 %%# \usepackage{guitar}
102 %%# c) If you use some other (non-LaTeX) format, you will probably have to
103 %%# insert a line like
104 %%# \catcode`\@=11\input guitar.sty\catcode`\@=12\relax
105 %%#
106 %%# For TeX-insiders:
107 %%# The only LaTeX-specific commands used in `guitar.sty' are:
108 %%#
109 %%# \newenvironment
110 %%# \newcommand (only in the form \newcommand{\command}{} to ensure that
111 %%# \command was not defined before)
112 %%# \newsavebox
113 %%# \newlength
114 %%# \RequirePackage
115 %%# \ProvidesPackage
116 %%# \typeout
117 %%#
118 %%# The above commands are used only if they are defined
119 %%# (otherwise, the plainTeX are used).
120 %%#
121
122 %%#
123 %%# Usage:
124 %%#
125
126 %%# The general usage is very simple:
127 %%#
128 %%# \guitarChord{Bb}Really. \guitarChord{G#}Oh yes.
129 %%#
130 %%# This puts the chord "B flat" and "G sharp" over the "R" resp. "O".
131 %%# (in the chord, "b" and "#" always translate into "flat" resp. "sharp").
132 %%# When you switch into "magic" mode, you can even use [...] instead of
133 %%# \guitarChord{...}.
134 %%# E.g., in LaTeX, you can just write
135 %%#
136 %%# \begin{guitar}
137 %%# [Cm]This [Bb]is a [G#]very [Gm]simple song.
138 %%# You can still use any [\TeX]macros in the chord text.
139 %%# Actually, each accord reads a second argument over
140 %%# which it is [A]{centered}.
141 %%# By default, the linefeeds in the source lead to linebreaks %
142 %%# in the output, unless you put a percentage sign at the end of the line. %
143 %%# If a single line gets too long, the wrapped lines are right-aligned.
144 %%# To force the wrapping use \verb|\newline|\newline like here.
145 %%# To stretch the first line, use \verb|\linebreak|\linebreak like here.
146 %%#
147 %%# Two subsequent linefeeds in the source start a new verse.
148 %%#
149 %%#
150 %%# Three or more subsequent linefeeds in the source start a new verse with a %
151 %%# slightly larger space.
152 %%#
153 %%# Unfortunately, if the chords get too long, they may [Ebm+7]o[G#]verlap.
154 %%# To avoid this, the following solutions are supported:
155 %%#
156 %%# 1. If the token after your chord is a space, like in "[Ebm+7] space",
157 %%# this space is stretched.
158 %%# Note that this is different from the notation "[Ebm+7]{ }space".
159 %%# 2. Inside words, put a _ at the end like for [Ebm+7_]O[G#]K.
160 %%# 3. Outside words, put a | at the end like for [Ebm+7|]{OK}[G#|].
161 %%# If the chord is short enough (compared to its argument) then the symbols
162 %%# | and _ do not harm like in [E|]{long} or [E_]{long}er.
163 %%#
164 %%# You may (and in plainTeX you must) replace "\begin{guitar}" and
165 %%# "\end{guitar}" by "\guitarOn" and "\guitarOff", respectively.
166 %%#
167 %%# If you only want to put the guitar chords as above but do not like the
168 %%# feature concerning the linefeeds, you can use the environment
169 %%# \begin{guitarMagic}
170 %%# \end{guitarMagic}
171 %%# or the respective commands \guitarMagicOn and \guitarMagicOff.
172 %%# Similarly, you can also use only the linefeed feature by the environment
173 %%# \begin{guitarCr}
174 %%# \end{guitarCr}
175 %%# or the respective commands \guitarCrOn and \guitarCrOff.
176 %%#
177 %%# As a matter of fact, you can also e.g. use \guitarCrOff *within* a
178 %%# {guitar} environment, but then you have to use \guitarCrOn before you
179 %%# end the environment to have a proper nesting of modes.
180 %%#
181
182 %%#
183 %%# Customization
184 %%#
185
186 %%# The output of the "#" and "b" tokens in the chords is generated by the two
187 %%# commands
188 %%#
189 %%# \guitarSharp
190 %%# \guitarFlat
191 %%#
192 %%# Thus, for, example the customization
193 %%#
194 %%# \def\guitarSharp{$^{\sharp}$}
195 %%#
196 %%# will make the sharp symbol be written as an upper index.
197
198 %%# In a similar way, the macros
199 %%#
200 %%# \guitarEndLine
201 %%# \guitarEndPar
202 %%# \guitarEndDoublePar
203 %%#
204 %%# are expanded when the song text contains one, two, or three (or more)
205 %%# linefeeds.\par
206
207 %%# After the macro
208 %%#
209 %%# \guitarNoChord
210 %%#
211 %%# has been used, no chords are output anymore. You can make the effect
212 %%# local by putting this command in a group. (\guitarNoChord redefines the
213 %%# macros which are responsible for the actual output of the chords - see the
214 %%# description at the end).
215 %%#
216 %%# The command
217 %%#
218 %%# \guitarPreAccord
219 %%#
220 %%# is expanded before the actual chord is typeset: You can change this
221 %%# definition to e.g. modify the font used for the chord. By default, this
222 %%# command contains a \strut which ensures that the lines with chords
223 %%# usually all have the same height.
224 %%# The macro \guitarPreAccord may also use and modify the macro
225 %%#
226 %%# \guitarAccord
227 %%#
228 %%# which contains the actual chord which is then output (you may use this
229 %%# feature to e.g. calculate a modulation in \guitarPreAccord or to
230 %%# replace the text of \guitarAccord by some graphic equivalent).
231 %%#
232 %%# It is guaranteed that the macros \guitarPreAccord and \guitarAccord
233 %%# are expanded precisely once.
234 %%# In contrast, it might happen that the argument of the chord (i.e. the
235 %%# text over which the chord is put) is expanded twice.
236 %%# (The doubled expansion could have been avoided, but the price were that
237 %%# in some cases the TeX kerning mechanism would then fail if the argument
238 %%# is a syllable of some word which is continued afterwards).
239 %%#
240 %%# Whenever the "guitar" mode or the "linefeed" mode is turned
241 %%# on or off, the corresponding macro
242 %%#
243 %%# \guitarMagicOnHook
244 %%# \guitarMagicOffHook
245 %%# \guitarCrOnHook
246 %%# \guitarCrOffHook
247 %%#
248 %%# is expanded (for switching on, the macro is expanded even before the
249 %%# necessary catcode changes are done, and for switching off, the macro
250 %%# is expanded after the catcodes have been restored).
251 %%# In the current defaults, a group is opened and closed in
252 %%# \guitarCrOnHook and \guitarCrOffHook: This is the reason why these
253 %%# commands must be properly nested.
254 %%# (The reason for this group is that"\parindent should be changed locally).
255 %%#
256 %%# In the current implementation, TeX forgets everything following the magic
257 %%# tokens "|" and "_" in the chord (because these symbols are intended to be
258 %%# the last one in the chord). If you want to use these tokens within a chord:
259 %%# They loose their magic meaning if they occur in a braced context
260 %%# (i.e. between { and }). If you regularly have to use these tokens within
261 %%# chords, you can change the default choice of this tokens by the respective
262 %%# commands
263 %%#
264 %%# \toolboxMakeSplit{token}{guitarSplitDist}
265 %%# \toolboxMakeSplit{token}{guitarSplitMerge}
266 %%#
267 %%# (See the "toolbox" package for details of the command \toolboxMakeSplit
268 %%# used here).
269 %%# It should be pointed out that {token} may actually be a *sequence*
270 %%# of tokens, so that for the `magic tokens' "|" and "_" you may instead use
271 %%# whole phrases if you prefer.
272 %%#
273 %%# Some fine tuning of the spacing can be done by redefining
274 %%#
275 %%# \guitarCalcDim
276 %%#
277 %%# When this macro is called, the skip register
278 %%#
279 %%# \guitarDim
280 %%#
281 %%# contains the width of the chord which should be put over the text.
282 %%# After \guitarCalcDim has been expanded, it is ensured that at least
283 %%# \guitarDim (horizontal) space is reserved for the chord. Thus, if
284 %%# \guitarCalcDim increases e.g. \guitarDim by 2pt (which is the
285 %%# default behavior of \guitarCalcDim), then 2pt more space is reserved
286 %%# for the chord than its actual size: This ensures that two subsequent
287 %%# chords are always separated by some space.
288 %%#
289 %%# Finally, you can modify the macros which do the actual setting of the
290 %%# chords: This setting is done by the commands
291 %%#
292 %%# \guitarPut
293 %%# \guitarPutOnSpace
294 %%# \guitarPutDist
295 %%# \guitarPutMerge
296 %%#
297 %%# which with the exception of \guitarPutOnSpace all expect one argument
298 %%# (namely the text on which they should be put). The command
299 %%# \guitarPutOnSpace is called, if a space followed the chord argument.
300 %%# Similarly, \guitarPutDist and \guitarPutMerge are called if the chord
301 %%# argument ended with the magic symbol "|" respectively "_".
302 %%# Before one of the above four macros is called, the chord text is stored in
303 %%# the macro \guitarAccord (and has not been expanded to this time); also the
304 %%# argument has not been expanded to this time. The above four macros are also
305 %%# responsible for the appropriate expansion (also of the expansion of the
306 %%# macros \guitarCalcDim and \guitarPreAccord, if
307 %%# the latter should still keep their meaning).
308 %%# The above four macros may freely use the skip register \guitarDim and the
309 %%# box register \guitarBox (which are both not used or
310 %%# modified by the other macros of this package).
311 %%#
312
313 %%#
314 %%# Possible Problems:
315 %%#
316
317 %%# The special treatment of [ # b and linefeed is implemented by a changing of
318 %%# catcodes. This may cause essentially two sorts of problems:
319 %%#
320 %%# 1. In some cases, you will want to avoid the automatic replacement of '#'
321 %%# and 'b'. For example, in [\textbf{F#}] or in \guitarChord{\textbf{F#}}
322 %%# the "b" of "\textbf" gets replaced which is of course not what you want.
323 %%# To avoid this replacement, there is a * version of the respective
324 %%# commands, i.e. the above example works in the intended way if you write
325 %%# instead [*\textbf{F\guitarSharp}] or
326 %%# \guitarChord*{\textbf{F\guitarSharp}}
327 %%# (you have to use the command "\guitarSharp", because due to the * also
328 %%# the # would not be replaced).
329 %%#
330 %%# 2. There are some situations in which catcodes are set too early,
331 %%# e.g. if you use the macros within the argument of certain macros.
332 %%# In this case, these symbols keep their usual \TeX\ meaning
333 %%# (which may either lead to an error in case of "#" (and sometimes "[") or
334 %%# just to a false output). If this happens to you, you have to replace at
335 %%# the corresponding place the above one-symbol shortcuts by their longer
336 %%# macro equivalents. In other words: You might have to replace in
337 %%# certain special situations some occurrences of the symbols according to
338 %%# the following table:
339 %%#
340 %%# [...] -> \guitarChord{...}
341 %%# # -> \guitarSharp
342 %%# b -> \guitarFlat
343 %%# linefeed -> \guitarEndLine
344 %%# 2 linefeeds -> \guitarEndPar
345 %%# 3+ linefeeds -> \guitarEndDoublePar
346 %%#
347
348
349 % This is the end of the ascii documentation
350 %</asciidocu>
351 %\fi\catcode\#6\relax
352 %
353 % \iffalse
354 %<*metainfo>
355 % \fi
356
357 % \def\basename{guitar}
358
359 %% \CharacterTable
360 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
361 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
362 %% Digits \0\1\2\3\4\5\6\7\8\9
363 %% Exclamation \! Double quote \" Hash (number) \#
364 %% Dollar \$ Percent \% Ampersand \&
365 %% Acute accent \' Left paren \( Right paren \)
366 %% Asterisk \* Plus \+ Comma \,
367 %% Minus \- Point \. Solidus \/
368 %% Colon \: Semicolon \; Less than \<
369 %% Equals \= Greater than \> Question mark \?
370 %% Commercial at \@ Left bracket \[ Backslash \\
371 %% Right bracket \] Circumflex \^ Underscore \_
372 %% Grave accent \` Left brace \{ Vertical bar \|
373 %% Right brace \} Tilde \~}
374
375 % \CheckSum{532}
376
377 % \iffalse
378 % \RecordChanges
379 % \fi
380 % \def\mypar{}
381 % \def\ChangesTab{}\let\orichanges\changes
382 % \def\changes#1#2#3{\orichanges{#1}{#2}{#3}
383 % \expandafter\def\expandafter\ChangesTab\expandafter{\ChangesTab
384 % \item[v#1 {\mdseries(\emph{#2})}] {#3.}}}
385 % \newcommand{\cmdcite}[1]{\texttt{\textbackslash#1}}
386 % \newcommand{\filecite}[1]{\texttt{#1}}
387 %
388 % \changes{1.6}{2013/11/26}{Update email, clarify license. Date/version remains the
389 % same since only commments and documentation are modified}
390 % \changes{1.6}{2009/03/17}{Do not redefine commands on new catcodes globally.
391 % Instead save and restore the original definition when changing catcodes.
392 % Thanks to Heiko Oberdiek for pointing out this bug}
393 % \changes{1.5}{2001/08/27}{Included references to other packages in
394 % documentation; slightly modified the \cmdcite{typeout} of the package name}
395 % \changes{1.4}{2001/08/27}{Introduced \texttt{*} versions to avoid changing
396 % of catcodes in special situation}
397 % \changes{1.3}{2001/08/24}{Improved technique of right-alignment thanks to
398 % valuable hints of Donald Arseneau \texttt{<[email protected]>}. Introduced
399 % \cmdcite{\guitarFirstLeft} and made \cmdcite{guitarFirstFlush} the default}
400 % \changes{1.2}{2001/08/21}{Right-alignment of broken lines. Added remarks
401 % about catcode-changes in the documentation}
402 % \changes{1.1}{2001/08/19}{First release}
403 %
404 % \iffalse
405 %
406 % The following part is the code needed to compile the documentation.
407 % We do some trickery here, because we want that this file here could be used
408 % for *both*: Compiling the documentation *and* as `guitar.sty'
409 % (if really required).
410 % Everything between the lines %<*driver> and %</driver>
411 % goes to the file `guitar.tex'.
412 %
413 % \fi
414 \ifcat @a% If this test is positive, then `@' has letter catcode which means
415 % that this file is loaded as a style file (or as described in the
416 % install section of the documentation).
417 \def\TemporaryDummy{}
418 \else\long\def\TemporaryDummy{%
419 %
420 %
421 % \iffalse
422 %</metainfo>
423 %<*driver>
424 \documentclass{ltxdoc}
425 \usepackage{guitar}
426 \OnlyDescription%% Comment this out, or
427 %%\AlsoImplementation%% uncomment this line, if you want to see the source.
428
429 %% If you want an index, uncomment one of the following lines.
430 %% After running latex a first time, you have to use
431 %% makeindex -s gind.ist guitar
432 %% Then run latex again.
433 %%\CodelineIndex% comment this out if you want an index referring to codelines
434 %%\PageIndex% comment this out if you want an index referring to pages
435 %%\OldMakeindex% uncomment this line, if your MakeIndex is pre-v2.9
436
437 \setlength\hfuzz{15pt}
438 \hbadness=7000
439 \begin{document}
440 \DocInput{guitar.dtx}
441 \end{document}
442 %</driver>
443 %<*metainfo>
444 % \fi
445 }
446 \fi\TemporaryDummy\let\TemporaryDummy\undefined
447 %
448 % \iffalse
449 % Personal macros used for the doc utility:
450 % \fi
451 % \MakeShortVerb{"}
452 % \def\bracemeta#1{\texttt{\{}\meta{#1}\texttt{\}}}
453 % \def\cmdmeta{\textbackslash\meta}
454 % \def\nocomment{}
455 % \def\myspace{\texttt{\textvisiblespace}}
456 % \toolboxMakeSplit{/}{guitarSplitDist}
457
458 % \title{The \texttt{guitar} package\thanks
459 % {This package has version number \fileversion, last revised \filedate.
460 % The package may be distributed and/or modified under the conditions of the
461 % LaTeX Project Public License, either version 1.3c of this license or (at
462 % your option) any later version. The latest version of this license is in
463 % \texttt{http://www.latex-project.org/lppl.txt}, and version 1.3c or later
464 % is part of all distributions of LaTeX version 2005/12/01 or later.}}
465 % \author{Martin V\"ath\relax
466 %\thanks{\texttt{[email protected]}}
467 %{}\thanks{The author thanks
468 % Donald Arseneau \texttt{<[email protected]>},
469 % Dan Luecking \texttt{<[email protected]>},
470 % and a colleague who does not want to be named here.}}
471 % \date{\docdate}
472 % \maketitle
473
474 % \begin{abstract}
475 % This package allows you to typeset guitar chords over song texts.
476 % This package requires the \filecite{toolbox} package.
477 % To typeset graphical chords, you need an additional package like e.g.\
478 % \filecite{gchords.sty}, available from
479 % \texttt{http://www.damtp.cam.ac.uk/user/kp229/gchords/}
480 % \end{abstract}
481
482 % This is not the only package available for typesetting guitar songs.
483 % The following packages are also available (and possibly also others:
484 % I do not claim that this list is complete).
485 % \begin{enumerate}
486 % \item \filecite{gchords.sty};
487 % \texttt{http://www.damtp.cam.ac.uk/user/kp229/gchords/}
488 % \item \filecite{songbook.sty};
489 % \texttt{http://www.rath.ca/Misc/Songbook/}\newline
490 % (or on CTAN: \texttt{macros/latex/contrib/supported/songbook/})
491 % \item guitar\TeX\ (which is not a `pure' (La)\TeX solution):\newline
492 % \texttt{http://rz-home.de/\~{ }jmiltz/guitartex/}
493 % \end{enumerate}
494 % The packages 1.\ and 2.\ have somewhat different intentions.
495 % It should be possible to combine them with the current package
496 % without any severe problems.
497
498 % \tableofcontents
499
500 %
501 % \section{Changes}
502 %
503 % \begin{description}
504 % \def\mypar{\par}\ChangesTab
505 % \end{description}
506 %
507 %
508 % \section{Installation}
509 %
510 % This package should run with plain \TeX, \LaTeX 2.09, and \LaTeXe.
511 % Actually, it should actually run with all \TeX\ formats.
512
513 % To use \filecite{guitar}, you have to put the file \filecite{guitar.sty}
514 % in a path where \TeX\ looks for its input files. The \TeX\ documents using
515 % \filecite{guitar} need the following modifications in their header:
516 %
517 % \begin{itemize}
518 % \item If you use \LaTeXe, put in the preamble the command
519 % \begin{verbatim}
520 % \usepackage{guitar}\end{verbatim}
521 %
522 % \item If you use \LaTeX 2.09, use "guitar" as a style option, e.g.\
523 % \begin{verbatim}
524 % \documentstyle[guitar]{article}\end{verbatim}
525 % or
526 % \begin{verbatim}
527 % \documentstyle[guitar,12pt]{article}\end{verbatim}
528 %
529 % \item If you use some other (non-\LaTeX) format, you will probably have to
530 % insert a line like
531 % \begin{verbatim}
532 % \catcode`\@=11\input guitar.sty\catcode`\@=12\relax\end{verbatim}
533 %
534 % \end{itemize}
535 %
536 % For \TeX-insiders:
537 % The only \LaTeX-specific commands used in "guitar.sty" are:
538 %
539 % \begin{itemize}
540 % \item "\newenvironment"
541 % \item "\newcommand" (used only in the form "\newcommand{"\meta{command}"}{}"
542 % to ensure that \meta{command} was not defined before)
543 % \item "\newsavebox"
544 % \item "\newlength"
545 % \item "\RequirePackage"
546 % \item "\ProvidesPackage"
547 % \item "\typeout"
548 % \end{itemize}
549 % The above commands are used only if they are defined
550 % (otherwise, the plain\TeX\ substitutes are used).
551 %
552 % \section{Example and Usage}
553 %
554 % The general usage is very simple:
555 % \DescribeMacro{\guitarChord}\begin{verbatim}
556 % \guitarChord{Bb}Really. \guitarChord{G#}Oh yes.\end{verbatim}
557 % produces the output
558 % \begin{quote}
559 % \guitarChord{Bb}Really. \guitarChord{G#}Oh yes.
560 % \end{quote}
561 % (in the chord, "b" and "#" always translate into $\flat$ resp. $\sharp$).
562 % When you switch into ``magic'' mode, you can even use "[...]" instead of
563 % "\guitarChord{...}".
564 % E.g., in \LaTeX, you can just write
565 % \DescribeEnv{guitar}\begin{verbatim}
566 %\begin{guitar}
567 %[Cm]This [Bb]is a [G#]very [Gm]simple song.
568 %You can still use any [\TeX]macros in the chord text.
569 %Actually, each accord reads a second argument over which it is [A]{centered}.
570 %By default, the linefeeds in the source lead to linebreaks %
571 %in the output, unless you put a percentage sign at the end of the line. %
572 %If a single line gets too long, the wrapped lines are right-aligned.
573 %To force the wrapping use \verb|\newline|\newline like here.
574 %To stretch the first line, use \verb|\linebreak|\linebreak like here.
575 %
576 %Two subsequent linefeeds in the source start a new verse.
577 %
578 %
579 %Three or more subsequent linefeeds in the source start a new verse with a %
580 %slightly larger space on top.
581 %\end{guitar}\end{verbatim}
582 % This will produce the output
583 % \begin{quote}
584 % \begin{guitar}
585 % [Cm]This [Bb]is a [G#]very [Gm]simple song.
586 % You can still use any [\TeX]macros in the chord text.
587 % Actually, each accord reads a second argument over which it is ^^A
588 % [A]{centered}.
589 % By default, the linefeeds in the source lead to linebreaks ^^A
590 % in the output, unless you put a percentage sign at the end of the line. ^^A
591 % If a single line gets too long, the wrapped lines are right-aligned.
592 % To force the wrapping use "\newline"\newline like here.
593 % To stretch the first line, use "\linebreak"\linebreak like here.
594 %
595 % Two subsequent linefeeds in the source start a new verse.
596 %
597 %
598 % Three or more subsequent linefeeds in the source start a new verse with a ^^A
599 % slightly larger space on top.
600 % \end{guitar}\end{quote}
601 % \noindent
602 % Unfortunately, if the chords get too long, they may overlap.
603 % For example, "[Ebm+7]O[G#]K" produces the unreadable output
604 % \begin{guitar}[Ebm+7]O[G#]K\end{guitar}.
605 % To avoid this, the following solutions are supported:
606 % \begin{enumerate}
607 % \item
608 % If the token after your chord is a space, like in ``"a[Ebm+7] space"'', this
609 % space is stretched: \begin{guitar}a[Ebm+7] space\end{guitar}.
610 % Note that this is different from the notation "a[Ebm+7]{ }space" which
611 % produces instead: \begin{guitarMagic}a[Ebm+7]{ }space\end{guitarMagic}.
612 % \item
613 % Inside words, you can put a "_" at the end like for "[Ebm+7_]O[G#]K".
614 % This stretches the word: \begin{guitarMagic}[Ebm+7_]O[G#]K\end{guitarMagic}.
615 % \item
616 % Outside words, you can put a "|" at the end like for
617 % "[Ebm+7|]{OK}[G#|].[C#m]"\textvisiblespace\,:
618 % \begin{guitarMagic}[Ebm+7/]{OK}[G#/].[C#m] \end{guitarMagic}
619 % \end{enumerate}
620 % If the chord is short enough (compared to its argument) then the symbols
621 % "|" and "_" do not harm: "[E|]{long}" and "[E_]{long}er" produce
622 % \begin{guitarMagic}[E/]{long} and [E_]{long}er\end{guitarMagic}.\bigskip\par
623 %
624 % You may (and in plain\TeX\ you must) replace "\begin{guitar}" and
625 % "\end{guitar}" by \DescribeMacro{\guitarOn}"\guitarOn" and
626 % \DescribeMacro{\guitarOff}"\guitarOff", respectively.
627 %
628 % If you only want to put the guitar chords as above but do not like the
629 % feature concerning the linefeeds, you can use the environment
630 % \begin{verbatim}
631 % \begin{guitarMagic}
632 % \end{guitarMagic}\end{verbatim}\DescribeEnv{guitarMagic}
633 % or the respective commands
634 % \DescribeMacro{\guitarMagicOn}"\guitarMagicOn" and
635 % \DescribeMacro{\guitarMagicOff}"\guitarMagicOff".
636 % Similarly, you can also use only the linefeed feature by the environment
637 % \begin{verbatim}
638 % \begin{guitarCr}
639 % \end{guitarCr}\end{verbatim}\DescribeEnv{guitarCr}
640 % or the respective commands \DescribeMacro{\guitarCrOn}"\guitarCrOn" and
641 % \DescribeMacro{\guitarCrOff}"\guitarCrOff".
642 %
643 % As a matter of fact, you can also e.g.\ use "\guitarCrOff" \emph{within} a
644 % "{guitar}" environment, but then you have to use "\guitarCrOn" before you
645 % end the environment to have a proper nesting of modes.
646 %
647 % \section{Customization}
648 %
649 % If you want that the first line in a broken phrase is always left-aligned
650 % (i.e.\ the spaces between words are not enlarged to fill the line), enter
651 % before your line the command
652 % \begin{quote}
653 % \DescribeMacro{\guitarFirstLeft}"\guitarFirstLeft"
654 % \end{quote}
655 % You can switch back into the default mode with
656 % \begin{quote}
657 % \DescribeMacro{\guitarFirstLeft}"\guitarFirstFlush"
658 % \end{quote}
659 % The output of the "#" and "b" tokens in the chords is generated by the two
660 % commands
661 % \begin{quote}
662 % \DescribeMacro{\guitarSharp}"\guitarSharp"\\
663 % \DescribeMacro{\guitarFlat}"\guitarFlat".
664 % \end{quote}
665 % Thus, for, example the customization
666 % \begin{verbatim}
667 % \def\guitarSharp{$^{\sharp}$}\end{verbatim}
668 % will make the chord "[F#]" look like {\footnotesize F$^{\sharp}$}
669 % (instead of the default {\footnotesize F$\sharp$}).\par
670 %
671 % In a similar way, the macros
672 % \begin{quote}
673 % \DescribeMacro{\guitarEndLine}"\guitarEndLine"\\
674 % \DescribeMacro{\guitarEndPar}"\guitarEndPar"\\
675 % \DescribeMacro{\guitarEndDoublePar}"\guitarEndDoubePar"
676 % \end{quote}
677 % are expanded when the song text contains one, two, or three (or more)
678 % linefeeds.\par
679 %
680 % After the macro
681 % \begin{quote}
682 % \DescribeMacro{\guitarNoChord}"\guitarNoChord"
683 % \end{quote}
684 % has been used, no chords are output anymore. You can make the effect
685 % local by putting this command in a group. ("\guitarNoChord" redefines the
686 % macros which are responsible for the actual output of the chords -- see the
687 % description at the end).\par
688 %
689 % The command
690 % \begin{quote}
691 % \DescribeMacro{\guitarPreAccord}"\guitarPreAccord"
692 % \end{quote}
693 % is expanded before the actual chord is typeset: You can change this
694 % definition to e.g.\ modify the font used for the chord. By default, this
695 % command contains a "\strut" which ensures that the lines with chords
696 % usually all have the same height.
697 % The macro "\guitarPreAccord" may also use and modify the macro
698 % \begin{quote}
699 % \DescribeMacro{\guitarAccord}"\guitarAccord"
700 % \end{quote}
701 % which contains the actual chord which is then output (you may use this
702 % feature to e.g.\ calculate a modulation in "\guitarPreAccord" or to
703 % replace the text of "\guitarAccord" by some graphic equivalent).
704 %
705 % It is guaranteed that the macros "\guitarPreAccord" and "\guitarAccord"
706 % are expanded precisely once.
707 % In contrast, it might happen that the argument of the chord (i.e.\ the
708 % text over which the chord is put) is expanded twice.
709 % (The doubled expansion could have been avoided, but the price were that
710 % in some cases the \TeX\ kerning mechanism would then fail if the argument
711 % is a syllable of some word which is continued afterwards).
712 % \par
713 %
714 % Whenever the ``guitar'' mode or the ``linefeed'' mode is turned
715 % on or off, the corresponding macro
716 % \begin{quote}
717 % \DescribeMacro{\guitarMagicOnHook}"\guitarMagicOnHook"\\
718 % \DescribeMacro{\guitarMagicOffHook}"\guitarMagicOffHook"\\
719 % \DescribeMacro{\guitarCrOnHook}"\guitarCrOnHook"\\
720 % \DescribeMacro{\guitarCrOffHook}"\guitarCrOffHook"
721 % \end{quote}
722 % is expanded (for switching on, the macro is expanded even before the
723 % necessary catcode changes are done, and for switching off, the macro
724 % is expanded after the catcodes have been restored).
725 % In the current defaults, a group is opened and closed in
726 % "\guitarCrOnHook" and "\guitarCrOffHook": This is the reason why these
727 % commands must be properly nested.
728 % (The reason for this group is that "\parindent" should be changed locally).
729 % \par
730 %
731 % In the current implementation, \TeX\ forgets everything following the magic
732 % tokens "|" and "_" in the chord (because these symbols are intended to be
733 % the last one in the chord). If you want to use these tokens within a chord:
734 % They loose their magic meaning if they occur in a braced context
735 % (i.e.\ between "{" and "}"). If you regularly have to use these tokens within
736 % chords, you can change the default choice of this tokens by the respective
737 % commands
738 % \begin{quote}
739 % \DescribeMacro{\guitarSplitDist}"\toolboxMakeSplit"\bracemeta{token}\relax
740 %"{guitarSplitDist}"\\
741 % \DescribeMacro{\guitarSplitMerge}"\toolboxMakeSplit"\bracemeta{token}\relax
742 %"{guitarSplitMerge}".
743 % \end{quote}
744 % (See the \filecite{toolbox} package for details of the command
745 % \DescribeMacro{\toolboxMakeSplit}"\toolboxMakeSplit" used here).
746 % It should be pointed out that \meta{token} may actually be a \emph{sequence}
747 % of tokens, so that for the `magic tokens' "|" and "_" you may instead use
748 % whole phrases if you prefer.
749 % \par
750 %
751 % Some fine tuning of the spacing can be done by redefining
752 % \begin{quote}
753 % \DescribeMacro{\guitarCalcDim}"\guitarCalcDim".
754 % \end{quote}
755 % When this macro is called, the skip register
756 % \begin{quote}
757 % \DescribeMacro{\guitarDim}"\guitarDim"
758 % \end{quote}
759 % contains the width of the chord which should be put over the text.
760 % After "\guitarCalcDim" has been expanded, it is ensured that at least
761 % "\guitarDim" (horizontal) space is reserved for the chord. Thus, if
762 % "\guitarCalcDim" increases e.g.\ "\guitarDim" by "2pt" (which is the
763 % default behavior of "\guitarCalcDim"), then "2pt" more space is reserved
764 % for the chord than its actual size: This ensures that two subsequent
765 % chords are always separated by some space.\par
766 %
767 % Finally, you can modify the macros which do the actual setting of the chords:
768 % This setting is done by the commands
769 % \begin{quote}
770 % \DescribeMacro{\guitarPut}"\guitarPut"\\
771 % \DescribeMacro{\guitarPutOnSpace}"\guitarPutOnSpace"\\
772 % \DescribeMacro{\guitarPutDist}"\guitarPutDist"\\
773 % \DescribeMacro{\guitarPutMerge}"\guitarPutMerge"
774 % \end{quote}
775 % which with the exception of "\guitarPutOnSpace" all expect one argument
776 % (namely the text on which they should be put). The command
777 % "\guitarPutOnSpace" is called, if a space followed the chord argument.
778 % Similarly, "\guitarPutDist" and "\guitarPutMerge" are called if the chord
779 % argument ended with the magic symbol "|" respectively "_".\par
780 % Before one of the above four macros is called, the chord text is stored in
781 % the macro "\guitarAccord" (and has not been expanded to this time); also the
782 % argument has not been expanded to this time. The above four macros are also
783 % responsible for the appropriate expansion (also of the expansion of the
784 % macros \DescribeMacro{\guitarCalcDim}"\guitarCalcDim" and
785 % \DescribeMacro{\guitarPreAccord}"\guitarPreAccord", if
786 % the latter should still keep their meaning).
787 % The above four macros may freely use the skip register
788 % \DescribeMacro{\guitarDim}"\guitarDim" and the box register
789 % \DescribeMacro{\guitarBox}"\guitarBox" (which are both not used or
790 % modified by the other macros of this package).
791 %
792 %
793 % \section{Possible Problems}
794 %
795 % The special treatment of "[" "#" "b" and \meta{linefeed} is implemented by a
796 % changing of catcodes. This may cause essentially two sorts of problems:
797 % \begin{enumerate}
798 % \item
799 % In some cases, you will want to avoid the automatic replacement of "#"
800 % and "b". For example, in "[\textbf{F#}]" or in "\guitarChord{\textbf{F#}}"
801 % the "b" of "\textbf" gets replaced which is of course not what you want.
802 % To avoid this replacement, there is a "*"~version of the respective
803 % commands, i.e.\ the above example works in the intended way if you write
804 % instead "[*\textbf{F\guitarSharp}]" or
805 % "\guitarChord*{\textbf{F\guitarSharp}}"
806 % (you have to use the command "\guitarSharp", because due to the "*" also
807 % the "#" would not be replaced).
808 % \item
809 % There are some situations in which catcodes are set
810 % too early, e.g.\ if you use the macros within the argument of certain
811 % macros. In this case, these symbols keep their usual \TeX\ meaning
812 % (which may either lead to an error in case of "#" (and sometimes "[") or
813 % just to a false output). If this happens to you, you have to replace at
814 % the corresponding place the above one-symbol shortcuts by their longer
815 % macro equivalents. In other words: You might have to replace in
816 % certain special situations some occurrences of the symbols according to
817 % the following table:
818 % \bigskip\par
819 % \begin{tabular}[T]{l@{$\quad\to\quad$}l}
820 % "[...]" &"\guitarChord{...}"\\
821 % "#" &"\guitarSharp"\\
822 % "b" &"\guitarFlat"\\
823 % linefeed &"\guitarEndLine"\\
824 % $2$ linefeeds &"\guitarEndPar"\\
825 % $3{+}$ linefeeds&"\guitarEndDoublePar"
826 % \end{tabular}
827 % \end{enumerate}
828 %
829 % \iffalse
830 %</metainfo>
831 % \fi
832 % \iffalse--------------------------------------------------------------\fi
833 % \StopEventually{\PrintChanges}
834 % \section{Implementation}
835 %
836 % \iffalse--------------------------------------------------------------
837 %
838 %
839 %<*package>
840 % \fi
841 % \begin{macrocode}
842 %%
843 %% This file was generated by the docstrip utility from guitar.dtx.
844 %% You may distribute this file only together with the source guitar.dtx
845 %% (and if possible with guitar.ins) and only if these files are unmodified.
846 %%
847 %% Author:
848 %%
849 %% M. V\"ath [email protected]
850 %%
851
852 \ifx\typeout\undefined
853 \def\tbx@tmp{\immediate\write17}\expandafter\tbx@tmp
854 \else
855 \expandafter\typeout
856 \fi{guitar.sty by M. Vaeth: Guitar chords over song texts 1.6}
857
858 \ifx\ProvidesPackage\undefined\else
859 \ProvidesPackage{guitar}[2009/03/17 v1.6]
860 \fi
861 \ifx\RequirePackage\undefined
862 \ifx\toolboxDef\undefined
863 \input toolbox.sty
864 \fi
865 \else
866 \RequirePackage{toolbox}[2001/04/08]
867 \fi
868 \ifx\toolboxIfNextGobbling\undefined
869 \errmessage{guitar.sty requires toolbox.sty version 2.0 or higher}
870 \fi
871
872 \ifx\newenvironment\undefined\else
873 \newenvironment{guitar}{\guitarOn}{\guitarOff}
874 \newenvironment{guitarMagic}{\guitarMagicOn}{\guitarMagicOff}
875 \newenvironment{guitarCr}{\guitarCrOn}{\guitarCrOff}
876 \fi
877
878 \ifx\newcommand\undefined\else
879 \newcommand{\guitarChord}{}
880
881 \newcommand{\guitarOn}{}
882 \newcommand{\guitarOff}{}
883 \newcommand{\guitarMagicOn}{}
884 \newcommand{\guitarMagicOff}{}
885 \newcommand{\guitarCrOn}{}
886 \newcommand{\guitarCrOff}{}
887
888 \newcommand{\guitarSharp}{}
889 \newcommand{\guitarFlat}{}
890 \newcommand{\guitarMagicOnHook}{}
891 \newcommand{\guitarMagicOffHook}{}
892 \newcommand{\guitarCrOnHook}{}
893 \newcommand{\guitarCrOffHook}{}
894 \newcommand{\guitarEndLine}{}
895 \newcommand{\guitarEndPar}{}
896 \newcommand{\guitarEndDoublePar}{}
897 \newcommand{\guitarCalcDim}{}
898 \newcommand{\guitarPreAccord}{}
899
900 \newcommand{\guitarPut}{}
901 \newcommand{\guitarPutOnSpace}{}
902 \newcommand{\guitarPutDist}{}
903 \newcommand{\guitarPutMerge}{}
904
905 \newcommand{\guitarNoChord}{}
906
907 \newcommand{\guitarAccord}{}
908 \newcommand{\guitarSplitDist}{}
909 \newcommand{\guitarSplitMerge}{}
910 \fi
911
912 % \end{macrocode}
913 % \begin{macro}{\guitarBox}\nocomment
914 % \begin{macrocode}
915 \ifx\newsavebox\undefined
916 \newbox\guitarBox
917 \else
918 \newsavebox{\guitarBox}
919 \fi
920 % \end{macrocode}
921 % \end{macro}
922 % \begin{macro}{\guitarBox}\nocomment
923 % \begin{macrocode}
924 \ifx\newlength\undefined
925 \newskip\guitarDim
926 \else
927 \newlength{\guitarDim}
928 \fi
929
930 % \end{macrocode}
931 % \end{macro}
932 % \begin{macro}{\guitarSharp}\nocomment
933 % \begin{macrocode}
934 \def\guitarSharp{$\sharp$}
935 % \end{macrocode}
936 % \end{macro}
937 % \begin{macro}{\guitarFlat}\nocomment
938 % \begin{macrocode}
939 \def\guitarFlat{$\flat$}
940 % \end{macrocode}
941 % \end{macro}
942 % \begin{macro}{\guitarCalcDim}\nocomment
943 % \begin{macrocode}
944 \def\guitarCalcDim{\advance\guitarDim by 2pt}
945 % \end{macrocode}
946 % \end{macro}
947 % \begin{macro}{\guitarPreAccord}\nocomment
948 % \begin{macrocode}
949 \def\guitarPreAccord{\footnotesize\strut}
950 % \end{macrocode}
951 % \end{macro}
952 % \begin{macro}{\guitarMagicOnHook}\nocomment
953 % \begin{macrocode}
954 \let\guitarMagicOnHook\toolboxEmpty
955 % \end{macrocode}
956 % \end{macro}
957 % \begin{macro}{\guitarMagicOffHook}\nocomment
958 % \begin{macrocode}
959 \let\guitarMagicOffHook\toolboxEmpty
960 % \end{macrocode}
961 % \end{macro}
962 % \begin{macro}{\guitarCrOnHook}\nocomment
963 % \begin{macrocode}
964 \def\guitarCrOnHook{\begingroup\leftskip 0pt plus 1fill\relax
965 \parindent 0pt\leavevmode\gtr@CrOnHook\nobreak\hskip-\leftskip\relax
966 \finalhyphendemerits=0\everypar{\nobreak\hskip-\leftskip\relax}\sloppy\relax
967 \linepenalty=50\relax\parskip0pt\relax}
968 % \end{macrocode}
969 % \end{macro}
970 % \begin{macro}{\guitarFirstLeft}\nocomment
971 % \begin{macrocode}
972 \def\guitarFirstLeft{\def\gtr@CrOnHook
973 {\rightskip 0pt plus 1fil\relax\parfillskip 0pt\relax}}
974 % \end{macrocode}
975 % \end{macro}
976 % \begin{macro}{\guitarFirstFlush}\nocomment
977 % \begin{macrocode}
978 \def\guitarFirstFlush{\let\gtr@CrOnHook\toolboxEmpty}
979 % \end{macrocode}
980 % \end{macro}
981 % \begin{macro}{\gtr@CrOnHook}\nocomment
982 % \begin{macrocode}
983 \guitarFirstFlush
984 % \end{macrocode}
985 % \end{macro}
986 % \begin{macro}{\guitarCrOffHook}\nocomment
987 % \begin{macrocode}
988 \let\guitarCrOffHook\endgroup
989 % \end{macrocode}
990 % \end{macro}
991 % \begin{macro}{\guitarEndLine}\nocomment
992 % \begin{macrocode}
993 \def\guitarEndLine{\par\leavevmode}
994 % \end{macrocode}
995 % \end{macro}
996 % \begin{macro}{\guitarEndPar}\nocomment
997 % \begin{macrocode}
998 \def\guitarEndPar{\medskip\par\leavevmode}
999 % \end{macrocode}
1000 % \end{macro}
1001 % \begin{macro}{\guitarEndDoublePar}\nocomment
1002 % \begin{macrocode}
1003 \def\guitarEndDoublePar{\bigskip\par\leavevmode}
1004
1005 % \end{macrocode}
1006 % \end{macro}
1007 % \begin{macro}{\guitarPut}\nocomment
1008 % \begin{macrocode}
1009 \def\guitarPut#1{\setbox0\hbox{\strut#1}\leavevmode
1010 \raise\ht0\hbox to 0pt{\hbox to\wd0{\guitarPreAccord
1011 \hfill\guitarAccord\hfill\hss}\hss}#1}
1012 % \end{macrocode}
1013 % \end{macro}
1014 % \begin{macro}{\guitarPutOnSpace}\nocomment
1015 % \begin{macrocode}
1016 \def\guitarPutOnSpace{\leavevmode\raise\ht\strutbox
1017 \hbox{\guitarPreAccord\guitarAccord}}
1018 % \end{macrocode}
1019 % \end{macro}
1020 % \begin{macro}{\guitarPutDist}\nocomment
1021 % \begin{macrocode}
1022 \def\guitarPutDist{\gtr@distMerge\hfil}
1023 % \end{macrocode}
1024 % \end{macro}
1025 % \begin{macro}{\guitarPutMerge}\nocomment
1026 % \begin{macrocode}
1027 \def\guitarPutMerge{\gtr@distMerge\hrulefill}
1028 % \end{macrocode}
1029 % \end{macro}
1030 % \begin{macro}{\gtr@distMerge}\nocomment
1031 % \begin{macrocode}
1032 \def\gtr@distMerge#1#2{\setbox\guitarBox\hbox{\strut#2}%
1033 \setbox0\hbox{\guitarPreAccord\guitarAccord}\leavevmode
1034 \guitarDim=\wd0\relax\guitarCalcDim
1035 \ifdim\wd\guitarBox<\guitarDim% Accord is too large:
1036 \hbox to 0pt{\raise\ht\guitarBox\hbox{\copy0}\hss}%
1037 \hbox to\guitarDim{\box\guitarBox#1}%
1038 \let\guitarAccord\toolboxEmpty%now used as a temporary variable.
1039 \else
1040 \hbox to 0pt{\raise\ht\guitarBox
1041 \hbox to\wd\guitarBox{\hfil\box0\hfil}\hss}%
1042 \def\guitarAccord{#2}%
1043 \fi\guitarAccord}
1044
1045 % \end{macrocode}
1046 % \end{macro}
1047 % \begin{macro}{\guitarNoChord}\nocomment
1048 % \begin{macrocode}
1049 \def\guitarNoChord{\def\guitarPut##1{##1}%
1050 \let\guitarPutDist\guitarPut
1051 \let\guitarPutMerge\guitarPut
1052 \let\guitarPutOnSpace\toolboxSpace}
1053
1054 % \end{macrocode}
1055 % \end{macro}
1056 % \begin{macro}{\guitarSplitDist}\nocomment
1057 % \begin{macrocode}
1058 \toolboxMakeSplit{|}{guitarSplitDist}
1059 % \end{macrocode}
1060 % \end{macro}
1061 % \begin{macro}{\guitarSplitMerge}\nocomment
1062 % \begin{macrocode}
1063 \toolboxMakeSplit{_}{guitarSplitMerge}
1064
1065 % \end{macrocode}
1066 % \end{macro}
1067 % \begin{macro}{\guitarOn}\nocomment
1068 % \begin{macrocode}
1069 \def\guitarOn{\guitarCrOn\guitarMagicOn}
1070 % \end{macrocode}
1071 % \end{macro}
1072 % \begin{macro}{\guitarOff}\nocomment
1073 % \begin{macrocode}
1074 \def\guitarOff{\guitarMagicOff\guitarCrOff}
1075 % \end{macrocode}
1076 % \end{macro}
1077 % \begin{macro}{\guitarMagicOn}\nocomment
1078 % \begin{macrocode}
1079 \def\guitarMagicOn{\guitarMagicOnHook\gtr@magicOn\gtr@ignorespaces}
1080 % \end{macrocode}
1081 % \end{macro}
1082 % \begin{macro}{\guitarMagicOff}\nocomment
1083 % \begin{macrocode}
1084 \def\guitarMagicOff{\gtr@magicOff\guitarMagicOffHook}
1085 % \end{macrocode}
1086 % \end{macro}
1087 % \begin{macro}{\gtr@crMagicCondOn}
1088 % During the scanning of the chord and its argument, we switch off
1089 % the magic meaning of "[" and of linefeeds. After the scanning, the codes are
1090 % restored again with "\gtr@crMagicCondOn". Of course, we have to take care
1091 % that we switch on the catcodes only if we `are' in the corresponding mode.
1092 % We thus have to redefine the commands executed by "\gtr@crMagicCondOn" when
1093 % we change the mode.
1094 % \begin{macrocode}
1095 \def\gtr@crMagicCondOn{\gtr@magicCondOn\gtr@crCondOn}
1096 % \end{macrocode}
1097 % \end{macro}
1098 % \begin{macro}{\gtr@crMagicCondOff}
1099 % "\gtr@crMagicCondOff" is the opposite of "\gtr@crMagicOn" and used to
1100 % switch off the catcodes during the scanning of the chord and its argument.
1101 % \begin{macrocode}
1102 \def\gtr@crMagicCondOff{\gtr@magicCondOff\gtr@crCondOff}
1103 % \end{macrocode}
1104 % \end{macro}
1105 % \begin{macro}{\gtr@magicOn}\nocomment
1106 % \begin{macrocode}
1107 \def\gtr@magicOn{\gtr@magicOnCat
1108 \let\gtr@magicCondOff\gtr@magicOffCat
1109 \let\gtr@magicCondOn\gtr@magicOnCat}
1110 % \end{macrocode}
1111 % \end{macro}
1112 % \begin{macro}{\gtr@magicOn}\nocomment
1113 % \begin{macrocode}
1114 \def\gtr@magicOff{\gtr@magicOffCat
1115 \let\gtr@magicCondOff\toolboxEmpty
1116 \let\gtr@magicCondOn\toolboxEmpty}
1117 % \end{macrocode}
1118 % \end{macro}
1119 % \begin{macro}{\gtr@braceOnDef}
1120 % "\gtr@braceOnDef" will later save/redefine the "[" command.
1121 % For the very first call below we must make it a dummy command now.
1122 % \begin{macrocode}
1123 \let\gtr@magicOnDef\toolboxEmpty
1124 % \end{macrocode}
1125 % \end{macro}
1126 % \begin{macro}{\gtr@magicOnCat}\nocomment
1127 % \begin{macrocode}
1128 \def\gtr@magicOnCat{\catcode`\[=13\gtr@magicOnDef}
1129 % \end{macrocode}
1130 % \end{macro}
1131 % \begin{macro}{gtr@magicSave}\nocomment
1132 % "\gtr@magicSave" is the content of the original "[" command
1133 % \begin{macrocode}
1134 \gtr@magicOnCat\def\gtr@magicOnDef{\let\gtr@magicSave[\let[\gtr@magicNew}%
1135 % \end{macrocode}
1136 % \end{macro}
1137 % \begin{macro}{\gtr@magicNew}\nocomment
1138 % "\gtr@magicNew" is the magic new "[" command
1139 % \begin{macrocode}
1140 \def\gtr@magicNew{\gtr@chordTest\gtr@scanBrace}
1141 % \end{macrocode}
1142 % \end{macro}
1143 % \begin{macro}{\gtr@magicOffCat}\nocomment
1144 % \begin{macrocode}
1145 \def\gtr@magicOffCat{\let[\gtr@magicSave\catcode`\[=12\relax}
1146 \gtr@magicOnDef\gtr@magicOff
1147
1148 % \end{macrocode}
1149 % \end{macro}
1150 % \begin{macro}{\gtr@scanBrace}\nocomment
1151 % \begin{macrocode}
1152 \def\gtr@scanBrace#1]{\gtr@parse{#1}}
1153
1154 % \end{macrocode}
1155 % \end{macro}
1156 % \begin{macro}{\gtr@scanBrace}\nocomment
1157 % \begin{macrocode}
1158 \def\guitarChord{\gtr@chordTest\gtr@parse}
1159 % \end{macrocode}
1160 % \end{macro}
1161 % \begin{macro}{\gtr@chordTest}\nocomment
1162 % "\gtr@chordTest"\bracemeta{arg} first disables the magic catcodes for "[".
1163 % Unless the next token is a "*", it enables the magic catcodes for
1164 % "#" and "b" (the "*" is gobbled). Then \meta{arg} is expanded.
1165 % It should be noted that the scanning for "*" happens with catcodes
1166 % for "#" and "b" enabled (this is necessary to parse properly, e.g.\ "[b]").
1167 % \begin{macrocode}
1168 \def\gtr@chordTest#1{\gtr@crMagicCondOff\gtr@change
1169 \toolboxIfNextGobbling*{\gtr@normal#1}{#1}}
1170 % \end{macrocode}
1171 % \end{macro}
1172 % \begin{macro}{\gtr@parse}\nocomment
1173 % "\gtr@parse"\bracemeta{chrd} parses the chord \meta{chord} and possibly a
1174 % following space (gobbling). Depending on what it finds, it expands the
1175 % corresponding "\guitarPut..." command.
1176 % \begin{macrocode}
1177 \def\gtr@parse#1{\gtr@normal\gtr@changeDef
1178 \guitarSplitDist{#1}\guitarAccord\gtr@dist
1179 \expandafter
1180 \guitarSplitMerge\expandafter{\guitarAccord}\guitarAccord\gtr@merge
1181 \gtr@changeUndef
1182 \toolboxIfNextGobbling\toolboxSpaceToken
1183 {\gtr@crMagicCondOn\guitarPutOnSpace}\gtr@para}
1184 % \end{macrocode}
1185 % \end{macro}
1186 % \begin{macro}{\gtr@para}\nocomment
1187 % \begin{macrocode}
1188 \def\gtr@para#1{\gtr@crMagicCondOn
1189 \ifx\gtr@dist\undefined
1190 \ifx\gtr@merge\undefined
1191 \let\gtr@tmp\guitarPut
1192 \else
1193 \let\gtr@tmp\guitarPutMerge
1194 \fi
1195 \else
1196 \let\gtr@tmp\guitarPutDist
1197 \fi\gtr@tmp{#1}}
1198
1199 % \end{macrocode}
1200 % \end{macro}
1201 % \begin{macro}{\gtr@change}\nocomment
1202 % \begin{macrocode}
1203 \def\gtr@change{\catcode`\#=13\catcode`b=13\relax}
1204 % \end{macrocode}
1205 % \end{macro}
1206 % \begin{macro}{gtr@sharpSave}
1207 % "\gtr@sharpSave" is the content of the original sharp command
1208 % \end{macro}
1209 % \begin{macro}{gtr@flatSave}
1210 % "\gtr@flatSave" is the content of the original flat command
1211 % \end{macro}
1212 % \begin{macro}{\gtr@changeDef}
1213 % "\gtr@changeDef" will later save/redefine the sharp and flat command.
1214 % \begin{macrocode}
1215 \gtr@change\def\gtr@changeDef{\let\gtr@sharpSave#\let#\gtr@sharpNew
1216 \let\gtr@flatSave b\let b\gtr@flatNew}
1217 % \end{macrocode}
1218 % \end{macro}
1219 % \begin{macro}{gtr@ChangeUndef}
1220 % "\gtr@ChangeUndef" restores the change made by "\gtr@changeDef"
1221 % \begin{macrocode}
1222 \def\gtr@changeUndef{\let#\gtr@sharpSave\let b\gtr@flatSave}
1223 % \end{macrocode}
1224 % \end{macro}
1225 % \begin{macro}{\gtr@sharpNew}\nocomment
1226 % "\gtr@sharpNew" is the magic new "#" command
1227 % \begin{macrocode}
1228 \def\gtr@sharpNew{\guitarSharp}
1229 % \end{macrocode}
1230 % \end{macro}
1231 % \begin{macro}{\gtr@flatNew}\nocomment
1232 % "\gtr@flatNew" is the magic new "#" command
1233 % \begin{macrocode}
1234 \def\gtr@flatNew{\guitarFlat}
1235 % \end{macrocode}
1236 % \end{macro}
1237 % \begin{macro}{\gtr@normal}\nocomment
1238 % \begin{macrocode}
1239 \def\gtr@normal{\catcode`\#=6\catcode`b=11\relax}
1240 \gtr@changeDef\gtr@normal
1241
1242 % \end{macrocode}
1243 % \end{macro}
1244 % \begin{macro}{\guitarCrOn}\nocomment
1245 % \begin{macrocode}
1246 \def\guitarCrOn{\guitarCrOnHook\gtr@crOn\gtr@ignorespaces}
1247 % \end{macrocode}
1248 % \end{macro}
1249 % \begin{macro}{\guitarCrOff}\nocomment
1250 % \begin{macrocode}
1251 \def\guitarCrOff{\gtr@crOff\guitarCrOffHook}
1252 % \end{macrocode}
1253 % \end{macro}
1254 % \begin{macro}{\gtr@crOn}\nocomment
1255 % \begin{macrocode}
1256 \def\gtr@crOn{\gtr@crOnCat
1257 \let\gtr@crCondOff\gtr@crOffCat
1258 \let\gtr@crCondOn\gtr@crOnCat}
1259 % \end{macrocode}
1260 % \end{macro}
1261 % \begin{macro}{\gtr@crOn}\nocomment
1262 % \begin{macrocode}
1263 \def\gtr@crOff{\gtr@crOffCat
1264 \let\gtr@crCondOff\toolboxEmpty
1265 \let\gtr@crCondOn\toolboxEmpty}
1266 % \end{macrocode}
1267 % \end{macro}
1268 % \begin{macro}{\gtr@crOnDef}
1269 % "\gtr@crOnDef" will later save/redefine the linefeed command.
1270 % For the very first call below we must make it a dummy command now.
1271 % \begin{macrocode}
1272 \let\gtr@crOnDef\toolboxEmpty
1273 % \end{macrocode}
1274 % \end{macro}
1275 % \begin{macro}{\gtr@crOnCat}\nocomment
1276 % \begin{macrocode}
1277 \def\gtr@crOnCat{\catcode`\^^M=13\gtr@crOnDef}
1278 % \end{macrocode}
1279 % \end{macro}
1280 % \begin{macro}{gtr@crSave}\nocomment
1281 % "\gtr@crSave" is the content of the original linefeed command
1282 % \begin{macrocode}
1283 \gtr@crOnCat\def\gtr@crOnDef{\let\gtr@crSave^^M\let^^M\gtr@crNew}%
1284 % \end{macrocode}
1285 % \end{macro}
1286 % \begin{macro}{gtr@crNew}\nocomment
1287 % "\gtr@crNew" is the special new linefeed command
1288 % \begin{macrocode}
1289 \def\gtr@crNew{\toolboxIfNextGobbling^^M\gtr@par\guitarEndLine}%
1290 % \end{macrocode}
1291 % \end{macro}
1292 % \begin{macro}{gtr@par}\nocomment
1293 % \begin{macrocode}
1294 \def\gtr@par{\toolboxIfNextGobbling^^M\gtr@dblpar\guitarEndPar}%
1295 % \end{macrocode}
1296 % \end{macro}
1297 % \begin{macro}{gtr@dblpar}\nocomment
1298 % \begin{macrocode}
1299 \def\gtr@dblpar{\toolboxIfNextGobbling^^M\gtr@dblpar\guitarEndDoublePar}%
1300 % \end{macrocode}
1301 % \end{macro}
1302 % \begin{macro}{gtr@ignorespaces}\nocomment
1303 % \begin{macrocode}
1304 \def\gtr@ignorespaces{\toolboxIfNextGobbling^^M\gtr@ignorespaces\ignorespaces}%
1305 % \end{macrocode}
1306 % \end{macro}
1307 % \begin{macro}{gtr@crOffCat}\nocomment
1308 % \begin{macrocode}
1309 \def\gtr@crOffCat{\let^^M\gtr@crSave\catcode`\^^M=5\relax}%
1310 \gtr@crOnDef\gtr@crOff
1311
1312 % \end{macrocode}
1313 % \end{macro}
1314 %
1315 % \iffalse
1316 %</package>
1317 % \fi
1318 % \Finale\PrintIndex
1319 %
1320 %
1321 %
1322 % \iffalse
1323 %<*metainfo>
1324 % \fi
1325 \iffalse -------------------------------------------------------------
1326 %
1327 % Just in case that for some reason the file `guitar.ins' got lost:
1328 % The content of this file is between the lines %<*insfile> and %</insfile>.
1329 %
1330 %\iffalse
1331 %</metainfo>
1332 %<*insfile>
1333 \def\batchfile{guitar.ins}
1334 \input docstrip.tex
1335 \keepsilent
1336 \nopreamble
1337 \generateFile{guitar.sty}{f}{\from{guitar.dtx}{package}}
1338 \generateFile{guitar.txt}{f}{\from{guitar.dtx}{asciidocu}}
1339 \generateFile{guitar.tex}{f}{\from{guitar.dtx}{driver}}
1340 %%\generateFile{guitar.ins.dup}{f}{\from{guitar.dtx}{insfile}}
1341
1342 \Msg{***************************************************************}
1343 \Msg{*}
1344 \Msg{* To finish the installation you have to move the}
1345 \Msg{* file 'guitar.sty' into a directory searched by TeX.}
1346 \Msg{*}
1347 \Msg{*}
1348 \Msg{* Run the file guitar.tex through LaTeX to produce the}
1349 \Msg{* documentation or read the ascii documentation in guitar.txt}
1350 \Msg{*}
1351 \Msg{*}
1352 \Msg{***************************************************************}
1353 \endbatchfile
1354 %</insfile>
1355 %<*metainfo>
1356 % \fi
1357 \fi
1358 % \iffalse
1359 %</metainfo>
1360 % \fi
1361 \endinput
1362
1363 %%% Local Variables:
1364 %%% mode: latex
1365 %%% TeX-master: "guitar.tex"
1366 %%% End: