Hi,

On Sun, 2019-03-31 at 18:57 -0300, Phelype Oleinik wrote:
> If you can't switch the catcode of & before looking for the
> optional argument, as David suggests

David has a good point, I could handle the optional argument parsing
myself and ensure that the case works correctly. It may not be trivial,
but it should be reasonably easy.
It had not occurred to me that I could do that.

> you can use the ! argument modifier to disallow a space token before
> the first “[”:
> \NewDocumentEnvironment { sdapsarray } { !o }

Oh, I really like the simplicity of that solution.

Thanks to you and David for the suggestions!

Benjamin

> in which case:
> 
> \begin{sdapsarray}
>   & b
> \end{sdapsarray}
> 
> will work as expected, but:
> 
> \begin{sdapsarray} [] % note the space before the []
>   & b
> \end{sdapsarray}
> 
> and:
> 
> \begin{sdapsarray}
>   []
>   & b
> \end{sdapsarray}
> 
> won't see the optional argument anymore.
> 
> Best,
> 
> Phelype