0

I want to align the number values of second and third column in the table, with the decimal point. Anyone can help me?

\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\begin{table}[htbp]
\centering
\begin{tabular}{p{2cm} *{2}{C{2.5cm}} C{2cm}}
   \toprule
     \multicolumn{1}{c}{ } &
     \multicolumn{1}{c}{sub-problem 1} &
     \multicolumn{1}{c}{sub-problem 2}\\
     \cmidrule(lr){2-2} \cmidrule(lr){3-3} 
     \multicolumn{1}{l}{$X=R/T$}&  \multicolumn{1}{c}{$F_{TH}^{opt}$} & \multicolumn{1}{c}{$F_{TH}^{W_{c}^{opt}}$} & \multicolumn{1}{c}{Error ($\%$)} \\              
   \midrule
   $0.33$  & 0.054 & 0.1209 & $6.7$ \\
   $0.6$   & 0.0102 & 0.0373 & $2.7$ \\
   $0.866$ & 0.0032 & 0.0179 & $1.47$ \\
   $1$     & 0.002 & 0.002 & $0$ \\
   $1.2$   & 0.0023 & 0.0061 & $0.38$ \\
   $2$     & 0.0036 & 0.0827 & $7.9$ \\
   \bottomrule
\end{tabular}
\caption{ }
\label{ }
\end{table}
0

With siunitx, it's easy:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{booktabs, caption}
\captionsetup{labelfont = sc}
\usepackage{siunitx}

\begin{document}

\begin{table}[htbp]
  \centering\sisetup{table-format=1.4, table-number-alignment=center}
  \begin{tabular}{S[table-format=1.3] *{2}{S}S[table-format=1.2] }
    \toprule & {sub-problem 1} &{sub-problem 2}\\
    \cmidrule(lr){2-2} \cmidrule(lr){3-3}
    {$X=R/T$} & {$F_{TH}^\textrm{opt}$} & {$F_{TH}^{W_{c}^\textrm{opt}}$} & {Error ($\%$)} \\
    \midrule
    0.33 & 0.054 & 0.1209 & 6.7 \\
    0.6 & 0.0102 & 0.0373 & 2.7 \\
    0.866 & 0.0032 & 0.0179 & 1.47 \\
    1 & 0.002 & 0.002 & 0 \\
    1.2 & 0.0023 & 0.0061 & 0.38 \\
    2 & 0.0036 & 0.0827 & 7.9 \\
    \bottomrule
  \end{tabular}
  \caption{ }
  \label{ }
\end{table}

\end{document} 

enter image description here

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.