我正在使用以下代码来打印在剧本给定场景中说话的所有角色的列表。
\newcommand\sceneroles[2][Roles]{%
\def\scenename{#2}%
\textbf{#1}:%
\Bind{?id}{rdf:type}{rl:role}{%
% \GetVal prints the variable name,
% \GetValProperty extracts property from the name
% Set the default left time
% use the real at:left if it has been set
\IfProperty{\GetVal{?id}}{is:playsin#2}{%
\GetValProperty{?id}{rl:name}, %
}{}%
}%
}
问题是,我无法去掉最后一个逗号。
应该打印的是:
Roles: Romeo, Juliet
打印内容:
Roles: Romeo, Juliet,
答案1
使用这个定义:
\newcommand\sceneroles[2][Roles]{%
\def\scenename{#2}% Store scene names
\def\namesep{\def\namesep{, }}% One cycle delay name separator
\textbf{#1}:%
\Bind{?id}{rdf:type}{rl:role}{%
% \GetVal prints the variable name,
% \GetValProperty extracts property from the name
% Set the default left time
% use the real at:left if it has been set
\IfProperty{\GetVal{?id}}{is:playsin#2}{%
\namesep\GetValProperty{?id}{rl:name}%
}{}%
}%
}
它使用狡猾的 (La)TeX 技巧。