2

I have the following table:

\documentclass{article}
\usepackage{booktabs}
\begin{document}    
\begin{table}
\centering
\begin{tabular}{ lcccccccc } 
\toprule
\multicolumn{5}{c}{\textbf{Training time per fold}}  \\ 
\toprule
\textbf{Average per fold}     & 1462.20 & 1482.31 & 1487.15 & 1496.49    \\[2pt] \hline
\textbf{Stddev per fold}      & 35.13   & 28.09   &  30.10  &  31.30   \\[2pt] \hline
\textbf{Average per sequence} & 365.55  & 370.58  &  371.79 &  374.12   \\[2pt] 
\midrule
\multicolumn{5}{c}{\textbf{Time for classification per fold}} \\ 
\midrule
\textbf{Average per fold}     & 1092.39 & 1101.13  & 1102.03 & 1080.47 \\[2pt] \hline
\textbf{Stddev per fold}      &  53.17  & 43.73    & 46.43   & 45.66   \\[2pt] \hline
\textbf{Average per sequence} & 273.10  & 275.28   & 275.51  & 270.12  \\[2pt] 
\bottomrule
\end{tabular}
\end{table}
\end{document}

I would like to align all numbers with respect to their decimal position, that means all dots should be aligned.

  • Siunitx or dcolumn – cmhughes Apr 9 '16 at 16:41
4

Here is a solution with siunitx and booktabs. Don't use too many rules.

\documentclass{article} 
\usepackage[utf8]{inputenc}
\usepackage{booktabs, array}
\usepackage{siunitx} 

\begin{document}

\begin{table}
\centering 
    \begin{tabular}{ l*{4}{S[table-format=4.2, table-number-alignment=center]}}
         \toprule 
         \multicolumn{5}{c}{\textbf{Training time per fold}} \\
         \cmidrule[\lightrulewidth](lr){1-5}
         \textbf{Average per fold} & 1462.20 & 1482.31 & 1487.15 & 1496.49 \\ 
         %\hline%
         \textbf{Stddev per fold} & 35.13 & 28.09 & 30.10 & 31.30 \\[2pt]
         %\hline%
         \textbf{Average per sequence} & 365.55 & 370.58 & 371.79 & 374.12 \\ 
         \midrule[\heavyrulewidth]
         \multicolumn{5}{c}{\textbf{Time for classification per fold}} \\ 
         \cmidrule[\lightrulewidth](lr){1-5}
         \textbf{Average per fold} & 1092.39 & 1101.13 & 1102.03 & 1080.47 \\ 
         %\hline %
         \textbf{Stddev per fold} & 53.17 & 43.73 & 46.43 & 45.66 \\ 
        % \hline %
         \textbf{Average per sequence} & 273.10 & 275.28 & 275.51 & 270.12 \\ 
     \bottomrule \end{tabular}
  \end{table}

\end{document} 

enter image description here

|improve this answer|||||
  • What's with the comment characters at the ends of many lines of code? :-) – Mico Apr 9 '16 at 17:23
  • @Mico: It comes from a problem with line wrapping in WinEdt latest release – for legibility of code. – Bernard Apr 9 '16 at 19:03

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