Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

It seems that macros form the \siunitx package have a \bm problem, but no problem with \textcolor:

enter image description here

Note that the 180 passed thru the \ang macro is not bold.

So, how do I change the \MyFormat macro so that \bm passes thru the siunitx macros.

Code:

\documentclass{article}
\usepackage{xcolor}
\usepackage{bm}
\usepackage{siunitx}

\newcommand*{\MyFormat}[2][blue]{\bm{\textcolor{#1}{#2}}}%

\begin{document}

\[ 
    \MyFormat{\frac{180}{\pi}} = \MyFormat{\frac{\ang{180}}{\pi}}
\]

\end{document}
share|improve this question
    
Colour and font weight are treated differently as siunitx deliberately resets the font, but does nothing to the colour. –  Joseph Wright Jul 24 '12 at 17:56
    
I ran that document with \tracingall but decided to go home rather than look at it, thankfully someone else answered. You should try it:-) \ang is more complicated than it looks (and so is \bm for that matter:-) –  David Carlisle Jul 24 '12 at 19:48
    
@DavidCarlisle: Wow!! With just the siunitx package and the document consisting only of \ang{180} I get a 5.4MB file with \tracingall. ...Well, if have just the package included and an completely empty document I still get a 4.7MB file!! How can you possibly debug with \tracingall? –  Peter Grill Jul 24 '12 at 20:48
1  
The log file looks a bit scary at first but nothing looks too bad once you have it safely in an emacs buffer. –  David Carlisle Jul 24 '12 at 20:58
    
@PeterGrill There's a lot of font switching going on. You are best off with the trace package and \traceon. (Of course, I have the advantage of knowing where to look in the first place, at least in theory.) –  Joseph Wright Jul 25 '12 at 18:25

1 Answer 1

up vote 11 down vote accepted

You can configure the siunitx package to detect bold math. Try

\sisetup{detect-weight, detect-display-math}

For in-line formulae, you additionally need:

\sisetup{detect-inline-weight=math}
share|improve this answer
6  
To elaborate a little, siunitx can deal with math mode material either as 'matching' the surrounds or as 'independent'. With the standard settings, it ignores font changes entirely. If you turn on weight detection, math material is as standard treated as 'matching' the text it is within. –  Joseph Wright Jul 24 '12 at 17:55

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.