我正在编写歌本,我想在每节歌词上方的适当位置插入吉他和弦图。我发现该musixguit
软件包可以绘制漂亮的图表,我想将其包含在我的歌本中(显示封闭和弦的音格编号以及可能的和弦表格符号),但我无法根据歌词定位它们。
\documentclass{article}
\usepackage{musixguit}
\begin{document}
\raiseguitar {14}
\NOtes\guitar {Cm $^7$}{2}x-----\gbarre1\gdot33\gdot52
\guitar G{}o-----\gbarre3\gdot25\gdot35\gdot44\en
*Lyrics of the first *verse...
\end{document}
如何将图表放置在其预期位置(用星号表示)上方?是否可以定义一个新命令,将预定义的和弦插入歌词中的适当位置,如下例所示?
\chord{Cm7}Lyrics of the first \chord{G}verse...
谢谢。
答案1
弦只需通过一次定义\guitarchord
,并可根据需要重复使用。我习惯这样做\raiseguitar
,而不是使用设置垂直位置。\setstackgap{L}{<baselinekip of stack>}
已编辑以解决 OP 指出的缺陷。要使用的宏包括
\guitarchord\<chordname>{<chord-definition>}
和
\showchord [<short entry text>]{\<chordname>}
如果弦文本短于弦宽,则使用可选参数。请注意 MWE 中指定的两个长度,允许调整对齐和最小弦间距。
重新编辑以提供一些人可能认为更好的可选语法:
\chordline{\<chordname>}{<text>}
以下是 MWE:
\documentclass{article}
\usepackage{musixguit,stackengine}
\def\chordalign{\dimexpr2.2ex}% 2.2ex sets alignment of chord
\def\chordminwidth{\dimexpr6.5ex}% 6.5ex provides min. hskip for optional argument
\newcommand\guitarchord[2]{%
\savestack#1{\kern\chordalign\NOtes\guitar #2\en}
}
\newcommand\showchord[2][\relax]{%
\ifx\relax#1\relax\def\tmpuaw{T}\else\def\tmpuaw{F}\fi%
\stackengine{\Lstackgap}{#1}{%
\makebox[0ex][l]{#2}\kern\chordminwidth}{O}{l}{F}{\tmpuaw}{L}%
}
\newcommand\chordline[2]{\setbox0=\hbox{#2}%
\ifdim\wd0>\chordminwidth\showchord{#1}#2\else\showchord[#2]{#1}\fi%
}
\raiseguitar {0}
\setstackgap{L}{2.7\baselineskip}
\begin{document}
\guitarchord\Cm{{Cm $^7$}{2}x-----\gbarre1\gdot33\gdot52}
\guitarchord\GM{G{}o-----\gbarre3\gdot25\gdot35\gdot44}
\showchord[Ly-]{\Cm} \showchord{\GM}rics of the first
\showchord[of 2]{\Cm} \showchord{\GM}verses ...
Alternative syntax:
\chordline{\Cm}{Ly-}
\chordline{\GM}{rics of the first}
\chordline{\Cm}{of 2}
\chordline{\GM}{verses ...}
\end{document}
虽然我不推荐这样做,因为存在潜在危险,但 OP 随后询问是否#
可以将字符(以及括号之类的东西)合并到和弦名称中。为此,我制作了#
catcode 11,并使用了大量\csname
命名法。
以下是一个这样的版本:
\documentclass{article}
\usepackage{musixguit,stackengine}
\def\chordalign{\dimexpr2.2ex}% 2.2ex sets alignment of chord
\def\chordminwidth{\dimexpr9ex}% 6.5ex provides min. hskip for optional argument
\newcommand\guitarchord[2]{%
\expandafter\savestack\expandafter{\csname #1\endcsname}{%
\kern\chordalign\NOtes\guitar #2\en}
}
\newcommand\showchord[2][\relax]{%
\ifx\relax#1\relax\def\tmpuaw{T}\else\def\tmpuaw{F}\fi%
\stackengine{\Lstackgap}{#1}{%
\makebox[0ex][l]{\csname #2\endcsname}\kern\chordminwidth}%
{O}{l}{F}{\tmpuaw}{L}%
}
\newcommand\chordline[2]{\setbox0=\hbox{#2}%
\ifdim\wd0>\chordminwidth\relax\showchord{#1}#2\else
\showchord[#2]{#1}\fi%
}
\raiseguitar {0}
\setstackgap{L}{2.7\baselineskip}
\begin{document}
\catcode`#=11
\guitarchord{F#m7(add4)}{{F$\sharp$m7(add4)$^7$}{2}x-----\gbarre1\gdot33\gdot52}
\guitarchord{GM}{G{}o-----\gbarre3\gdot25\gdot35\gdot44}
\showchord[Ly-]{F#m7(add4)} \showchord{GM}rics of the first
\showchord[of 2]{F#m7(add4)} \showchord{GM}verses ...
Alternative syntax:
\chordline{F#m7(add4)}{Ly-}
\chordline{GM}{rics of the first}
\chordline{F#m7(add4)}{of 2}
\chordline{GM}{verses ...}
\end{document}
答案2
结合guitarchordschemes
包(需要 v0.7)用于创建和弦图和leadsheets
放置和弦的包:
\documentclass{article}
\usepackage[T1]{fontenc}
% the `chords' library of the leadsheets package provides the convenient
% \chord macro; we don't any other functionality of said package so we
% use the `chords' option:
\usepackage{leadsheets}
% no parsing of the chord input:
\setleadsheets{chord-cs=}
\usepackage{guitarchordschemes}
% guitarchordschemes setup:
\setchordscheme{
tuning = {,,,,,} ,
chord-frets = 4 ,
rotate = -90 ,
x-unit = 1.5mm , y-unit = 2mm ,
finger-radius = .25 ,
line-width = .6pt ,
restrict-bounding-box ,
position-format+ = \footnotesize ,
chord-name-cs = \chordname ,
name-distance = 0pt
}
\newcommand\minorsevenAtype[2]{%
\chordscheme[
name = #1 ,
position = #2 ,
finger = {2/2,3/4} ,
barre = {1/1-5} ,
mute = {6}
]%
}
\newcommand\minorsevenEtype[2]{%
\chordscheme[
name = #1 ,
position = #2 ,
finger = {1/6} ,
barre = {1/2-4} ,
mute = {1,5}
]%
}
\newcommand\majorEtype[2]{%
\chordscheme[
name = #1 ,
position = #2 ,
finger = {2/3,3/4,3/5} ,
barre = {1/1-6}
]%
}
\newcommand\majorAtype[2]{%
\chordscheme[
name = #1 ,
position = #2 ,
finger = {3/2,3/3,3/4} ,
barre = {1/1-5} ,
mute = 6
]%
}
\newcommand\cminorseven{\minorsevenAtype{Cmi7}{III}}
\newcommand\fminorseven{\minorsevenEtype{Fmi7}{I}}
\newcommand\gmajor{\majorEtype{Gma}{III}}
\newcommand\ebmajor{\majorAtype{Ebma}{VI}}
\begin{document}
\chord{\cminorseven}Text and text and \chord{\ebmajor}more text and
\chord{\gmajor}more text and even \chord{\fminorseven}more text
\end{document}