My goal is to define a starred and a non-starred version of a macro \foo
that will be called as \foo arg {actual argument}
or \foo* arg {actual argument}
.
So I tried the following:
\makeatletter
\def\foo{\@ifstar\withstar\withoutstar}
\makeatother
\def\withstar arg #1{%
With star: #1
}
\def\withoutstar arg #1{%
Without star: #1
}
\foo* arg {actual argument}
\foo arg {actual argument}
but I get the error
! Use of \withstar doesn't match its definition.
l.67 \foo*
arg {actual argument}
However, if I change the definition of \withstar
and \withoutstar
to
\def\withstar #1{%
With star: #1
}
\def\withoutstar #1{%
Without star: #1
}
Then the calls \foo* {actual argument}
and \foo {actual argument}
work as expected. Why does this happen?