这里是模板我用于以下 杂志。我对常规 latex 文档中所有完美的表格都存在问题。以下是包含所有表格的页面:
这是我添加的包和表:
% *** MATH PACKAGES ***
%
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{algorithm}
\usepackage{textcomp}
\usepackage{filecontents}
\usepackage{microtype}
\usepackage{float}
\usepackage{adjustbox}
\usepackage{booktabs,makecell,tabularx}
\usepackage{url}
\usepackage{booktabs}
\usepackage{subfigure}
\newcommand{\tvar}[2]{%
\mathrm{#1}_{\mathrm{#2}}%
}
\renewcommand\theadfont{\small}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{siunitx}
\usepackage[utf8]{inputenc}
\renewcommand{\thetable}{\arabic{table}}
\usepackage{etoolbox}
\usepackage{xparse}
\makeatletter
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
\begin{document}
\begin{table}[!htb]
\centering
\setlength{\tabcolsep}{2pt}
\small
\begin{tabularx}{0.6\columnwidth}{@{}c L S[table-format=7.0]*{2}{S[table-format=2.0]}@{}}
\toprule
\thead{ID} & \thead{UCI Dataset Name}
& {\thead{Samples}}
& {\thead{Attributes}}
& {\thead{Classes}} \\
\midrule
DS2 & \textbf {Pfsddfs}- cdfsads dfsdffdss & 2222222 & 22 & 5 \\
DS2 & \textbf {ESSSS} - cdfsads dfsdffdss cdfsads dfsdffdss cdfsads dfsdffdss cdfsads dfsdffdss
& 45555 & 9 & 2 \\
DS3 & \textbf {AAAA} - cdfsads dfsdffdss cdfsads dfsdffdss cdfsads dfsdffdss & 22222 & 54 & 7 \\
DS4 & \textbf {ABBB} - cdfsads dfsdffdss cdfsads dfsdffdss cdfsads dfsdffdss & 539383 & 28 & 2 \\
DS5 & \textbf {SSSS} & 60000 & 3 & 3 \\
\bottomrule
\end{tabularx}
\caption{Ssdfsdfsddgs dgfgdsg gsdgsfggdfsfgd sdfgfgsd}
\label{table:2}
\end{table}
\begin{table}[!htb]
\centering
\sisetup{table-format=2.3, table-number-alignment=center, tight-spacing,}% table-column-width =2.5cm
\setlength{\tabcolsep}{3pt}
\small
\centering
\sisetup{detect-weight,mode=text}
\renewrobustcmd{\bfseries}{\fontseries{b}\selectfont}
\renewrobustcmd{\boldmath}{}
% abbreviation
\newrobustcmd{\B}{\bfseries}
% shorten the intercolumn spaces
\setlength{\tabcolsep}{4pt}
\begin{tabular}{l>{\centering}lSSSS}
\toprule
\thead {Dataset \\ Name} & {\thead{No. of processed \\ records} }& {\thead{fsad fsd Trfsdee\\ Acc }} & {\thead{fsdd\\ Acc} }
& {\thead{dfsadf Alg\\Acc} } & {\thead{dfsfds fsd\\ J48}} \\ [0.5ex]
\midrule
Pfds fssdf & 200K to 900K & 0.504 & 0.504 & \B 0.504 & 0.504 \\
Pfds fssd & 200K to 900K & 0.524 & \B 0.546 & \B 0.546 & 0.498\\
dfsfs & 200K to 900K & 0.504 & \B0.832 & \B 0.504 & 0.504 \\
fssdf & 200K to 900K & 0.504 & \B0.754 & \B 0.754& 0.702 \\
Codsffdspe & 200K to 900K & 0.622 & 0.504 & \B 0.504 & 0.676 \\
Codsffdspe & 200K to 900K & 0.563 & \B0.674 & 0.665 & 0.686 \\
sdfdf & 200K to 900K & 0.956 & \B 0.957 & 0.956 & 0.945\\
sdfdf & 200K to 900K & 0.949 & \B0.504 & \B 0.955 & 0.952\\
dsa & 20K to 90K & 0.895 & 0.798 & \B 0.504 & 0.853\\
dsa & 20K to 90K & 0.924 & 0.834 & \B 0.932
& 0.927\\
dsa-2 & 20K to 90K & 0.899 & 0.906 & \B 0.943 & 0.942\\
SdsaA-2 & 20K to 90K & 0.892 & \B0.947 & \B 0.947 & 0.942\\
SEdsaA-3 & 20K to 90K & 0.884 & 0.832 & \B 0.897 & 0.846\\
[2ex]
\bottomrule
\end{tabular}
\caption{Csdfdfsdfs CsdfdfsdfsCsdfdfsdfsCsdfdfsdfsCsdfdfsdfs)}
\label{table:2a}
\end{table}
\begin{table}[!htb]
\centering
\sisetup{table-format=2.3, table-number-alignment=center, tight-spacing,}% table-column-width =2.5cm
\setlength{\tabcolsep}{3pt}
\small
\centering
\sisetup{detect-weight,mode=text}
\renewrobustcmd{\bfseries}{\fontseries{b}\selectfont}
\renewrobustcmd{\boldmath}{}
% abbreviation
\newrobustcmd{\B}{\bfseries}
% shorten the intercolumn spaces
\setlength{\tabcolsep}{4pt}
\begin{tabular}{l>{\centering}lSSSS}
\toprule
\thead {Dataset \\ Name} & {\thead{fsddsf \\ records} }& {\thead{Hsfd\\ Acc }} & {\thead{fsdsf\\ Acc} }
& {\thead{sfdfsd sfdf\\Acc} } & {\thead{fsd fs\\ fsd}} \\ [0.5ex]
\midrule
fsdfs fsd & 100K to 900K & 0.504 & 0.547 & \B 0.548 & 0.503 \\
fsdfs fsd & 200K to 900K & 0.524 & 0.548 & \B 0.550 & 0.498\\
sfddfs& 200K to 900K & 0.788 & \B0.833 & 0.832 & 0.824 \\
fddfs& 200K to 900K & 0.680 & 0.757 & \B 0.758& 0.702 \\
Cosdfype & 200K to 900K & 0.622 & 0.735 & \B 0.735 & 0.676 \\
Cdfspe & 200K to 900K & 0.563 & 0.677 & \B 0.678 & 0.686 \\
Airfsd & 200K to 900K & 0.956 & 0.959 & \B 0.962 & 0.945\\
dfsf & 200K to 500K & 0.949 & \B0.958 & \B 0.958 & 0.952\\
SfdsEA & 20K to 90K & 0.895 & 0.802 & \B 0.899 & 0.853\\
SEfdsA & 20K to 90K & 0.924 & 0.836 & \B 0.934 & 0.927\\
fds-2 & 20K to 90K & 0.899 & 0.935 & \B 0.943 & 0.942\\
fds-2 & 20K to 90K & 0.892 & 0.952 & \B 0.954 & 0.942\\
Sfds3 & 20K to 90K & 0.884 & 0.853 & \B 0.897 & 0.846\\
[2ex]
\bottomrule
\end{tabular}
\caption{fgdfgdsgsf (In \textbf{Bold} thedfgsdfggf)}
\label{table:2b}
\end{table}
\begin{table}[!htb]
\centering
\sisetup{table-format=2.3, table-number-alignment=center, tight-spacing,}% table-column-width =2.5cm
\setlength{\tabcolsep}{3pt}
\small
\centering
\sisetup{detect-weight,mode=text}
\renewrobustcmd{\bfseries}{\fontseries{b}\selectfont}
\renewrobustcmd{\boldmath}{}
% abbreviation
\newrobustcmd{\B}{\bfseries}
% shorten the intercolumn spaces
\setlength{\tabcolsep}{4pt}
\begin{tabular} {l c c} %{l>{\centering}lSSSS}
\toprule
\thead {Dataset \\ Name} & {\thead{dsaasd add dada (sec) \\ 1000 dsad} } & {\thead{adsdas das ddsa Time (sec) \\ 2000 fdsfds}} \\ [0.5ex]
\midrule
dfg gdfs & 22.222 & 4.4222\\
sdfgg& 22.222 & 4.0222 \\
sdfggsd & 22.222 & 22.2226\\
dsfggfd & 32.355 & 2.277 \\
dfd & 20.254 & 2.238 \\
[2ex]
\bottomrule
\end{tabular}
% \end{tabular}
\caption{fgdfgsd}
\label{table:3}
\end{table}
\end{document}
答案1
无关:
- 您的 MWE 中缺少文档类。对于我的 MWE,我使用
IEEEtran
。 - 从您的序言中,我只考虑了与您的表相关的包(其他的我从我的 MWE 中删除了,但是请再检查一下,您是否真的需要所有这些包,以及其中一些包是否加载了两次)。
- 如果文章是针对某些 IEEE 期刊的,请不要重新格式化其标题等的默认设置。
表格:
- 我建议将所有新的命令定义从表移到序言中(例如
\newrobustcmd{\B}{\bfseries}
。 - 从表中删除所有重复的设置(例如
\centering
,\tabcolsep
等等)。 - 不清楚为什么选定的第一个表的宽度比列的宽度小得多。
- 在下面的 MWE 中,我清理了表代码并尝试以统一的方式设计它们。
你的问题:
- 我不太清楚你的问题是什么。表格设计?
\documentclass{IEEEtran}
%\usepackage{amsmath} is supersede by mathtools,
\usepackage{mathtools}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
\usepackage{textcomp}
\usepackage{microtype}
\usepackage{booktabs,makecell,tabularx}
\renewcommand\theadfont{\small}
\renewcommand\theadgape{}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{siunitx}
\usepackage{etoolbox}
\newrobustcmd{\B}{\bfseries}
\begin{document}
\begin{table}[!htb]
\small
\setlength{\tabcolsep}{3pt}
\caption{Ssdfsdfsddgs dgfgdsg gsdgsfggdfsfgd sdfgfgsd}
\label{table:2}
\begin{tabularx}{\linewidth}{@{} c L S[table-format=7.0]*{2}{S[table-format=2.0]} @{}}
\toprule
\thead{ID} & \thead{UCI Dataset Name} & {\thead{Samples}} & {\thead{Attributes}} & {\thead{Classes}}\\
\midrule
DS2 & \textbf{Pfsddfs}- cdfsads dfsdffdss & 2222222 & 22 & 5 \\
DS2 & \textbf{ESSSS} - cdfsads dfsdffdss cdfsads dfsdffdss cdfsads dfsdffdss cdfsads dfsdffdss
& 45555 & 9 & 2 \\
DS3 & \textbf{AAAA} - cdfsads dfsdffdss cdfsads dfsdffdss cdfsads dfsdffdss & 22222 & 54 & 7 \\
DS4 & \textbf{ABBB} - cdfsads dfsdffdss cdfsads dfsdffdss cdfsads dfsdffdss & 539383 & 28 & 2 \\
DS5 & \textbf{SSSS} & 60000 & 3 & 3 \\
\bottomrule
\end{tabularx}
\end{table}
\begin{table}[!htb]
\sisetup{detect-weight,
mode=text,
table-format=2.3}
\setlength{\tabcolsep}{0pt}
\caption{Csdfdfsdfs Csdfdf sdfsCsdf dfsdfs CsdfdfsdfsCs dfdfsdfs)}
\label{table:2a}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} l c SSSS}
\toprule
\thead[b]{Dataset \\ Name}
& {\thead[b]{No. of\\ processed \\ records} }
& {\thead[b]{fsad fsd\\ Trfsdee\\ Acc }}
& {\thead[b]{fsdd\\ Acc} }
& {\thead[b]{dfsadf\\ Alg\\Acc} }
& {\thead[b]{dfsfds fsd\\ J48}} \\
\midrule
Pfds fssdf & 200K to 900K & 0.504 & 0.504 & \B 0.504 & 0.504 \\
Pfds fssd & 200K to 900K & 0.524 & \B 0.546 & \B 0.546 & 0.498 \\
dfsfs & 200K to 900K & 0.504 & \B 0.832 & \B 0.504 & 0.504 \\
fssdf & 200K to 900K & 0.504 & \B 0.754 & \B 0.754 & 0.702 \\
Codsffdspe & 200K to 900K & 0.622 & 0.504 & \B 0.504 & 0.676 \\
Codsffdspe & 200K to 900K & 0.563 & \B 0.674 & 0.665 & 0.686 \\
sdfdf & 200K to 900K & 0.956 & \B 0.957 & 0.956 & 0.945 \\
sdfdf & 200K to 900K & 0.949 & \B 0.504 & \B 0.955 & 0.952 \\
dsa & 20K to 90K & 0.895 & 0.798 & \B 0.504 & 0.853 \\
dsa & 20K to 90K & 0.924 & 0.834 & \B 0.932 & 0.927 \\
dsa-2 & 20K to 90K & 0.899 & 0.906 & \B 0.943 & 0.942 \\
SdsaA-2 & 20K to 90K & 0.892 & \B 0.947 & \B 0.947 & 0.942 \\
SEdsaA-3 & 20K to 90K & 0.884 & 0.832 & \B 0.897 & 0.846 \\
\bottomrule
\end{tabular*}
\end{table}
\begin{table}[!htb]
\sisetup{table-format=2.3,
detect-weight,
mode=text}% table-column-width =2.5cm
\setlength{\tabcolsep}{3pt}
\small
\caption{fgdfgdsgsf (In \textbf{Bold} thedfgsdfggf)}
\label{table:2b}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}l c SSSS}
\toprule
\thead {Dataset \\ Name}
& {\thead{fsddsf \\ records} }
& {\thead{Hsfd\\ Acc }}
& {\thead{fsdsf\\ Acc} }
& {\thead{sfdfsd sfdf\\Acc} }
& {\thead{fsd fs\\ fsd}} \\ [0.5ex]
\midrule
fsdfs fsd & 100K to 900K & 0.504 & 0.547 & \B 0.548 & 0.503 \\
fsdfs fsd & 200K to 900K & 0.524 & 0.548 & \B 0.550 & 0.498 \\
sfddfs & 200K to 900K & 0.788 & \B 0.833 & 0.832 & 0.824 \\
fddfs & 200K to 900K & 0.680 & 0.757 & \B 0.758 & 0.702 \\
Cosdfype & 200K to 900K & 0.622 & 0.735 & \B 0.735 & 0.676 \\
Cdfspe & 200K to 900K & 0.563 & 0.677 & \B 0.678 & 0.686 \\
Airfsd & 200K to 900K & 0.956 & 0.959 & \B 0.962 & 0.945 \\
dfsf & 200K to 500K & 0.949 & \B 0.958 & \B 0.958 & 0.952 \\
SfdsEA & 20K to 90K & 0.895 & 0.802 & \B 0.899 & 0.853 \\
SEfdsA & 20K to 90K & 0.924 & 0.836 & \B 0.934 & 0.927 \\
fds-2 & 20K to 90K & 0.899 & 0.935 & \B 0.943 & 0.942 \\
fds-2 & 20K to 90K & 0.892 & 0.952 & \B 0.954 & 0.942 \\
Sfds3 & 20K to 90K & 0.884 & 0.853 & \B 0.897 & 0.846 \\
\bottomrule
\end{tabular*}
\end{table}
\begin{table}[!htb]
\caption{fgdfgsd}
\label{table:3}
\sisetup{table-format=2.4}% table-column-width =2.5cm
\centering
\small
\begin{tabular} {l S S }
\toprule
\thead {Dataset \\ Name}
& {\thead{dsaasd add dada (sec) \\ 1000 dsad} }
& {\thead{adsdas das ddsa Time (sec) \\ 2000 fdsfds}} \\
\midrule
dfg gdfs & 22.222 & 4.4222 \\
sdfgg & 22.222 & 4.0222 \\
sdfggsd & 22.222 & 22.2226 \\
dsfggfd & 32.355 & 2.277 \\
dfd & 20.254 & 2.238 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}