我怎样才能生成这个累计数字表?我试过了,但没有成功。
答案1
借助附加列和的示例\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}
答案2
把所有东西都当成一列:
\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}
答案3
第二种方法是tabular, array
使用booktabs
代码:
\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}