I want pdflatex to take the command \num from the package siunitx, but the command seems to already be defined in the package stata obtainable (in complicated ways, if you don't have stata, unfortunately) from http://repec.sowi.unibe.ch/stata/texdoc/index.html.
(I'd provide the whole sty file in a github repo, but I don't know whether the Stata ToS or Ben Jann would allow it, so, sorry about that.)
Main question
How do I tell LaTeX to take the definition of \num from siunitx.sty without altering stata.sty (like, say, just going ahead and deleting that line in stata.sty, which would solve the problem instantly, but I might need that definition later in another document)? Other adviceful comments welcome whatsoever.
Here is an MWE, the desired and faulty output:
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{stata} % <--- deactivate to get desired output
\usepackage{siunitx}
\begin{document}
\begin{align*}
P(x \leq 2) & = \num{1e-9} + \num{8.1e-8}
\end{align*}
\num{1e-9}
\end{document}
what it should look like
what it does look like
the error I get (logfile)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "xparse/command-already-defined"
!
! Command '\num' already defined!
!
! See the LaTeX3 documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.7289 }
|'''''''''''''''''''''''''''''''''''''''''''''''
| You have used \NewDocumentCommand with a command that already has a
| definition.
| The existing definition of '\num' will not be altered.
|...............................................
and (error list in texstudio)
LaTeX error: "xparse/command-already-defined" Command '\num' already defined! For immediate help type H <return>. }
the definition of \num in siunitx.sty
\NewDocumentCommand \num { o m } {
\leavevmode
\group_begin:
\bool_set_false:N \l__siunitx_font_set_bool
\IfNoValueF {#1}
{ \keys_set:nn { siunitx } {#1} }
\__siunitx_number_output:n {#2}
\group_end:
}
and the same definition in stata.sty
\def\num{{\it \#\/}}
(Annotation: I know the command \it is deprecated, since I am told so by the program, if I invert the load order ot the packages stata and siunitx, but that's a different matter I shall need to discuss with Dr. Jann)


stata.stybut as a work-around you could put\let\num\relaxor (maybe better?)\let\num\undefinedbetween loadingstataandsiunitx. – campa Mar 07 '18 at 16:23\let\num\undefinedas in https://tex.stackexchange.com/questions/35962/undefining-custom-commands. – Marijn Mar 07 '18 at 16:26siunitxfirst, then\let\SInum\numand\let\num\relax. Then, loadstatapackage. Use\SInumwhen you want thesiunitxversion. – Steven B. Segletes Mar 07 '18 at 16:26\numcommand, but inverting the order might produce other, yet unknown, issues down the road. – thymaro Mar 07 '18 at 16:45