# Bold text with dcolumn [duplicate]

I use dcolumn to align (and modify) numerical entries in a table. When I try to change the font of a cell to mathbf it affects only the number before the decimal point. Assigning the mathbf to the numbers before and after the separator individually is not an option for me, because the number is read as one value from a csv file.

A similar effect also occurred when changing the color (which was already asked here). Here is my slightly modified example:

\documentclass[]{article}
\usepackage{dcolumn}
\begin{document}
\begin{tabular*}{\linewidth}{lD{,}{,}{1}}
text & 1,12\\
text & \mathbf 1,12\\       % only first part is bold
%text & \mathbf{1,12}\\     % leads to compilation error
text & \mathbf{1},\mathbf{12}\\ % not really nice and not usable for me
\end{tabular*}
\end{document}


Is there a similar solution to this problem?

Thank you very much!

-

## marked as duplicate by David Carlisle, T. Verron, Heiko Oberdiek, Martin Schröder, ThorstenJun 21 '13 at 9:18

For reference, I'd recommend having a look at the S columntype from the siunitx package too –  cmhughes Nov 27 '12 at 0:19
Thank you for the info. I do not use siunitx, because I also use other characters (placeholders that are replaced to spaces by dcolumn) as separators and I am not sure if siunitx can do this... –  Tim Nov 27 '12 at 0:22

D is defined by

\newcolumntype{D}[3]{>{\DC@{#1}{#2}{#3}}c<{\DC@end}}


so you can do a bold math version as

\documentclass[]{article}
\usepackage{dcolumn}
\showhyphens{musculoskeletal}
\makeatletter
\newcolumntype{B}[3]{>{\boldmath\DC@{#1}{#2}{#3}}c<{\DC@end}}
\makeatother
\begin{document}
\noindent
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lD{,}{,}{1}B{,}{,}{1}@{}}
text & 1,12&1,12\\
text & 1,12&1,12\\
text &\multicolumn{1}{B{,}{,}{1}}{1,12}&\multicolumn{1}{D{,}{,}{1}@{}}{1,12}\\
text & 1,12&1,12
\end{tabular*}
\end{document}

-
This works well for the whole column. I want to have to only use the bold version in some cells (although I failed to point this out in the question). Using multicol does not work (even with plain D), probably because of the extra {} around the value. –  Tim Nov 27 '12 at 6:11
\multicolumn{1}{B}{3.5} should work to give a bold number in a non-bold columns. I will update the example –  David Carlisle Nov 27 '12 at 9:48
I am not sure what I did different. Thank you! –  Tim Nov 27 '12 at 9:59
For reference: \multicolumn seems to fail, if you do not use \makeatletter and \makeatother. –  Tim Nov 27 '12 at 10:29
You need them around the definition of B otherwise \DC@ does not refer to the command named DC@ but to the undefined command named DC followed by the character @ and similarly \DC@end –  David Carlisle Nov 27 '12 at 18:02