When we look at xparse
package documentation there are four related commands
\NewDocumentCommand
\RenewDocumentCommand
\ProvideDocumentCommand
\DeclareDocumentCommand
Similarly there are four commands for environments. When I've learned about \NewCommandCopy
I've expected a similar four commands will be available. But looking at LaTeX source I've only found that
\NewCommandCopy
\RenewCommandCopy
\DeclareCommandCopy
are defined.
Is there a technical reason why \ProvideCommandCopy
was not defined?
EDIT: Example usecase
In the answer by Phelype Oleinik it is claimed that there is no usecase for such command.
Let's consider that we want to provide a black-and-white switch for the document and we want to use \IfBooleanTF
from xparse
because we are familiar with it. We know that it exports values \BooleanFalse
and \BooleanTrue
so we may write for example
\NewCommandCopy\blackandwhite\BooleanFalse
\IfBooleanTF{\blackandwhite}{...}{...}
Let's say we want to pass it when compiling document such as pdflatex '\NewCommandCopy\blackandwhite\BooleanTrue\input{document.tex}'
. This will obviously cause errors because \blackandwhite
is already defined. If there was \ProvideCommandCopy
we could use it to define the default value of \blackandwhite
switch in case user does not provide it. Currently we are forced to always define it explicitly.
Obviously there are other ways to make the black-and-white switch work as intended, but I think this is a valid usecase of ProvideCommandCopy
.
Best Answer
There isn't a
\ProvideCommandCopy
because it isn't useful (and may be harmful even), so the decision was to not implement it. There is a note in the implementation (texdoc source2e
, section Copying robust commands inltdefns.dtx
):