11

enter image description here

I want to have some numbers in my table bold. But get some troubles with the decimal points of the numbers. Here is my code for it:

\begin{document} 
\begin{table}[htbp]
  \centering
  \caption{}
    \begin{tabular}{r|SSS|SSS|S}
    \toprule
    \multicolumn{1}{r}{\multirow{2}[2]{*}{$r$}} & \multicolumn{1}{r}{\multirow{2}[2]{*}{$IC_{1}$}} & \multicolumn{1}{r}{\multirow{2}[2]{*}{$IC_{2}$}} & \multicolumn{1}{r}{\multirow{2}[2]{*}{$IC_{3}$}} & \multicolumn{1}{r}{\multirow{2}[2]{*}{$IC_{1}$}} & \multicolumn{1}{r}{\multirow{2}[2]{*}{$IC_{2}$}} & \multicolumn{1}{r}{\multirow{2}[2]{*}{$IC_{3}$}} & \multicolumn{1}{c}{\multirow{2}[2]{*}{$\mu_{i}$}} \\
    \multicolumn{1}{r}{} &       &       & \multicolumn{1}{r}{} &       &       & \multicolumn{1}{r}{} &  \\
    \midrule
    1     & 0.60  & 0.65  & 0.65  & 0.61  & 0.66  & $\mathbf{0.79}$  & 0.40 \\
    2     & 0.45  & 0.55  & 0.55  & 0.46  & 0.56  & 0.84  & 0.15 \\
    3     & 0.35  & 0.49  & 0.50  & 0.37  & 0.52  & 0.93  & 0.10 \\
    4     & 0.26  & 0.45  & 0.45  & 0.28  & 0.48  & 1.02  & 0.10 \\
    \toprule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}% 
end{document}

Is there some general solutions, which can be used for other tables as well? Thank you!

egreg
  • 1,121,712
tibiooo
  • 185

1 Answers1

13

Use the proper siunitx feature:

\documentclass{article}
\usepackage{siunitx,booktabs,caption}

\begin{document}

\begin{table}[htbp]
\centering

\caption{}\label{tab:addlabel}

\begin{tabular}{
 r
 *{7}{S[table-format=1.2]}
}
\toprule
\addlinespace[6pt]
$r$ & {$IC_{1}$} & {$IC_{2}$} & {$IC_{3}$} & {$IC_{1}$} & {$IC_{2}$} & {$IC_{3}$} & {$\mu_{i}$} \\
\addlinespace[3pt]
\midrule
1 & 0.60  & 0.65  & 0.65  & 0.61  & 0.66  & \bfseries 0.79  & 0.40 \\
2 & 0.45  & 0.55  & 0.55  & 0.46  & 0.56  &           0.84  & 0.15 \\
3 & 0.35  & 0.49  & 0.50  & 0.37  & 0.52  &           0.93  & 0.10 \\
4 & 0.26  & 0.45  & 0.45  & 0.28  & 0.48  &           1.02  & 0.10 \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

I removed the \multirow tricks; if you really want more vertical space before and after the column headers, use \addlinespace as shown; but it's not required and I wouldn't do it.

enter image description here

egreg
  • 1,121,712
  • 1
    thank u for your reply. just for understanding: u defined 7 columns with the S command from package siunitx and u defined manually the table-format with 1.2, which should indicate one number infront of the decimal point and 2 numbers after the decimal point? thank you – tibiooo Jun 30 '19 at 15:11
  • 1
    @alix correctly deduced. – Skillmon Jun 30 '19 at 15:29
  • 1
    @alix Yes; only specifying S gives a default, which might not be good for the specific table. – egreg Jun 30 '19 at 15:38