我现在正在使用钢琴套餐。这个包有点受限,所以我想改变一些东西。圆点的标准颜色是橙色。我想在不同情况下改变这一点。但我不想sty
每次都编辑文件。我想更改
\keyboard[color = … ]…
或者
\usepackage[color = … ]{piano}
我该如何改变这一点?第一个选项是我的首选选项,但标准代码是“ \keyboard[Dso][Fso][Aso][Dst]
”,所以我必须将其更改为\keyboard{Dso}{Fso}{Aso}{Dst}
,但我不知道这是否可行……有人能帮我吗?谢谢
答案1
通过以下重新定义,\keyboard
现在您有一个由括号分隔的可选第一个参数,允许您随意更改颜色:
例如,现在你可以说:
\keyboard[Co][Eo][Gso][Ct][Et]
\keyboard(cyan)[Co][Eo][Gso][Ct][Et]
\keyboard(olive)[Co][Eo][Gso][Ct][Et]
代码:
\documentclass[11pts]{article}
\usepackage{xcolor}
\usepackage{piano}
\usepackage{xparse}
\makeatletter
\RenewDocumentCommand{\keyboard}{D(){orange}O{0}O{0}O{0}O{0}O{0}O{0}O{0}}{
%% Clavier 2 octaves
\setlength{\unitlength}{0.5cm}
\begin{picture}(15,4.5)
%Touches blanches
\multiput(0,0)(1,0){14}%
{\line(0,1){4}}
%Contour
\put(0,0){\line(0,1){4}}
\put(0,0){\line(1,0){14}}
\put(14,0){\line(0,1){4}}
\put(0,4){\line(1,0){14}}
%Touches noires
\linethickness{3mm}
\multiput(1,4)(1,0){2}%
{\line(0,-1){3}}
\multiput(4,4)(1,0){3}%
{\line(0,-1){3}}
\linethickness{3mm}
\multiput(8,4)(1,0){2}%
{\line(0,-1){3}}
\multiput(11,4)(1,0){3}%
{\line(0,-1){3}}
%Rond de note
{\color{#1}
\ifthenelse{\equal{#2}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#2}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}
\ifthenelse{\equal{#3}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#3}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}
\ifthenelse{\equal{#4}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#4}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}
\ifthenelse{\equal{#5}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#5}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}
\ifthenelse{\equal{#6}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#6}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}
\ifthenelse{\equal{#7}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#7}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}
\ifthenelse{\equal{#8}{Co}}{\put(0.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Do}}{\put(1.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Eo}}{\put(2.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Fo}}{\put(3.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Go}}{\put(4.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Ao}}{\put(5.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Bo}}{\put(6.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Ct}}{\put(7.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Dt}}{\put(8.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Et}}{\put(9.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Ft}}{\put(10.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Gt}}{\put(11.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{At}}{\put(12.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Bt}}{\put(13.5,0.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Cso}}{\put(1,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Dso}}{\put(2,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Fso}}{\put(4,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Gso}}{\put(5,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Aso}}{\put(6,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Cst}}{\put(8,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Dst}}{\put(9,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Fst}}{\put(11,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Gst}}{\put(12,1.5){\circle*{0.5}}}{
\ifthenelse{\equal{#8}{Ast}}{\put(13,1.5){\circle*{0.5}}}}{}}}}}}}}}}}}}}}}}}}}}}}
}
\end{picture}
}
\makeatother
\begin{document}
\keyboard[Co][Eo][Gso][Ct][Et]
\keyboard(cyan)[Co][Eo][Gso][Ct][Et]
\keyboard(olive)[Co][Eo][Gso][Ct][Et]
\end{document}
输出:
答案2
不建议改变参数的输入方式,方括号表示法更好,因为七个参数是可选的。
要改变颜色,最简单的方法是加载xcolor
并改变定义orange
:
\documentclass{article}
\usepackage{piano}
\usepackage{xcolor}
\colorlet{orange}{red!20}
\begin{document}
\keyboard[Co][Eo][Gso][Ct][Et]
\end{document}
该\colorlet
命令在本地起作用,因此您可以在某些环境或组中更改颜色,以免破坏默认颜色。
替代版本
另存以下文件为xpiano.sty
\ProvidesPackage{xpiano}[2014/02/24 from piano.sty by Émile Daneault]
\RequirePackage{xcolor}
\usepackage{xparse}
\definecolor{pianodefault}{RGB}{255,127,0}
\ExplSyntaxOn
\NewDocumentCommand{\keyboard}{ m }
{
\piano_keyboard:n { #1 }
}
\keys_define:nn { piano }
{
color .tl_set:N = \l_piano_color_tl,
one .tl_set:N = \l_piano_one_tl,
two .tl_set:N = \l_piano_two_tl,
three .tl_set:N = \l_piano_three_tl,
four .tl_set:N = \l_piano_four_tl,
five .tl_set:N = \l_piano_five_tl,
six .tl_set:N = \l_piano_six_tl,
seven .tl_set:N = \l_piano_seven_tl,
color .initial:n = {pianodefault},
one .initial:n = {},
two .initial:n = {},
three .initial:n = {},
four .initial:n = {},
five .initial:n = {},
six .initial:n = {},
seven .initial:n = {},
}
\cs_new_protected:Npn \piano_keyboard:n #1
{
\group_begin:
\keys_set:nn { piano } { #1 }
%% Clavier 2 octaves
\setlength{\unitlength}{0.5cm}
\begin{picture}(15,4.5)
%Touches blanches
\multiput(0,0)(1,0){14}{\line(0,1){4}}
%Contour
\put(0,0){\line(0,1){4}}
\put(0,0){\line(1,0){14}}
\put(14,0){\line(0,1){4}}
\put(0,4){\line(1,0){14}}
%Touches noires
\linethickness{3mm}
\multiput(1,4)(1,0){2}{\line(0,-1){3}}
\multiput(4,4)(1,0){3}{\line(0,-1){3}}
\multiput(8,4)(1,0){2}{\line(0,-1){3}}
\multiput(11,4)(1,0){3}{\line(0,-1){3}}
%Rond de note
\color{\l_piano_color_tl}
\__piano_do_key:N \l_piano_one_tl
\__piano_do_key:N \l_piano_two_tl
\__piano_do_key:N \l_piano_three_tl
\__piano_do_key:N \l_piano_four_tl
\__piano_do_key:N \l_piano_five_tl
\__piano_do_key:N \l_piano_six_tl
\__piano_do_key:N \l_piano_seven_tl
\end{picture}
\group_end:
}
\cs_new_protected:Npn \__piano_do_key:N #1
{
\str_case:Vn #1
{
{}{}% initial case
{Co}{\put(0.5,0.5){\circle*{0.5}}}
{Do}{\put(1.5,0.5){\circle*{0.5}}}
{Eo}{\put(2.5,0.5){\circle*{0.5}}}
{Fo}{\put(3.5,0.5){\circle*{0.5}}}
{Go}{\put(4.5,0.5){\circle*{0.5}}}
{Ao}{\put(5.5,0.5){\circle*{0.5}}}
{Bo}{\put(6.5,0.5){\circle*{0.5}}}
{Ct}{\put(7.5,0.5){\circle*{0.5}}}
{Dt}{\put(8.5,0.5){\circle*{0.5}}}
{Et}{\put(9.5,0.5){\circle*{0.5}}}
{Ft}{\put(10.5,0.5){\circle*{0.5}}}
{Gt}{\put(11.5,0.5){\circle*{0.5}}}
{At}{\put(12.5,0.5){\circle*{0.5}}}
{Bt}{\put(13.5,0.5){\circle*{0.5}}}
{Cso}{\put(1,1.5){\circle*{0.5}}}
{Dso}{\put(2,1.5){\circle*{0.5}}}
{Fso}{\put(4,1.5){\circle*{0.5}}}
{Gso}{\put(5,1.5){\circle*{0.5}}}
{Aso}{\put(6,1.5){\circle*{0.5}}}
{Cst}{\put(8,1.5){\circle*{0.5}}}
{Dst}{\put(9,1.5){\circle*{0.5}}}
{Fst}{\put(11,1.5){\circle*{0.5}}}
{Gst}{\put(12,1.5){\circle*{0.5}}}
{Ast}{\put(13,1.5){\circle*{0.5}}}
}
}
\cs_generate_variant:Nn \str_case:nn { V }
\ExplSyntaxOff
现在您可以使用键值语法输入键盘:
\documentclass{article}
\usepackage{xpiano}
\begin{document}
\keyboard{
color=red!20,
one=Co,
two=Eo,
three=Gso,
four=Ct,
five=Et
}
\bigskip
\keyboard{
one=Cso,
two=Fso,
}
\end{document}
允许的键color
用于设置颜色和one
two
three
four
five
six
seven
标记键;值color
必须是语法中的颜色名称xcolor
,可以是预定义的,也可以是像示例中那样给定的色调。
您还可以通过重新定义来全局更改默认颜色pianodefault
,例如
\definecolor{pianodefault}{RGB}{255,0,0}
或者
\colorlet{pianodefault}{red}
将红色作为默认颜色。
答案3
该piano.sty
包定义了所有点的颜色orange
。如果您重新定义颜色orange
,则可以更改插入的每个键盘的外观。不过,我不确定如何更改每个点的颜色……
\documentclass{minimal}
\usepackage{piano}
\begin{document}
% red dots
\definecolor{orange}{RGB}{255,0,0}
\keyboard[Co][Eo][Gso][Ct][Et]
% green dots
\definecolor{orange}{RGB}{0,127,0}
\keyboard[Co][Eo][Gso][Ct][Et]
% blue dots
\definecolor{orange}{RGB}{0,0,255}
\keyboard[Co][Eo][Gso][Ct][Et]
\end{document}