我想知道是否有人可以帮助我——我对 MusixTex 比较了解。
我正在尝试使用 For Each 循环构建音阶。问题是,当我这样做时,小节的位置似乎被上移了 - 我不知道为什么。上面的图片显示了摘录应该是什么样子,下面的图片显示了我实际得到的结果。难道不能像这样以编程方式生成 MusixTex 吗?
谢谢您的帮助。
\begin{music}
\Largemusicsize
\instrumentnumber{1} % a single instrument
\setname1{}
\setstaffs1{1} % with one staff
\generalmeter{\meterfrac44} % 4/4 meter chosen
\nobarnumbers
\generalsignature{2} % Two sharps
\startpiece
\notes
\foreach \scalenote [
evaluate={
\noteletter={"N","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v"}[\scalenote+2];
\isendbar=int(mod(\scalenote,4));
}] in{1,...,7}{
\qu{\noteletter}
\ifnum\isendbar=0 {
\en\bar
\notes
}
\fi
}
\en
\endpiece
\end{music}
答案1
我认为这是代码中的空间问题,但我无法查明原因。
这似乎可以按您希望的方式工作:
\documentclass{article}
\usepackage{musixtex}
\ExplSyntaxOn
\tl_const:Nn \c_stephen_notelist_tl {abcdefghijklmnopqrstuv}
\int_new:N \g__stephen_scale_start_int
\NewDocumentCommand{\makescale}{m}
{
% #1 is the starting point in the list of notes (1=c)
\int_gset:Nn \g__stephen_scale_start_int { #1 }
\int_step_function:nnN { 1 } { 7 } \stephen_scale:n
}
\cs_new_protected:Nn \stephen_scale:n
{
\exp_args:Ne \qu { \tl_item:Nn \c_stephen_notelist_tl { \g__stephen_scale_start_int+#1+1 } }
\int_compare:nT { \int_mod:nn { #1 } { 4 } == 0 } { \en\bar\notes }
}
\ExplSyntaxOff
\begin{document}
\begin{music}
\Largemusicsize
\instrumentnumber{1} % a single instrument
\setname1{}
\setstaffs1{1} % with one staff
\generalmeter{\meterfrac44} % 4/4 meter chosen
\nobarnumbers
\generalsignature{2} % Two sharps
\startpiece
\notes
\makescale{1}
\en
\endpiece
\end{music}
\begin{music}
\Largemusicsize
\instrumentnumber{1} % a single instrument
\setname1{}
\setstaffs1{1} % with one staff
\generalmeter{\meterfrac44} % 4/4 meter chosen
\nobarnumbers
\generalsignature{-2} % Two sharps
\startpiece
\notes
\makescale{0}
\en
\endpiece
\end{music}
\end{document}
\usepackage{xparse}
如果您没有使用最新的 LaTeX 内核,则可能需要添加。