Custom command with \ensuremath within \textbf

I'd use a specific command:

\documentclass{article}

\newcommand{\anum}[2][n]{%
  \mbox{%
    \mathcode`,=\numexpr\mathcode`,-"6000
    \if#1b\boldmath\fi
    $#2$%
  }%
}
\newcommand{\E}[1]{\cdot10^{#1}}

\begin{document}

\anum{-4,25\E{-6}}

\anum[b]{-1,73\E{-6}}

\end{document}

enter image description here

Note that the minus sign is a real minus and not a hyphen; also the comma leaves no unwanted space.


I suggest to use the siunitx package and the detect-weight setting for is, with \num{...} as typesetter.

If the exponent-product key is omitted, the default x style for numbers is usesd.

The d-6 style will print as 10^{-6} then.

\documentclass{article}

\usepackage[detect-weight,mode=text,copy-decimal-marker=true,exponent-product=\cdot]{siunitx}

\begin{document}


\num{-1,73d-6}

\textbf{\num{-1,73d-6}}
\end{document}

enter image description here