diff options
author | Karl Berry <karl@freefriends.org> | 2014-09-15 22:57:22 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-09-15 22:57:22 +0000 |
commit | 720ab6d5bd9c366793fd8f03c58aec9b4348bf4d (patch) | |
tree | 82056343b04f7f5ec1101a536dccfb5ab316c783 /Master/texmf-dist/tex/latex/guitarchordschemes | |
parent | d2fd2a3b5c16b8291823a204b10077dc0bfa0ce2 (diff) |
guitarchordschemes (15sep14)
git-svn-id: svn://tug.org/texlive/trunk@35179 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/guitarchordschemes')
-rw-r--r-- | Master/texmf-dist/tex/latex/guitarchordschemes/guitarchordschemes.sty | 325 |
1 files changed, 190 insertions, 135 deletions
diff --git a/Master/texmf-dist/tex/latex/guitarchordschemes/guitarchordschemes.sty b/Master/texmf-dist/tex/latex/guitarchordschemes/guitarchordschemes.sty index 8e6f9e75a61..7caf6de3ac4 100644 --- a/Master/texmf-dist/tex/latex/guitarchordschemes/guitarchordschemes.sty +++ b/Master/texmf-dist/tex/latex/guitarchordschemes/guitarchordschemes.sty @@ -8,7 +8,7 @@ % Web: https://bitbucket.org/cgnieder/guitarchordschemes/ % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2013 Clemens Niederberger +% Copyright 2013-2014 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -34,29 +34,24 @@ % % package info and requirements: \NeedsTeXFormat{LaTeX2e} -\def\gcs@date{2013/08/25} -\def\gcs@version{v0.4} +\def\gcs@date{2014/09/15} +\def\gcs@version{v0.6} \def\gcs@description{Guitar Chord and Scale Tablatures with TikZ (CN)} \ProvidesPackage{guitarchordschemes}[\gcs@date\space \gcs@version\space \gcs@description] -\RequirePackage{tikz,etoolbox,pgfopts} +\RequirePackage{tikz,cnltx-base} \usetikzlibrary{shapes.misc,arrows,calc} % -------------------------------------------------------------------------- % message handling -\def\gcs@create@message#1{% - \ifstrequal{#1}{Error} - {% - \lowercase{\csdef{gcs@#1}}##1##2{% - \csuse{Package#1}{guitarchordschemes}{##1}{##2}}% - }{% - \lowercase{\csdef{gcs@#1}}##1{% - \csuse{Package#1}{guitarchordschemes}{##1}}% - }} -\gcs@create@message{Error} -\gcs@create@message{Warning} -\gcs@create@message{WarningNoLine} -\gcs@create@message{Info} +\newcommand*\gcs@error@message{% + For details have a look at the `guitarchordschemes' manual.% +} + +\cnltx@create@generic@message{gcs}{guitarchordschemes}{Error}{\gcs@error@message} +\cnltx@create@generic@message{gcs}{guitarchordschemes}{Warning}{} +\cnltx@create@generic@message{gcs}{guitarchordschemes}{WarningNoLine}{} +\cnltx@create@generic@message{gcs}{guitarchordschemes}{Info}{} \def\gcs@missing@date@error#1#2{% \gcs@error @@ -64,23 +59,39 @@ {#1: It seems you didn't specify the #2}% } -\def\gcs@cs@new{\protected\def} +\newrobustcmd*\gcs@def[1]{% + \ifdef{#1} + {% + \gcs@error + {The macro \string#1\space is already defined} + {% + The macro \string#1\space is already defined. Please let the package + author know% + }% + } + {\protected\def#1}% +} + +\gcs@def\gcs@deprecated@option#1#2{% + \gcs@warning{Since version #1 the option `#2' has been dropped}% +} % -------------------------------------------------------------------------- % package options and setup: -\newbool{gcs@rbc} +\newcommand*\gcs@finger@font{\sffamily\small} +\newcommand*\gcs@position@font{\sffamily} +\newcommand*\gcs@name@font{\large} +\newcommand*\gcs@string@name@format{\sffamily\small} -\def\gcs@finger@font{\sffamily\small} -\def\gcs@position@font{\sffamily} -\def\gcs@name@font{\large} -\def\gcs@string@name@format{\sffamily\small} +\newcommand*\gcs@x@unit{.8cm} +\newcommand*\gcs@y@unit{.8cm} +\newcommand*\gcs@line@width{1pt} +\newcommand*\gcs@finger@radius{.1875} +\newcommand*\gcs@finger@x@offset{.375} +\newcommand*\gcs@finger@y@offset{.275} -\def\gcs@x@unit{.8cm} -\def\gcs@y@unit{.8cm} -\def\gcs@line@width{1pt} -\def\gcs@finger@radius{.1875} -\def\gcs@finger@x@offset{.375} -\def\gcs@finger@y@offset{.275} +\newcommand*\gcs@chordscheme@fret@number{4} +\newcommand*\gcs@scales@fret@number{6} \pgfkeys{ guitarchordschemes/.cd , @@ -98,10 +109,26 @@ name-format+/.code = \expandafter\def\expandafter\gcs@name@font \expandafter{\gcs@name@font#1} , + chord-name-cs/.code = {\let\gcs@chord@name@command=#1} , + scales-name-cs/.code = {\let\gcs@scales@name@command=#1} , string-name-format/.code = \def\gcs@string@name@format{#1} , string-name-format+/.code = \expandafter\def\expandafter\gcs@string@name@format \expandafter{\gcs@string@name@format#1} , + chord-frets/.code = + \ifnumless{#1}{4} + {% + \gcs@warning{You cannot use less than 4 frets for a chord!}% + \def\gcs@chordscheme@fret@number{4}% + } + {\def\gcs@chordscheme@fret@number{#1}} , + scales-frets/.code = + \ifnumless{#1}{6} + {% + \gcs@warning{You cannot use less than 6 frets for a scale!}% + \def\gcs@scales@fret@number{6}% + } + {\def\gcs@scales@fret@number{#1}} , line-width/.code = \def\gcs@line@width{#1} , finger-radius/.code = \def\gcs@finger@radius{#1} , finger-x-offset/.code = \def\gcs@finger@x@offset{#1} , @@ -112,14 +139,14 @@ ringing-style/.code = \tikzset{ringing style/.style={#1}} , muted-style/.code = \tikzset{muted style/.style={#1}} , tuning/.code = \gcs@chord@tuning{#1} , - use-rbc/.is if = gcs@rbc + use-rbc/.code = \gcs@deprecated@option{0.5}{use-rbc} } % the setup command: \newrobustcmd*\setchordscheme[1]{\pgfqkeys{/guitarchordschemes}{#1}} \newcounter{gcs@string@number} -\newcommand\gcs@chord@tuning[1]{% +\newrobustcmd*\gcs@chord@tuning[1]{% \setcounter{gcs@string@number}{0}% \foreach \string@name in {#1} {% @@ -141,10 +168,6 @@ \ProcessPgfOptions* % -------------------------------------------------------------------------- -% are we using `realbookchords'? -\ifbool{gcs@rbc}{\RequirePackage{realbookchords}}{} - -% -------------------------------------------------------------------------- % settings for the whole scheme: \tikzset{ gcs/finger/.style = @@ -165,7 +188,14 @@ show-root/.code = \gcs@chord@show@root{#1} , mute/.code = \gcs@chord@mute{#1} , ring/.code = \gcs@chord@ring{#1} , - barre/.code = \gcs@chord@barre{#1} + barre/.code = \gcs@chord@barre{#1} , + fret-number/.code = + \ifnumless{#1}{4} + {% + \gcs@warning{You cannot use less than 4 frets for a chord!}% + \def\gcs@chordscheme@fret@number{4}% + } + {\def\gcs@chordscheme@fret@number{#1}} } % setting a scale: @@ -175,7 +205,7 @@ position/.code = \def\gcs@scales@position{#1} , finger/.code = \gcs@scales@finger{#1} , root/.code = \gcs@scales@root{#1} , - fret number/.code = + fret-number/.code = \ifnumless{#1}{6} {% \gcs@warning{You cannot use less than 6 frets for a scale!}% @@ -332,68 +362,72 @@ % placing fingers: % <fret>/<string>:<finger> -\gcs@cs@new\gcs@chord@finger#1{% +\newrobustcmd*\gcs@chord@finger[1]{% \foreach \gcs@finger@spec in {#1} { \expandafter\gcs@get@finger@data\gcs@finger@spec::\q@stop - \ifdefvoid\finger@x + \ifdefvoid\gcs@finger@x {\gcs@missing@date@error{finger}{position}} { - \pgfmathsetmacro\finger@fret{1.5*\finger@x-0.75} - \ifdefvoid\finger@y + \pgfmathsetmacro\gcs@finger@fret{1.5*\gcs@finger@x-0.75} + \ifdefvoid\gcs@finger@y {\gcs@missing@date@error{finger}{string}} { - \pgfmathsetmacro\finger@string{(6-\finger@y)*4/5} + \pgfmathsetmacro\gcs@finger@string{(6-\gcs@finger@y)*4/5} \draw[finger style] - (\finger@fret,\finger@string) circle (\gcs@finger@radius*\gcs@x@unit) ; - \node[gcs/finger] at (\finger@fret,\finger@string) {\finger@number} ; + (\gcs@finger@fret,\gcs@finger@string) + circle + (\gcs@finger@radius*\gcs@x@unit) ; + \node[gcs/finger] + at (\gcs@finger@fret,\gcs@finger@string) + {\gcs@finger@number} ; } } } } \let\gcs@scales@finger\gcs@chord@finger -\gcs@cs@new\gcs@get@finger@data#1/#2:#3:#4\q@stop{% - \def\finger@x{#1}% - \def\finger@y{#2}% - \def\finger@number{#3}% +\gcs@def\gcs@get@finger@data#1/#2:#3:#4\q@stop{% + \def\gcs@finger@x{#1}% + \def\gcs@finger@y{#2}% + \def\gcs@finger@number{#3}% } % placing a barre: % <fret>/<string>-<string>:<finger> -\gcs@cs@new\gcs@chord@barre#1{% +\newrobustcmd*\gcs@chord@barre[1]{% \foreach \gcs@barre@spec in {#1} { \expandafter\gcs@get@barre@data\gcs@barre@spec::\q@stop - \ifdefvoid\barre@x + \ifdefvoid\gcs@barre@x {\gcs@missing@date@error{barre}{position}} - {\pgfmathsetmacro\barre@fret{1.5*\barre@x-0.75}} - \ifdefvoid\barre@fromto + {\pgfmathsetmacro\gcs@barre@fret{1.5*\gcs@barre@x-0.75}} + \ifdefvoid\gcs@barre@fromto {\gcs@missing@date@error{barre}{string range}} { - \expandafter\gcs@barre@getstrings\barre@fromto--\q@stop - \pgfmathsetmacro\barre@lower@string{(6-\barre@lower@y)*4/5} - \pgfmathsetmacro\barre@upper@string{(6-\barre@upper@y)*4/5} + \expandafter\gcs@barre@getstrings\gcs@barre@fromto--\q@stop + \pgfmathsetmacro\gcs@barre@lower@string{(6-\gcs@barre@lower@y)*4/5} + \pgfmathsetmacro\gcs@barre@upper@string{(6-\gcs@barre@upper@y)*4/5} \draw[finger style,round cap-round cap,line width=2*\gcs@finger@radius*\gcs@x@unit] - (\barre@fret,\barre@lower@string) node[gcs/finger] {\barre@finger} + (\gcs@barre@fret,\gcs@barre@lower@string) node[gcs/finger] {\gcs@barre@finger} ++ (0,\gcs@finger@radius*\gcs@x@unit) -- - ($(\barre@fret,\barre@upper@string)+(0,-\gcs@finger@radius*\gcs@x@unit)$) + ($(\gcs@barre@fret,\gcs@barre@upper@string)+(0,-\gcs@finger@radius*\gcs@x@unit)$) ; } } } -\gcs@cs@new\gcs@get@barre@data#1/#2:#3:#4\q@stop{% - \def\barre@x{#1}% - \def\barre@fromto{#2}% - \def\barre@finger{#3}% +\gcs@def\gcs@get@barre@data#1/#2:#3:#4\q@stop{% + \def\gcs@barre@x{#1}% + \def\gcs@barre@fromto{#2}% + \def\gcs@barre@finger{#3}% } -\gcs@cs@new\gcs@barre@getstrings#1-#2-#3\q@stop{% +\gcs@def\gcs@barre@getstrings#1-#2-#3\q@stop{% \ifx#3-\relax - \def\barre@lower@y{#1}% - \def\barre@upper@y{#2}% + \def\gcs@barre@lower@y{#1}% + \def\gcs@barre@upper@y{#2}% \else \gcs@error {barre: wrong string range syntax} @@ -403,21 +437,23 @@ % placing root fingers: % <fret>/<string>:<finger> -\gcs@cs@new\gcs@chord@root#1{% +\newrobustcmd*\gcs@chord@root[1]{% \foreach \gcs@finger@spec in {#1} { \expandafter\gcs@get@finger@data\gcs@finger@spec::\q@stop - \ifdefvoid\finger@x + \ifdefvoid\gcs@finger@x {\gcs@missing@date@error{root}{position}} { - \pgfmathsetmacro\finger@fret{1.5*\finger@x-0.75} - \ifdefvoid\finger@y + \pgfmathsetmacro\gcs@finger@fret{1.5*\gcs@finger@x-0.75} + \ifdefvoid\gcs@finger@y {\gcs@missing@date@error{root}{string}} { - \pgfmathsetmacro\finger@string{(6-\finger@y)*4/5} - \node[minimum size=2*\gcs@finger@radius*\gcs@x@unit,root style] - at (\finger@fret,\finger@string) {} ; - \node[gcs/finger] at (\finger@fret,\finger@string) {\finger@number} ; + \pgfmathsetmacro\gcs@finger@string{(6-\gcs@finger@y)*4/5} + \node[minimum size=2*\gcs@finger@radius*\gcs@x@unit,inner sep=0pt,root style] + at (\gcs@finger@fret,\gcs@finger@string) {} ; + \node[gcs/finger] + at (\gcs@finger@fret,\gcs@finger@string) + {\gcs@finger@number} ; } } } @@ -426,27 +462,30 @@ % placing ghost roots: % <fret>/<string> -\gcs@cs@new\gcs@chord@show@root#1{% +\newrobustcmd*\gcs@chord@show@root[1]{% \foreach \gcs@finger@spec in {#1} { \expandafter\gcs@get@finger@data\gcs@finger@spec::\q@stop - \ifdefvoid\finger@x + \ifdefvoid\gcs@finger@x {\gcs@missing@date@error{show-root}{position}} { - \pgfmathsetmacro\finger@fret{1.5*\finger@x-0.75} - \ifdefvoid\finger@x + \pgfmathsetmacro\gcs@finger@fret{1.5*\gcs@finger@x-0.75} + \ifdefvoid\gcs@finger@x {\gcs@missing@date@error{show-root}{string}} { - \pgfmathsetmacro\finger@string{(6-\finger@y)*4/5} - \node[minimum size=2*\gcs@finger@radius*\gcs@x@unit,show root style] - at (\finger@fret,\finger@string) {} ; + \pgfmathsetmacro\gcs@finger@string{(6-\gcs@finger@y)*4/5} + \node[ + minimum size=2*\gcs@finger@radius*\gcs@x@unit, + inner sep=0pt, + show root style] + at (\gcs@finger@fret,\gcs@finger@string) {} ; } } } } % muted strings: -\gcs@cs@new\gcs@chord@mute#1{% +\newrobustcmd*\gcs@chord@mute[1]{% \foreach \muted@string in {#1} { \pgfmathsetmacro\muted@string@pos{(6-\muted@string)*4/5} @@ -455,7 +494,7 @@ } % ringing strings: -\gcs@cs@new\gcs@chord@ring#1{% +\newrobustcmd*\gcs@chord@ring[1]{% \foreach \ringing@string in {#1} { \pgfmathsetmacro\ringing@string@pos{(6-\ringing@string)*4/5} @@ -465,65 +504,74 @@ } % the chord name: -\gcs@cs@new\gcs@chord@name#1{% - \node[above,yshift=4ex] at (3,4) {% - \foreach \gcs@chord@name@variant in {#1} - {% - \gcs@name@font - \space - \ifbool{gcs@rbc} - {\expandafter\rbc\expandafter{\gcs@chord@name@variant}} - {\gcs@chord@name@variant}% - \space - }% +\newrobustcmd*\gcs@chord@name[1]{% + \node[above,yshift=4ex] at (.75*\gcs@chordscheme@fret@number,4) {% + \gcs@name@font + \foreach \gcs@chord@name@variant in {#1} + {% + \space + \expandafter\gcs@chord@name@command + \expandafter{\gcs@chord@name@variant}% + \space + }% } ; } +\newrobustcmd*\gcs@chord@name@command[1]{#1} + % the scale name: -\gcs@cs@new\gcs@scales@name#1{% - \node[above,yshift=4ex] at (4.5,4) {% - \foreach \gcs@scales@name@variant in {#1} - {% - \gcs@name@font - \space - \gcs@scales@name@variant - \space - }% +\newrobustcmd*\gcs@scales@name[1]{% + \node[above,yshift=4ex] at (.75*\gcs@scales@fret@number,4) {% + \gcs@name@font + \foreach \gcs@scales@name@variant in {#1} + {% + \space + \expandafter\gcs@scales@name@command + \expandafter{\gcs@scales@name@variant}% + \space + }% } ; } +\newrobustcmd*\gcs@scales@name@command[1]{#1} + % -------------------------------------------------------------------------- % the chord scheme command: -\gcs@cs@new\gcs@chordscheme#1{% -\begingroup -\begin{tikzpicture}[ - x=\gcs@x@unit, - y=\gcs@y@unit, - line width=\gcs@line@width, - baseline=(6thstring) - ] - \coordinate (6thstring) at (0,0) ; - \foreach \fret in { 0,1.5,3,4.5,6 } - { \draw (\fret,0) -- (\fret,4) ; } - \foreach \string@pos/\string@number in - { 0/6, 0.8/5, 1.6/4, 2.4/3, 3.2/2, 4/1, 0 } - { - \draw (0,\string@pos) node[left,minimum width=2em] - {\gcs@string@name@format\csuse{guitar@string@\string@number}} -- (6,\string@pos) ; - } - \pgfqkeys{/gcs/chord}{#1}% - \ifdefvoid\gcs@chord@position - {} - {\node[above,yshift=1ex,font=\gcs@position@font] at (.75,4) {\gcs@chord@position} ;} -\end{tikzpicture} -\endgroup +\newrobustcmd*\gcs@chordscheme[1]{% + \begingroup + \begin{tikzpicture}[ + x=\gcs@x@unit, + y=\gcs@y@unit, + line width=\gcs@line@width, + baseline=(6thstring) + ] + \coordinate (6thstring) at (0,0) ; + \pgfqkeys{/gcs/chord}{#1}% + \foreach \fret in {0,1,...,\gcs@chordscheme@fret@number} + { \draw (1.5*\fret,0) -- (1.5*\fret,4) ; } + \foreach \gcs@string@pos/\gcs@string@number in + { 0/6, 0.8/5, 1.6/4, 2.4/3, 3.2/2, 4/1, 0 } + { + \draw + (0,\gcs@string@pos) + node[left,minimum width=2em] + {\gcs@string@name@format\csuse{guitar@string@\gcs@string@number}} + -- + (1.5*\gcs@chordscheme@fret@number,\gcs@string@pos) ; + } + \ifdefvoid\gcs@chord@position + {} + { + \node[above,yshift=1ex,font=\gcs@position@font] + at (.75,4) {\gcs@chord@position} ; + } + \end{tikzpicture} + \endgroup } % -------------------------------------------------------------------------- -% the scalescommand: -\def\gcs@scales@fret@number{6} - -\gcs@cs@new\gcs@scales#1{% +% the scales command: +\newrobustcmd*\gcs@scales[1]{% \begingroup \begin{tikzpicture}[ x=\gcs@x@unit, @@ -535,18 +583,21 @@ \coordinate (6thstring) at (0,0) ; \foreach \fret in { 0,1,...,\gcs@scales@fret@number } { \draw (1.5*\fret,0) -- (1.5*\fret,4) ; } - \foreach \string@pos/\string@number in + \foreach \gcs@string@pos/\gcs@string@number in { 0/6, 0.8/5, 1.6/4, 2.4/3, 3.2/2, 4/1, 0 } { - \draw (0,\string@pos) node[left,minimum width=2em] - {\gcs@string@name@format\csuse{guitar@string@\string@number}} - -- (1.5*\gcs@scales@fret@number,\string@pos) ; + \draw + (0,\gcs@string@pos) + node[left,minimum width=2em] + {\gcs@string@name@format\csuse{guitar@string@\gcs@string@number}} + -- + (1.5*\gcs@scales@fret@number,\gcs@string@pos) ; } \ifdefvoid\gcs@scales@position {} {% - \node[above,yshift=1ex,font=\gcs@position@font] at (.75,4) - {\gcs@scales@position} ; + \node[above,yshift=1ex,font=\gcs@position@font] + at (.75,4) {\gcs@scales@position} ; } \end{tikzpicture} \endgroup @@ -560,7 +611,7 @@ % -------------------------------------------------------------------------- % the symbols for use outside of a scheme: -\newrobustcmd*\fingersymbol{% +\newrobustcmd*\gcs@fingersymbol{% \tikz\draw[finger style] (0,0) circle (\gcs@finger@radius*\gcs@x@unit);} \newrobustcmd*\rootsymbol{% @@ -592,3 +643,7 @@ 2013/05/01 v0.3 - added \scales command 2013/05/01 v0.3a - set all lengths as multiples of the base unit 2013/08/25 v0.4 - added scale option that allows variable number of frets +2014/07/16 v0.5 - add `inner sep=0pt' to `root' and `show root' styles +2014/09/15 v0.6 - new options `chord-frets', `scales-frets' and `fret-number' + +TODO: |