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!

  • Potential duplicate: Align numbers by decimal point using siunitx and bfseries – barbara beeton Jun 30 '19 at 15:09
  • Although you can align correctly the decimals as showed the egreg's answer, the bold font is bigger, so warping the left-right limits of the columns is unavoidable, and is not very nice. My suggestion is highlight using a dark red font or discrete cell background, some mark or better, do not highlight anything and explain clearly in the caption or the main text what is important in the table and why. – Fran Jul 9 '19 at 9:29
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

| improve this answer | |
  • 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 likes topanswers.xyz 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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