我的一个由代码编写的命令出现了一个奇怪的giving up on this path, did you forget a semicolon?
+错误(代码本身可以完美运行,由 建议给我,参见。missing } inserted
tikz
Sandy G
https://tex.stackexchange.com/a/670836/262813;错误来自于我的命令)。
如果之后添加另一个命令(这里是控制箭头),则该\coolbrace
命令会导致错误\draw
;但如果先绘制箭头,则不会发生错误。知道错误在哪里吗?
平均能量损失
\documentclass{article}
\usepackage[linguistics]{forest}
\usetikzlibrary{decorations.pathreplacing}
\NewDocumentCommand{\coolbraceauxone}{mmmmmmm}{
\draw[decorate,semithick,decoration={brace,amplitude=#1pt}]([shift={(#3,#4)}]#6.north east)--node[sloped, above=#2pt, align=center]{#5}([shift={(#3+0.9,#4)}]#7.south east);}
\NewDocumentCommand{\coolbraceaux}{mmmmm>{\SplitArgument{1}{,}}m}{%
\coolbraceauxone{#1}{#2}{#3}{#4}{#5}#6}
\ExplSyntaxOn
\NewDocumentCommand{\coolbrace}{O{}mm}
{
\group_begin:
\keys_set:nn {coolbrace} {#1}
\coolbrace:VVVVVnn
\coolbrace_size
\coolbrace_above
\coolbrace_xshift
\coolbrace_yshift
\coolbrace_text
{#2}
{#3}
\group_end:
}
\keys_define:nn {coolbrace}
{
size.tl_set:N = \coolbrace_size,
above.tl_set:N = \coolbrace_above,
xshift.tl_set:N = \coolbrace_xshift,
yshift.tl_set:N = \coolbrace_yshift,
text.tl_set:N = \coolbrace_text,
size.initial:n = 8,
above.initial:n = 10,
xshift.initial:n = 0,
yshift.initial:n = 0.4,
text.initial:n = ~,}
\cs_set_eq:NN\coolbrace:nnnnnnn\coolbraceaux
\cs_generate_variant:Nn\coolbrace:nnnnnnn{VVVVV}
\ExplSyntaxOff
\begin{document}
\begin{forest}
[ASP,name=pol[\textit{subject},name=subject][Asp
[asp][POL
[AdvP[\textit{non},roof]][Pol, name=nab
[pol][aP
[~,name=arg][a'
[a][root]]]]]]]
\draw[dashed,->,>=stealth] (arg)..controls +(west:2) and +(south west:2)..(subject);
\coolbrace[text=Adjective]{pol,nab}% No problem here.
% The following order triggers a bug:
%\coolbrace[text=Adjective]{pol,nab}
%\draw[dashed,->,>=stealth] (arg)..controls +(west:2) and +(south west:2)..(subject);
\end{forest}
\end{document}
答案1
问题在于 的定义\coolbrace
,它被定义为接受两个强制参数,但只接收一个。
这是的正确定义\coolbrace
。(它还修复了辅助宏中的参数相关问题。)
\documentclass{article}
\usepackage[linguistics]{forest}
\usetikzlibrary{decorations.pathreplacing}
\NewDocumentCommand{\coolbraceauxone}{mmmmmmm}{
\draw[decorate,semithick,decoration={brace,amplitude=#1pt}]([shift={(#3,#4)}]#6.north east)--node[sloped, above=#2pt, align=center]{#5}([shift={(#3+0.9,#4)}]#7.south east);}
\NewDocumentCommand{\coolbraceaux}{mmmmm>{\SplitArgument{1}{,}}m}{%
\coolbraceauxone{#1}{#2}{#3}{#4}{#5}#6}
\ExplSyntaxOn
\NewDocumentCommand{\coolbrace}{O{}m}
{
\group_begin:
\keys_set:nn {coolbrace} {#1}
\coolbrace:VVVVVn
\coolbrace_size
\coolbrace_above
\coolbrace_xshift
\coolbrace_yshift
\coolbrace_text
{#2}
\group_end:
}
\keys_define:nn {coolbrace}
{
size.tl_set:N = \coolbrace_size,
above.tl_set:N = \coolbrace_above,
xshift.tl_set:N = \coolbrace_xshift,
yshift.tl_set:N = \coolbrace_yshift,
text.tl_set:N = \coolbrace_text,
size.initial:n = 8,
above.initial:n = 10,
xshift.initial:n = 0,
yshift.initial:n = 0.4,
text.initial:n = ~,}
\cs_set_eq:NN\coolbrace:nnnnnn\coolbraceaux
\cs_generate_variant:Nn\coolbrace:nnnnnn{VVVVVn}
\ExplSyntaxOff
\begin{document}
\begin{forest}
[ASP,name=pol[\textit{subject},name=subject][Asp
[asp][POL
[AdvP[\textit{non},roof]][Pol, name=nab
[pol][aP
[~,name=arg][a'
[a][root]]]]]]]
% \draw[dashed,->,>=stealth] (arg)..controls +(west:2) and +(south west:2)..(subject);
% \coolbrace[text=Adjective]{pol,nab}% No problem here.
% The following order triggers a bug:
\coolbrace[text=Adjective]{pol,nab}
\draw[dashed,->,>=stealth] (arg)..controls +(west:2) and +(south west:2)..(subject);
\end{forest}
\end{document}