
次の表を、すっきりとプロフェッショナルに見えるようにタイプセットするにはどうすればよいでしょうか?
\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) 繰り返し要素を削除することから始めることをお勧めします。また、表には 9 つの列があり、各列にかなりの量の情報が含まれているため、表を横向きに組版することを検討してください。
これは、パッケージのルール描画マクロを利用する私の提案です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}
補遺: 前の提案は、テーブルに最終的にさらに多くの行が含まれるという前提に基づいています。そうでない場合は、テーブルを 2 つの部分に分割し、各部分に 2 つの列だけを含めることを検討してください。このような設定では、マテリアルを横向きモードでレンダリングする必要はありません。
\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
MWE:
\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}
生産する