It might be possible to do it without \ExplSyntaxOn
, but it would be really cumbersome.
With \SplitArgument{4}{,}
, the missing values are replaced by the special -NoValue-
string, that can be tested with \tl_if_novalue:nTF
.
We need to expand the test before \__krebs_coolphase:nnnnnn
sees the actual arguments.
\documentclass{article}
\usepackage[linguistics]{forest}
% this uses TikZ so it cannot go in \ExplSyntaxOn
\NewDocumentCommand{\coolphaseaux}{mmmmmm}{%
\draw[dotted,thick]([xshift=#1pt,yshift=#2pt]#6) arc[start angle=#4,end angle=#5,radius=#3cm];
}
\ExplSyntaxOn
\NewDocumentCommand{\coolphase}{>{\SplitArgument{4}{,}}om}
{
\krebs_coolphase:nnnnnn #1{#2}
}
\cs_new_protected:Nn \krebs_coolphase:nnnnnn
{
\__krebs_coolphase:eeeeen
{ \tl_if_novalue:nTF { #1 } { -58 } { #1 } }
{ \tl_if_novalue:nTF { #2 } { 0 } { #2 } }
{ \tl_if_novalue:nTF { #3 } { 8 } { #3 } }
{ \tl_if_novalue:nTF { #4 } { 150 } { #4 } }
{ \tl_if_novalue:nTF { #5 } { 110 } { #5 } }
{ #6 }
}
% make an internal version of \coolphaseaux
\cs_set_eq:NN \__krebs_coolphase:nnnnnn \coolphaseaux
% generate the needed variant
\cs_generate_variant:Nn \__krebs_coolphase:nnnnnn { eeeee }
\ExplSyntaxOff
\begin{document}
\begin{forest}
[ASP[\textit{subject}][Asp
[asp][POL
[AdvP[\textit{non},roof]][Pol
[pol, name=nab][aP
[~][a'
[a][root]]]]]]]
\coolphase[-77,2]{nab}
\end{forest}
\end{document}

However, it is much better if you use a key-value system, so you need not remember the precise order of the options.
\documentclass{article}
\usepackage[linguistics]{forest}
% this uses TikZ so it cannot go in \ExplSyntaxOn
\NewDocumentCommand{\coolphaseaux}{mmmmmm}{%
\draw[dotted,thick]([xshift=#1pt,yshift=#2pt]#6) arc[start angle=#4,end angle=#5,radius=#3cm];
}
\ExplSyntaxOn
\NewDocumentCommand{\coolphase}{O{}m}
{
\group_begin:
\keys_set:nn { krebs/coolphase } { #1 }
\krebs_coolphase:VVVVVn
\l__krebs_coolphase_x_tl
\l__krebs_coolphase_y_tl
\l__krebs_coolphase_sa_tl
\l__krebs_coolphase_ea_tl
\l__krebs_coolphase_r_tl
{#2}
\group_end:
}
\keys_define:nn { krebs/coolphase }
{
x .tl_set:N = \l__krebs_coolphase_x_tl,
y .tl_set:N = \l__krebs_coolphase_y_tl,
sa .tl_set:N = \l__krebs_coolphase_sa_tl,
ea .tl_set:N = \l__krebs_coolphase_ea_tl,
r .tl_set:N = \l__krebs_coolphase_r_tl,
x .initial:n = -58,
y .initial:n = 0,
sa .initial:n = 8,
ea .initial:n = 150,
r .initial:n = 110,
}
% make an internal version of \coolphaseaux
\cs_set_eq:NN \krebs_coolphase:nnnnnn \coolphaseaux
% generate the needed variant
\cs_generate_variant:Nn \krebs_coolphase:nnnnnn { VVVVV }
\ExplSyntaxOff
\begin{document}
\begin{forest}
[ASP[\textit{subject}][Asp
[asp][POL
[AdvP[\textit{non},roof]][Pol
[pol, name=nab][aP
[~][a'
[a][root]]]]]]]
\coolphase[x=-77,y=2]{nab}
\end{forest}
\end{document}
You could pass r=110,sa=150,x=-77,ea=110,y=2
, say, without worrying about the right order.
<1>
in order to specify<2>
in\coolphase[<1>][<2>]{...}
. However, a key-value approach would allow you to\coolphase[yshift=<2>]{...}
without having to specifyxshift
. Of course, if you're the only user, then UX is probably not a consideration...