\documentclass{article}
\begin{document}
\begin{table}[h!]
\centering
\caption{Bobot kriteria}
\label{tabel6}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Kriteria&\multicolumn{4}{c|}{Pembuat keputusan ($D_1 - D_4$)}&Nilai rata-rata\\
\hline
$C_1$&AI&AI&AI&AI&$([0.8, 0.9], [0, 0.1])$\\
\hline
$C_2$&VI&VI&VI&I&$([0.659,0.762], [0.132,0.238])$\\
\hline
\end{tabular}
\end{table}
\end{document}
为什么第 5 列的宽度与第 2、3、4 列的宽度不一样?如何修复?
答案1
如果\multicolumn
对象的宽度大于跨越列的总自然宽度,则多余的空间将进入最后一列跨越列。
如果无法将宽\multicolumn
条目拆分到多行,则可以测量它并将列宽设置为该宽度的四分之一。
\documentclass{article}
\usepackage{array}
\newlength{\spannedlength}
\AtBeginEnvironment{table}{%
\setlength{\belowcaptionskip}{\abovecaptionskip}%
\setlength{\abovecaptionskip}{0pt}%
}
\begin{document}
\begin{table}[h!]
\centering
\caption{Bobot kriteria}
\label{tabel6}
\settowidth{\spannedlength}{Pembuat keputusan ($D_1$ -- $D_4$}
% this will span four columns, six \tabcolsep spaces, but
% we need to take care of four \arrayrulewidth wide rules
\setlength{\spannedlength}{\dimexpr(\spannedlength-6\tabcolsep+4\arrayrulewidth)/4}
\begin{tabular}{|c|*{4}{w{c}{\spannedlength}|}c|}
\hline
Kriteria & \multicolumn{4}{c|}{Pembuat keputusan ($D_1$ -- $D_4$)} & Nilai rata-rata\\
\hline
$C_1$ & AI & AI & AI & AI & $([0.8, 0.9], [0, 0.1])$\\
\hline
$C_2$ & VI & VI & VI & I & $([0.659,0.762], [0.132,0.238])$\\
\hline
\end{tabular}
\end{table}
\end{document}
我已经改成了$D_1-D_2$
,$D_1$ -- $D_2$
因为它看起来不像减法。我还建议如何在标题和表格之间获得适当的距离。
booktabs
有和没有垂直线的表格的不同实现。
\documentclass{article}
\usepackage{array,booktabs}
\newlength{\spannedlength}
\AtBeginEnvironment{table}{%
\setlength{\belowcaptionskip}{\abovecaptionskip}%
\setlength{\abovecaptionskip}{0pt}%
}
\begin{document}
\begin{table}[h!]
\centering
\caption{Bobot kriteria}
\label{tabel6}
\settowidth{\spannedlength}{Pembuat keputusan ($D_1$ -- $D_4$}
% this will span four columns and six \tabcolsep spaces
\setlength{\spannedlength}{\dimexpr(\spannedlength-6\tabcolsep)/4}
\begin{tabular}{@{} c *{4}{w{c}{\spannedlength}} c @{}}
\toprule
Kriteria & \multicolumn{4}{c}{Pembuat keputusan ($D_1$ -- $D_4$)} & Nilai rata-rata\\
\midrule
$C_1$ & AI & AI & AI & AI & $([0.8, 0.9], [0, 0.1])$\\
$C_2$ & VI & VI & VI & I & $([0.659,0.762], [0.132,0.238])$\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
我建议您将其放在($D_1 - D_4$)
单独的一行上,正下方Pembuat keputusan
。
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{table}[h!]
\setlength\extrarowheight{2pt}
\addtolength\tabcolsep{2pt}
\centering
\caption{Bobot kriteria\strut}
\label{tabel6}
\begin{tabular}{ | *{6}{c|} }
\hline
Kriteria & \multicolumn{4}{c|}{Pembuat keputusan} & Nilai rata-rata \\
& \multicolumn{4}{c|}{($D_1 - D_4$)} & \\
\hline
$C_1$ & AI & AI & AI & AI & ($[0.8, 0.9]$, $[0, 0.1]$)\\
\hline
$C_2$ & VI & VI & VI & I & ($[0.659,0.762]$, $[0.132,0.238]$)\\
\hline
\end{tabular}
\end{table}
\end{document}
答案3
您可以手动固定第 2、3、4 和 5 列的宽度。
\documentclass{article}
\usepackage{caption}
\usepackage{array}
\begin{document}
\begin{table}[h!]
\centering
\caption{Bobot kriteria}
\label{tabel6}
\begin{tabular}{|c|*{4}{w{c}{1cm}|}c|}
\hline
Kriteria&\multicolumn{4}{c|}{Pembuat keputusan ($D_1 - D_4$)}&Nilai rata-rata\\
\hline
$C_1$&AI&AI&AI&AI&$([0.8, 0.9], [0, 0.1])$\\
\hline
$C_2$&VI&VI&VI&I&$([0.659,0.762], [0.132,0.238])$\\
\hline
\end{tabular}
\end{table}
\end{document}