TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a custom command to help me with scientific number notation:

\newcommand{\E}[1]{\ensuremath{\cdot 10^{#1}}}

The command works OK, but now I have a need to bold some of the numbers and the result is the following:

enter image description here

The code produced the image above is the following:

-4,25\E{-6}
\textbf{-1,73\E{-6}}

As you can see, the exponent part is not bolded.

My question is simple: how to bold the whole number?

share|improve this question
2  
Isn't the usage of siunitx easier here? – Christian Hupfer Mar 2 at 16:41
    
\newcommand{\E}[1]{\boldmath\ensuremath{\cdot 10^{#1}}\unboldmath}... but not recommended – Christian Hupfer Mar 2 at 16:42
    
@ChristianHupfer: I don't want to bold all the numbers, just the ones within \textbf. If there is not an easy way to do this, then I will look into siunitx. – alesc Mar 2 at 16:45
    
Actually, siunitx is the easiest way, in my point of view – Christian Hupfer Mar 2 at 17:01
up vote 2 down vote accepted

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.