I'm seeing a rather unexpected result with \NewDocumentCommand
. Suppose I have a custom-defined command \mybold{}
, like this:
\NewDocumentCommand{\mybold}{m}{\mathbf{#1}}
Or \oybold[]
:
\NewDocumentCommand{\oybold}{O{a}}{\mathbf{#1}}
I would expect to be able to refer to these in another \NewDocumentCommand
, like any of the following:
\NewDocumentCommand{\mmyvec}{m}{\hat\mybold{#1}}
\NewDocumentCommand{\moyvec}{m}{\hat\oybold[#1]}
\NewDocumentCommand{\omyvec}{O{a}}{\hat\mybold{#1}}
\NewDocumentCommand{\ooyvec}{O{a}}{\hat\oybold[#1]}
The first and the third just produce a bunch of errors (missing $ inserted
, missing } inserted
, extra }
etc.); while \moyvec[k]
and \ooyvec[k]
produce the following output:
(rather than the desired \hat\mathbf{k}
)
I assume this has something to do with it entering math mode twice. How can I fix this?
\hat\mybold
is the same as\hat{\mybold}
so naturally raises errors as the base of the accent is\mybold
with no argument supplied.\NewDocumentCommand
you would see same if you defined\mybold
simply as\def\mybold#1{#1}