| 1 |
|
| 2 |
%%# |
| 3 |
%%# Author and copyright 2001,2009,2013: |
| 4 |
%%# |
| 5 |
%%# M. V\"ath [email protected] |
| 6 |
%%# |
| 7 |
%%# The author thanks |
| 8 |
%%# Donald Arseneau <[email protected]> |
| 9 |
%%# Dan Luecking <[email protected]> |
| 10 |
%%# Heiko Oberdiek <[email protected]> |
| 11 |
%%# and a colleague who does not want to be named here. |
| 12 |
|
| 13 |
%%# The package may be distributed and/or modified under the conditions of |
| 14 |
%%# the LaTeX Project Public License (version 1.3c or later). |
| 15 |
|
| 16 |
%%############################################################################# |
| 17 |
%%# |
| 18 |
%%# guitar.sty - typesetting guitar chords over song texts. |
| 19 |
%%# |
| 20 |
%%############################################################################# |
| 21 |
|
| 22 |
%%# |
| 23 |
%%# This package should run with plain TeX, LaTeX 2.09, and LaTeX 2e. |
| 24 |
%%# Actually, it should run with all TeX formats. |
| 25 |
%%# |
| 26 |
|
| 27 |
%%# This is not the only package available for typesetting guitar songs. |
| 28 |
%%# The following packages are also available (and possibly also others: |
| 29 |
%%# I do not claim that this list is complete). |
| 30 |
%%# |
| 31 |
%%# 1. gchords.sty http://www.damtp.cam.ac.uk/user/kp229/gchords/ |
| 32 |
%%# 2. songbook.sty http://www.rath.ca/Misc/Songbook/ |
| 33 |
%%# or on CTAN: macros/latex/contrib/supported/songbook/ |
| 34 |
%%# 3. guitarTeX (which is not a `pure' (La)TeX solution): |
| 35 |
%%# http://rz-home.de/~jmiltz/guitartex/ |
| 36 |
%%# |
| 37 |
%%# The packages 1. and 2. have somewhat different intentions. |
| 38 |
%%# It should be possible to combine them with the current package |
| 39 |
%%# without any severe problems. |
| 40 |
|
| 41 |
|
| 42 |
%%# To use guitar, you have to put `guitar.sty' in a path where TeX looks |
| 43 |
%%# for its input files. The TeX documents using guitar need the |
| 44 |
%%# following modifications in their header: |
| 45 |
%%# |
| 46 |
%%# a) If you use LaTeX2.09, use guitar as a style option, e.g. |
| 47 |
%%# \documentstyle[guitar]{article} |
| 48 |
%%# or |
| 49 |
%%# \documentstyle[guitar,12pt]{article} |
| 50 |
%%# b) If you use LaTeX2e, put in the preamble the command |
| 51 |
%%# \usepackage{guitar} |
| 52 |
%%# c) If you use some other (non-LaTeX) format, you will probably have to |
| 53 |
%%# insert a line like |
| 54 |
%%# \catcode`\@=11\input guitar.sty\catcode`\@=12\relax |
| 55 |
%%# |
| 56 |
%%# For TeX-insiders: |
| 57 |
%%# The only LaTeX-specific commands used in `guitar.sty' are: |
| 58 |
%%# |
| 59 |
%%# \newenvironment |
| 60 |
%%# \newcommand (only in the form \newcommand{\command}{} to ensure that |
| 61 |
%%# \command was not defined before) |
| 62 |
%%# \newsavebox |
| 63 |
%%# \newlength |
| 64 |
%%# \RequirePackage |
| 65 |
%%# \ProvidesPackage |
| 66 |
%%# \typeout |
| 67 |
%%# |
| 68 |
%%# The above commands are used only if they are defined |
| 69 |
%%# (otherwise, the plainTeX are used). |
| 70 |
%%# |
| 71 |
|
| 72 |
%%# |
| 73 |
%%# Usage: |
| 74 |
%%# |
| 75 |
|
| 76 |
%%# The general usage is very simple: |
| 77 |
%%# |
| 78 |
%%# \guitarChord{Bb}Really. \guitarChord{G#}Oh yes. |
| 79 |
%%# |
| 80 |
%%# This puts the chord "B flat" and "G sharp" over the "R" resp. "O". |
| 81 |
%%# (in the chord, "b" and "#" always translate into "flat" resp. "sharp"). |
| 82 |
%%# When you switch into "magic" mode, you can even use [...] instead of |
| 83 |
%%# \guitarChord{...}. |
| 84 |
%%# E.g., in LaTeX, you can just write |
| 85 |
%%# |
| 86 |
%%# \begin{guitar} |
| 87 |
%%# [Cm]This [Bb]is a [G#]very [Gm]simple song. |
| 88 |
%%# You can still use any [\TeX]macros in the chord text. |
| 89 |
%%# Actually, each accord reads a second argument over |
| 90 |
%%# which it is [A]{centered}. |
| 91 |
%%# By default, the linefeeds in the source lead to linebreaks % |
| 92 |
%%# in the output, unless you put a percentage sign at the end of the line. % |
| 93 |
%%# If a single line gets too long, the wrapped lines are right-aligned. |
| 94 |
%%# To force the wrapping use \verb|\newline|\newline like here. |
| 95 |
%%# To stretch the first line, use \verb|\linebreak|\linebreak like here. |
| 96 |
%%# |
| 97 |
%%# Two subsequent linefeeds in the source start a new verse. |
| 98 |
%%# |
| 99 |
%%# |
| 100 |
%%# Three or more subsequent linefeeds in the source start a new verse with a % |
| 101 |
%%# slightly larger space. |
| 102 |
%%# |
| 103 |
%%# Unfortunately, if the chords get too long, they may [Ebm+7]o[G#]verlap. |
| 104 |
%%# To avoid this, the following solutions are supported: |
| 105 |
%%# |
| 106 |
%%# 1. If the token after your chord is a space, like in "[Ebm+7] space", |
| 107 |
%%# this space is stretched. |
| 108 |
%%# Note that this is different from the notation "[Ebm+7]{ }space". |
| 109 |
%%# 2. Inside words, put a _ at the end like for [Ebm+7_]O[G#]K. |
| 110 |
%%# 3. Outside words, put a | at the end like for [Ebm+7|]{OK}[G#|]. |
| 111 |
%%# If the chord is short enough (compared to its argument) then the symbols |
| 112 |
%%# | and _ do not harm like in [E|]{long} or [E_]{long}er. |
| 113 |
%%# |
| 114 |
%%# You may (and in plainTeX you must) replace "\begin{guitar}" and |
| 115 |
%%# "\end{guitar}" by "\guitarOn" and "\guitarOff", respectively. |
| 116 |
%%# |
| 117 |
%%# If you only want to put the guitar chords as above but do not like the |
| 118 |
%%# feature concerning the linefeeds, you can use the environment |
| 119 |
%%# \begin{guitarMagic} |
| 120 |
%%# \end{guitarMagic} |
| 121 |
%%# or the respective commands \guitarMagicOn and \guitarMagicOff. |
| 122 |
%%# Similarly, you can also use only the linefeed feature by the environment |
| 123 |
%%# \begin{guitarCr} |
| 124 |
%%# \end{guitarCr} |
| 125 |
%%# or the respective commands \guitarCrOn and \guitarCrOff. |
| 126 |
%%# |
| 127 |
%%# As a matter of fact, you can also e.g. use \guitarCrOff *within* a |
| 128 |
%%# {guitar} environment, but then you have to use \guitarCrOn before you |
| 129 |
%%# end the environment to have a proper nesting of modes. |
| 130 |
%%# |
| 131 |
|
| 132 |
%%# |
| 133 |
%%# Customization |
| 134 |
%%# |
| 135 |
|
| 136 |
%%# The output of the "#" and "b" tokens in the chords is generated by the two |
| 137 |
%%# commands |
| 138 |
%%# |
| 139 |
%%# \guitarSharp |
| 140 |
%%# \guitarFlat |
| 141 |
%%# |
| 142 |
%%# Thus, for, example the customization |
| 143 |
%%# |
| 144 |
%%# \def\guitarSharp{$^{\sharp}$} |
| 145 |
%%# |
| 146 |
%%# will make the sharp symbol be written as an upper index. |
| 147 |
|
| 148 |
%%# In a similar way, the macros |
| 149 |
%%# |
| 150 |
%%# \guitarEndLine |
| 151 |
%%# \guitarEndPar |
| 152 |
%%# \guitarEndDoublePar |
| 153 |
%%# |
| 154 |
%%# are expanded when the song text contains one, two, or three (or more) |
| 155 |
%%# linefeeds.\par |
| 156 |
|
| 157 |
%%# After the macro |
| 158 |
%%# |
| 159 |
%%# \guitarNoChord |
| 160 |
%%# |
| 161 |
%%# has been used, no chords are output anymore. You can make the effect |
| 162 |
%%# local by putting this command in a group. (\guitarNoChord redefines the |
| 163 |
%%# macros which are responsible for the actual output of the chords - see the |
| 164 |
%%# description at the end). |
| 165 |
%%# |
| 166 |
%%# The command |
| 167 |
%%# |
| 168 |
%%# \guitarPreAccord |
| 169 |
%%# |
| 170 |
%%# is expanded before the actual chord is typeset: You can change this |
| 171 |
%%# definition to e.g. modify the font used for the chord. By default, this |
| 172 |
%%# command contains a \strut which ensures that the lines with chords |
| 173 |
%%# usually all have the same height. |
| 174 |
%%# The macro \guitarPreAccord may also use and modify the macro |
| 175 |
%%# |
| 176 |
%%# \guitarAccord |
| 177 |
%%# |
| 178 |
%%# which contains the actual chord which is then output (you may use this |
| 179 |
%%# feature to e.g. calculate a modulation in \guitarPreAccord or to |
| 180 |
%%# replace the text of \guitarAccord by some graphic equivalent). |
| 181 |
%%# |
| 182 |
%%# It is guaranteed that the macros \guitarPreAccord and \guitarAccord |
| 183 |
%%# are expanded precisely once. |
| 184 |
%%# In contrast, it might happen that the argument of the chord (i.e. the |
| 185 |
%%# text over which the chord is put) is expanded twice. |
| 186 |
%%# (The doubled expansion could have been avoided, but the price were that |
| 187 |
%%# in some cases the TeX kerning mechanism would then fail if the argument |
| 188 |
%%# is a syllable of some word which is continued afterwards). |
| 189 |
%%# |
| 190 |
%%# Whenever the "guitar" mode or the "linefeed" mode is turned |
| 191 |
%%# on or off, the corresponding macro |
| 192 |
%%# |
| 193 |
%%# \guitarMagicOnHook |
| 194 |
%%# \guitarMagicOffHook |
| 195 |
%%# \guitarCrOnHook |
| 196 |
%%# \guitarCrOffHook |
| 197 |
%%# |
| 198 |
%%# is expanded (for switching on, the macro is expanded even before the |
| 199 |
%%# necessary catcode changes are done, and for switching off, the macro |
| 200 |
%%# is expanded after the catcodes have been restored). |
| 201 |
%%# In the current defaults, a group is opened and closed in |
| 202 |
%%# \guitarCrOnHook and \guitarCrOffHook: This is the reason why these |
| 203 |
%%# commands must be properly nested. |
| 204 |
%%# (The reason for this group is that"\parindent should be changed locally). |
| 205 |
%%# |
| 206 |
%%# In the current implementation, TeX forgets everything following the magic |
| 207 |
%%# tokens "|" and "_" in the chord (because these symbols are intended to be |
| 208 |
%%# the last one in the chord). If you want to use these tokens within a chord: |
| 209 |
%%# They loose their magic meaning if they occur in a braced context |
| 210 |
%%# (i.e. between { and }). If you regularly have to use these tokens within |
| 211 |
%%# chords, you can change the default choice of this tokens by the respective |
| 212 |
%%# commands |
| 213 |
%%# |
| 214 |
%%# \toolboxMakeSplit{token}{guitarSplitDist} |
| 215 |
%%# \toolboxMakeSplit{token}{guitarSplitMerge} |
| 216 |
%%# |
| 217 |
%%# (See the "toolbox" package for details of the command \toolboxMakeSplit |
| 218 |
%%# used here). |
| 219 |
%%# It should be pointed out that {token} may actually be a *sequence* |
| 220 |
%%# of tokens, so that for the `magic tokens' "|" and "_" you may instead use |
| 221 |
%%# whole phrases if you prefer. |
| 222 |
%%# |
| 223 |
%%# Some fine tuning of the spacing can be done by redefining |
| 224 |
%%# |
| 225 |
%%# \guitarCalcDim |
| 226 |
%%# |
| 227 |
%%# When this macro is called, the skip register |
| 228 |
%%# |
| 229 |
%%# \guitarDim |
| 230 |
%%# |
| 231 |
%%# contains the width of the chord which should be put over the text. |
| 232 |
%%# After \guitarCalcDim has been expanded, it is ensured that at least |
| 233 |
%%# \guitarDim (horizontal) space is reserved for the chord. Thus, if |
| 234 |
%%# \guitarCalcDim increases e.g. \guitarDim by 2pt (which is the |
| 235 |
%%# default behavior of \guitarCalcDim), then 2pt more space is reserved |
| 236 |
%%# for the chord than its actual size: This ensures that two subsequent |
| 237 |
%%# chords are always separated by some space. |
| 238 |
%%# |
| 239 |
%%# Finally, you can modify the macros which do the actual setting of the |
| 240 |
%%# chords: This setting is done by the commands |
| 241 |
%%# |
| 242 |
%%# \guitarPut |
| 243 |
%%# \guitarPutOnSpace |
| 244 |
%%# \guitarPutDist |
| 245 |
%%# \guitarPutMerge |
| 246 |
%%# |
| 247 |
%%# which with the exception of \guitarPutOnSpace all expect one argument |
| 248 |
%%# (namely the text on which they should be put). The command |
| 249 |
%%# \guitarPutOnSpace is called, if a space followed the chord argument. |
| 250 |
%%# Similarly, \guitarPutDist and \guitarPutMerge are called if the chord |
| 251 |
%%# argument ended with the magic symbol "|" respectively "_". |
| 252 |
%%# Before one of the above four macros is called, the chord text is stored in |
| 253 |
%%# the macro \guitarAccord (and has not been expanded to this time); also the |
| 254 |
%%# argument has not been expanded to this time. The above four macros are also |
| 255 |
%%# responsible for the appropriate expansion (also of the expansion of the |
| 256 |
%%# macros \guitarCalcDim and \guitarPreAccord, if |
| 257 |
%%# the latter should still keep their meaning). |
| 258 |
%%# The above four macros may freely use the skip register \guitarDim and the |
| 259 |
%%# box register \guitarBox (which are both not used or |
| 260 |
%%# modified by the other macros of this package). |
| 261 |
%%# |
| 262 |
|
| 263 |
%%# |
| 264 |
%%# Possible Problems: |
| 265 |
%%# |
| 266 |
|
| 267 |
%%# The special treatment of [ # b and linefeed is implemented by a changing of |
| 268 |
%%# catcodes. This may cause essentially two sorts of problems: |
| 269 |
%%# |
| 270 |
%%# 1. In some cases, you will want to avoid the automatic replacement of '#' |
| 271 |
%%# and 'b'. For example, in [\textbf{F#}] or in \guitarChord{\textbf{F#}} |
| 272 |
%%# the "b" of "\textbf" gets replaced which is of course not what you want. |
| 273 |
%%# To avoid this replacement, there is a * version of the respective |
| 274 |
%%# commands, i.e. the above example works in the intended way if you write |
| 275 |
%%# instead [*\textbf{F\guitarSharp}] or |
| 276 |
%%# \guitarChord*{\textbf{F\guitarSharp}} |
| 277 |
%%# (you have to use the command "\guitarSharp", because due to the * also |
| 278 |
%%# the # would not be replaced). |
| 279 |
%%# |
| 280 |
%%# 2. There are some situations in which catcodes are set too early, |
| 281 |
%%# e.g. if you use the macros within the argument of certain macros. |
| 282 |
%%# In this case, these symbols keep their usual \TeX\ meaning |
| 283 |
%%# (which may either lead to an error in case of "#" (and sometimes "[") or |
| 284 |
%%# just to a false output). If this happens to you, you have to replace at |
| 285 |
%%# the corresponding place the above one-symbol shortcuts by their longer |
| 286 |
%%# macro equivalents. In other words: You might have to replace in |
| 287 |
%%# certain special situations some occurrences of the symbols according to |
| 288 |
%%# the following table: |
| 289 |
%%# |
| 290 |
%%# [...] -> \guitarChord{...} |
| 291 |
%%# # -> \guitarSharp |
| 292 |
%%# b -> \guitarFlat |
| 293 |
%%# linefeed -> \guitarEndLine |
| 294 |
%%# 2 linefeeds -> \guitarEndPar |
| 295 |
%%# 3+ linefeeds -> \guitarEndDoublePar |
| 296 |
%%# |
| 297 |
|
| 298 |
\endinput |
| 299 |
%% |
| 300 |
%% End of file `guitar.txt'. |