我遇到了另一个chordbox
问题,当定义的调音包含升调(或降调)时会发生这种情况。在下面给出的示例中,我定义了打开G和调音一样,但变调夹在第四品. 在第 4 品上放置变调夹,相对于开放 G 的调音是F#-BF#-BD#-F#。当我编译文档时,输出中会出现两个升号,这些升号位于指板螺母处定义的升号之后。例如,D# 后面的音符应该是 E,但在输出中却是 #D#。不幸的是,我不太熟悉 TiKZ 的具体细节,无法自行解决问题,但我想在 中定义的 for 循环或 if 语句中可能存在问题chordbox
。
\documentclass[11pt,a4paper]{article}
\usepackage[left=2cm,right=2cm,bottom=2cm,top=2cm]{geometry}
\usepackage{graphicx}
\usepackage[lofdepth,lotdepth]{subfig}
\usepackage{chordbox}
\usepackage{etoolbox}
\usepackage{hyperref}
\hypersetup{colorlinks=true,linkcolor=red}%
\pgfkeys{%
/chordbox/text on node=pitch,%
/chordbox/numfrets=6,%
/chordbox/text below=pitch,%
/chordbox/text on node =pitch,%
/chordbox/tuning={"F\#","B","F\#","B","D\#","F\#"}%
}%
\tikzset{%
chordbox/.append style={scale=2.5,thick},%
string/muted/.style={string/open,cross out,minimum size=12}%
}%
\setlength{\parindent}{0em}%
\begin{document}
\section{Open G tuning}
With a \textit{capo} on the \textit{4th fret}, the tuning is
F$\sharp$, B, F$\sharp$, B, D$\sharp$, F$\sharp$, which actually is \textit{open B}.
\begin{itemize}
\item Chordbox~\ref{fig:b_chord} is correct.
\item In chordbox~\ref{fig:b6sus4_chord}, \#G should be G$\sharp$,
and \#D$\sharp$ should be E.
\item In chordbox~\ref{fig:e_chord}, x, E, \#A$\sharp$, E, \#G, \#A$\sharp$
should be x, E, B, E, G$\sharp$, B.
\item In chordbox~\ref{fig:e6sus4_chord}, \#A$\sharp$ should be B,
\#G$\sharp$ should be A, \#C$\sharp$ should be C$\sharp$.
\item In chordbox~\ref{fig:e_over_b_chord}, \#A$\sharp$ should be B.
\end{itemize}
\begin{figure}[!h]
\centering
\subfloat[B Major][B Major]
{\chordbox{B}{x,0,0,0,0,0}\label{fig:b_chord}}
\subfloat[B6sus4][B6sus4]
{\chordbox{B6sus4}{x,0,2,0,1,0}\label{fig:b6sus4_chord}}
\subfloat[E Major][E Major]
{\chordbox{E}{x,5,5,5,5,5}\label{fig:e_chord}}
\qquad
\subfloat[E6sus4][E6sus4]
{\bchordbox[5]{E6sus4}{x,5,7,5,6,5}{5}\label{fig:e6sus4_chord}}
\subfloat[E5/B chord][E5/B]
{\chordbox{E5/B}{x,x,5,5,x,x}\label{fig:e_over_b_chord}}
\caption{Several open G chords (capo on 4th fret)}
\label{fig:globfig}
\end{figure}
\end{document}
答案1
该包使用\if
测试将调整列表与需要用于打印节点的音高列表中的条目进行匹配。当调整列表包含诸如 之类的宏时,此方法不起作用\#
。
相反,您可以使用\IfStrEq
包xstring
来进行字符串匹配。xstring
已经被使用,chordbox
因此使用该包进行检查也是有意义的。
需要重新定义的代码是 handler @typeset pitch
。可以\pgfqkeys
在加载包后使用语句进行重新定义。
序言中的相关代码:
\usepackage{chordbox}
\makeatletter
\pgfqkeys{/chordbox}{
@typeset pitch/.code 2 args={%
\pgfmathparse{{\cb@tuning}[#1-1]}%
\ifnum#2=0%
\pgfkeys{@replace symbols=\pgfmathresult}%
\else%
\foreach \p in {0,...,11} {%
\pgfmathsetmacro{\stringpitch}{{\cb@pitchnames}[\p]}%
\IfStrEq{\stringpitch}{\pgfmathresult}{%
\pgfmathparse{{\cb@pitchnames}[mod(\p + #2, 12)]}%
\pgfkeys{@replace symbols=\pgfmathresult}%
\breakforeach%
}{}%
}%
\fi%
}
}
\makeatother
结果: