
如何排版下表才能顯得整齊專業?
\begin{table}[!h]
\caption{A summary of classification results on the free flowing traffic dataset}
\begin{tabular}{|p{1.7 cm}|p{1.7 cm}|p{1.7 cm}|p{1.7 cm}|p{1.5 cm}|p{1.5 cm}|p{1.5 cm}|p{1.6 cm}|p{1.5 cm}|}
\hline
\textbf{Total no. of vehicles used for classification} & \textbf{No. of small vehicles used for classification} & \textbf{No. of medium vehicles used for classification} & \textbf{No. of large vehicles used for classification} & \multicolumn{5}{|c|}{\textbf{Classification accuracy}}\\
\cline{5-9}
& & & & K-nearest neighbor classifier & Nearest centroid classifier & Naïve Bayes Classifier & Multilayer neural network classifier & Ensemble classifier\\
\hline
952 & 594 & 199 & 159 & 90.9\% & 89.4\% & 91.1\% & 89.3\% & 91.8\% \\
\hline
\end{tabular}
\label{tab 4.2}
答案1
我建議您首先 (a) 為標題提供更多結構並 (b) 消除重複元素。另外,您可能需要考慮以橫向模式排版表格,特別是當表格有九列,每列都包含大量資訊時。
這是我的建議,它利用了包的規則繪製巨集booktabs
。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{rotating,caption,tabularx,booktabs}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\begin{document}
\begin{sidewaystable}[!h]
\setlength\tabcolsep{4pt} % default: 6pt
\caption{A summary of classification results on the free flowing traffic dataset} \label{tab 4.2}
\begin{tabularx}{\textwidth}{@{} c *{7}{C} c @{}}
\toprule
\multicolumn{4}{@{}c}{No.\ of vehicles used for classication, by size} &
\multicolumn{5}{c@{}}{Classification accuracy, by classifier}\\
\cmidrule(r){1-4} \cmidrule(l){5-9}
Total & Small & Medium & Large &
$K$-nearest neighbor & Nearest centroid & Naïve Bayes & Multilayer neural network & Ensemble\\
\midrule
952 & 594 & 199 & 159 & 90.9\% & 89.4\% & 91.1\% & 89.3\% & 91.8\% \\
\bottomrule
\end{tabularx}
\end{sidewaystable}
\end{document}
附錄:前面的建議是基於表最終將包含更多行的假設。如果情況並非如此,您可能需要考慮將表格分成兩部分,每部分僅包含兩列。透過這樣的設置,就不需要以橫向模式渲染材質。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{caption,booktabs}
\begin{document}
\begin{table}[!h]
\setlength\tabcolsep{4pt} % default: 6pt
\caption{Summary of classification results on the free flowing traffic dataset} \label{tab 4.2}
\centering
\begin{tabular}{@{}lr@{}}
\toprule
\multicolumn{2}{@{}l@{}}{No.\ of vehicles used for}\\ \multicolumn{2}{@{}l@{}}{classication, by size} \\[0.25ex]
\midrule
Small & 594 \\
Medium & 199 \\
Large & 159 \\[1ex]
Total & 952 \\
\bottomrule
\end{tabular}
\bigskip
\begin{tabular}{@{}lr@{}}
\toprule
\multicolumn{2}{@{}l@{}}{Classification accuracy, by classifier}\\[0.25ex]
\midrule
$K$-nearest neighbor & 90.9\% \\
Nearest centroid & 89.4\% \\
Naïve Bayes & 91.1\% \\
Multilayer neural network & 89.3\% \\[1ex]
Ensemble & 91.8\% \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
也許是這樣的?我已經添加
booktabs
提供\toprule
、\midrule
和\bottomrule
的軟體包\cmidrule{}
- 為環境
tabularx
提供支援多行內容的列的包(嚴格來說,在我刪除單元格中的所有解釋性文字後沒有必要,tabularx
X
multirow
稍微水平對齊車輛變數的包,siunitx
用於正確格式化單位的包(在您的情況下為百分比)- 該
caption
套件可以對標題進行一些樣式設置,並在(現在相當大)標題和表格之間提供更好的間距,以及 - 包
geometry
,因為我不知道您使用哪種頁面佈局,並且表格需要更多的頁面寬度:p
微量元素:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs,tabularx,siunitx,multirow}
\usepackage[hang,bf,small]{caption}
\usepackage{geometry}
\newcommand{\totNumV}{N_{V,\mathrm{tot.}}}
\newcommand{\smallV}{N_{V,\mathrm{s}}}
\newcommand{\medV}{N_{V,\mathrm{m}}}
\newcommand{\largeV}{N_{V,\mathrm{l}}}
\begin{document}
\begin{table}[!h]
\centering
\caption{A summary of classification results on the free flowing traffic dataset, where $\totNumV$ is the total number of vehicles used for classification, $\smallV{}$, $\medV{}$ and $\largeV$ are the number of small, medium and large vehicles used for classification, respectively. $K$, $C$, $\mathit{NBC}$, $M$ and $E$ are the K-nearest neighbor classifier, Nearest centroid classifier, Naïve Bayes Classifier, Multilayer neural network classifier and Ensemble classifier, respectively. }
\label{tab 4.2}
\begin{tabularx}{\textwidth}{*{9}{X}}
\toprule
\multirow{2}{*}{$\totNumV{}$} & \multirow{2}{*}{$\smallV{}$} & \multirow{2}{*}{$\medV{}$} & \multirow{2}{*}{$\largeV{}$} & \multicolumn{5}{c}{\textbf{Classification accuracy}}\\
\cmidrule{5-9}
& & & & $K$ & $C$ & $\mathit{NBC}$ & $M$ & $E$ \\
\midrule
952 & 594 & 199 & 159 & \SI{90.9}{\percent} & \SI{89.4}{\percent} & \SI{91.1}{\percent} & \SI{89.3}{\percent} & \SI{91.8}{\percent} \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
生產