LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

 Options: Use Classic View Use Monospaced Font Show Text Part by Default Show All Mail Headers Topic: [<< First] [< Prev] [Next >] [Last >>]

 Re: Rescanning first token of environment when no optional argument is given Benjamin Berg <[log in to unmask]> Mon, 1 Apr 2019 09:29:53 +0200 text/plain (944 bytes) , signature.asc (832 bytes) 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