I would like to define a new command with two optional arguments, one at the end. This works:


But I would like to call it like this:


leaving out the optional brackets, if I don't need them. Is it possible?

1 Answer 1


You want to use \NewDocumentCommand. The o argument specifier means an optional argument with no default value, which can be tested with \IfValueTF (in this case only the “true“ branch is necessary).

Note that \textbf is wrong in this context and you want \mathbf.


%\usepackage{xparse} % for LaTeX prior to the 2020-10-01 release

\NewDocumentCommand{\matr}{ o m o }







enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .