Using \def
I can define a command as follows:
\def\aecmd#1 located at (#2);{---definition---}
I can recreate this with xparse
as follows:
\NewDocumentCommand\aecmd{ u{~located~at~(}u{);}}{----definition---}
However, I have a situation where I want to be able to write a command with an (almost final) optional argument. This would be a pain in the neck to do with \def
.
I'd like a command which could be expressed as either
\aecmd{Manditory content}[optional content] located at (location);
or
\aecmd{Manditory content} located at (location);
Essentially, I would like something that works like r
but instead of taking a single token as the delimiters can take whole strings. Let's call this hypothetical argument specifier b
Then my desired command could be defined along these lines:
\NewDocumentCommand{ mob{~located~at~(}{);}{ ---something--- }
I'm aware I could write something like that following:
\NewDocumentCommand\aecmd{ mou{~located~at~(}u{);}{---definition---}
Further, I suppose that I could test whether or not something was passed in the 3rd argument and raise an error if there was anything there.
But this just seems clunky. It doesn't feel right to me.
Any suggestions about how to do this better?