
Wie kann ich die folgende Tabelle so setzen, dass sie übersichtlich und professionell aussieht?
\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}
Antwort1
Ich schlage vor, dass Sie damit beginnen, (a) der Überschrift mehr Struktur zu verleihen und (b) sich wiederholende Elemente zu eliminieren. Unabhängig davon sollten Sie darüber nachdenken, die Tabelle im Querformat zu setzen, insbesondere da die Tabelle neun Spalten hat, von denen jede eine nicht unerhebliche Menge an Informationen enthält.
Hier ist mein Vorschlag, der die Regelzeichnungsmakros des booktabs
Pakets nutzt.
\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}
Nachtrag: Der vorherige Vorschlag basiert auf der Annahme, dass die Tabelle letztendlich mehr Zeilen enthalten wird. Wenn das nicht der Fall ist, sollten Sie darüber nachdenken, die Tabelle in zwei Teile aufzuteilen, von denen jeder nur zwei Spalten enthält. Bei einem solchen Aufbau wäre es nicht erforderlich, das Material im Querformat darzustellen.
\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}
Antwort2
Vielleicht so etwas? Ich habe hinzugefügt
- das Paket, das die , , und
booktabs
bereitstellt\toprule
\midrule
\bottomrule
\cmidrule{}
- das
tabularx
Paket, das dietabularx
Umgebung mit derX
Spalte bereitstellt, die mehrzeiligen Inhalt unterstützt (streng genommen nicht notwendig, nachdem ich den gesamten erklärenden Text in den Zellen entfernt habe, - das
multirow
Paket, um die Fahrzeugvariablen etwas horizontal auszurichten, - das
siunitx
Paket zur korrekten Formatierung von Einheiten (in Ihrem Fall Prozentsätze) - das
caption
Paket, um die Überschrift ein wenig zu formatieren und einen besseren Abstand zwischen der (jetzt recht umfangreichen) Überschrift und der Tabelle zu schaffen, und - das
geometry
Paket, da ich keine Ahnung habe, mit welchem Seitenlayout du arbeitest, und die Tabelle etwas mehr Seitenbreite benötigte :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}
Produktion