# How can I produce this table of cumulative numbers?

How can I produce this table of cumulative numbers? I tried without success.

-
What did you try? – Jubobs Apr 19 '14 at 9:07
This table is not easy (for me?) to read. Why are there double lines and also numbers in the first column? – Benjamin McKay Apr 19 '14 at 9:15
It is a statistic table (descriptive statistic) used to calculate cumulative numbers – Haouam Apr 19 '14 at 9:44
Thank you very much for your help ! you are the best .In less than in hour it's fantastic i'm very pleased – Haouam Apr 19 '14 at 10:31

Example with the help of additional columns and \multicolumn:

\documentclass{article}
\usepackage{array}

\begin{document}
\begingroup
\renewcommand*{\arraystretch}{1.2}%
\setlength{\extrarowheight}{.2ex}%
\setlength{\tabcolsep}{.5\tabcolsep}%
\def\X#1{&\multicolumn{2}{c}{#1}}%
\noindent
\begin{tabular}{>{$}l<{$} c||c *{5}{cc|c} c c||c c}
u_j &&& $a$ &&& $b$ &&& $c$ &&& $d$ &&& $e$ &&& $f$ &&& Total\\
\hline
\hline
n_j &&& 5 &&& 2 &&& 0 &&& 2 &&& 1 &&& 0 &&& 10\\
\hline
f_j &&& 0.5 &&& 0.2 &&& 0.0 &&& 0.2 &&& 0.1 &&& 0.0 &&& 1\\
\hline
N_{g,j} \X{0} & \X{5} & \X{7} & \X{7} & \X{9} & \X{10} & \X{10}\\
\hline
F_{g,j} \X{0} & \X{0.5} & \X{0.7} & \X{0.7} & \X{0.9} & \X{10} & \X{10}\\
\hline
N_{d,j} \X{10} & \X{5} & \X{3} & \X{3} & \X{1} & \X{0} & \X{0}\\
\hline
F_{d,j} \X{1} & \X{0.5} & \X{0.3} & \X{0.3} & \X{0.1} & \X{0} & \X{0}\\
\end{tabular}
\endgroup
\end{document}


-

Treat everything as a column:

\documentclass{article}
\usepackage{array}

\newcommand{\dvline}{\vline\hspace{\doublerulesep}\vline}

\begin{document}
\begin{table}[htp]
\centering

\caption{A table}

\medskip

\setlength{\tabcolsep}{2pt}
\begin{tabular}{>{$}l<{$}*{14}{>{$}c<{$}}}
u_j & \dvline
& a & \vline
& b & \vline
& c & \vline
& d & \vline
& e & \vline
& f & \dvline
& \multicolumn{1}{c}{Total} \\
\hline\hline
n_j & \dvline
& 5 & \vline
& 2 & \vline
& 0 & \vline
& 2 & \vline
& 1 & \vline
& 0 & \dvline
& 10 \\
\hline
f_j & \dvline
& 0.5 & \vline
& 0.2 & \vline
& 0.0 & \vline
& 0.2 & \vline
& 0.1 & \vline
& 0.0 & \dvline
& 1 \\
\hline
N_{g,j} & 0 && 5 && 7 && 7 && 9 && 10 && 10 \\
F_{g,j} & 0 && 0.5 && 0.7 && 0.7 && 0.9 && 1 && 1 \\
N_{d,j} & 10 && 5 && 3 && 3 && 1 && 0 && 0 \\
F_{d,j} & 1 && 0.5 && 0.3 && 0.3 && 0.1 && 0 && 0 \\
\end{tabular}

\end{table}
\end{document}


-

A second approach using tabular, array and booktabs

Code:

\documentclass[border=10pt]{standalone}
\usepackage{booktabs,array}

\begin{document}
\newcolumntype{C}{>{\centering\arraybackslash}m{0.3cm}}
\newcolumntype{c}{>{\centering\arraybackslash}m{1cm}}
\begin{tabular}{*{7}{CC}c}
\toprule
$u_j$ & $\vert\vert$ & a &$\vert$ &b & $\vert$ &c&$\vert$ &d&$\vert$ &e&$\vert$ &f&$\vert\vert$ &Total \\
\midrule \midrule
$n_j$ &$\vert\vert$ & 5 &$\vert$ &2 & $\vert$ &0&$\vert$ &2&$\vert$ &1&$\vert$ &0&$\vert\vert$ & 10\\
\midrule
$f_j$ &$\vert\vert$ & 0.5 &$\vert$ &0.2 & $\vert$ &0.0&$\vert$ &0.2&$\vert$ &0.1&$\vert$ &0.0&$\vert\vert$ & 1 \\ \midrule
$N_{g,j}$ &$0$ &  &$5$ &  & $7$ & &$7$ & &9 & &$10$ &&$10$ & \\ \midrule
$F_{g,j}$ &$0$ &  &$0.5$ &  & $0.7$ & &$0.7$ & &0.9 & &$1$ &&$1$   \\ \midrule
$N_{d,j}$ &$10$ &  &$5$ &  & $3$ & &$3$ & &1 & &$0$ &&$0$ & \\ \midrule
$F_{d,j}$ &$1$ &  &$0.5$ &  & $0.3$ & &$0.3$ & &0.1 & &$0$ &&$0$ & \\
\bottomrule
\end{tabular}

\end{document}

-