我正在尝试写一张表格11 列包含一些数值数据。但有些单元格的文本与下一个单元格重叠。我用它p{\dimexpr.09\textwidth-2\tabcolsep\relax}
来控制每列的宽度和\small
字体大小。提前致谢。MWE 是
\documentclass[3p, final]{elsarticle}
\usepackage{caption}
\captionsetup[table]{skip=0pt,singlelinecheck=off}
\usepackage{booktabs}
\journal{Applied Soft Computing}
\begin{document}
\begin{table}[!htb]
\label{tab3}
\caption{table 3}
\small
\begin{tabular}{@{}p{\dimexpr.09\textwidth-2\tabcolsep\relax}p{\dimexpr.09\textwidth-2\tabcolsep\relax}p{\dimexpr.09\textwidth-2\tabcolsep\relax}p{\dimexpr.09\textwidth-2\tabcolsep\relax}p{\dimexpr.09\textwidth-2\tabcolsep\relax}p{\dimexpr.09\textwidth-2\tabcolsep\relax}p{\dimexpr.09\textwidth-2\tabcolsep\relax}p{\dimexpr.09\textwidth-2\tabcolsep\relax}p{\dimexpr.09\textwidth-2\tabcolsep\relax}p{\dimexpr.09\textwidth-2\tabcolsep\relax}p{\dimexpr.09\textwidth-2\tabcolsep\relax}@{}}
\toprule
Server & \textbf{Dionaea} & \textbf{Cowrie} & \textbf{Heralding} & \textbf{Honeytrap} & \textbf{Rdpy} & \textbf{Adbhoney} & \textbf{Mailoney} & \textbf{Tanner} & \textbf{Conpot} & \textbf{Total Alert} \\ \midrule
\textbf{Africa} & 65464665 & 846132 & 86124 & 89645446 & 985131 & 95621455 & 956465 & 8465 & 65465 & 865135665645 \\
\textbf{Australia} & 86465 & 865465 & 8665 & 656165 & 864565 & 989230 & 9846465 & 6548465 & 9846516 & 8746563 \\ \bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
您的表格的正常字体大小比文本宽度宽,因此您需要将其中的字体大小减小到\footnotesize
。此外,我建议使用包S
中定义的列siunitx
作为带有数字的列:
\documentclass[3p, final]{elsarticle}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{caption}
\captionsetup[table]{skip=0pt,singlelinecheck=off}
\usepackage{booktabs}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\usepackage{siunitx}
\journal{Applied Soft Computing}
\begin{document}
\begin{table}[!htb]
\caption{table 3}
\label{tab3}
\footnotesize
\setlength\tabcolsep{0pt}
\sisetup{tight-spacing,
group-four-digits}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} l
S[table-format=8.0]
S[table-format=6.0]
S[table-format=5.0]
S[table-format=8.0]
S[table-format=6.0]
S[table-format=8.0]
S[table-format=7.0]
S[table-format=7.0]
S[table-format=7.0]
S[table-format=12.0]
}
\toprule
Server & \mc{Dionaea} & \mc{Cowrie} & \mc{Heralding} & \mc{Honeytrap}
& \mc{Rdpy} & \mc{Adbhoney} & \mc{Mailoney} & \mc{Tanner}
& \mc{Conpot} & \mc{Total Alert} \\
\midrule
Africa
& 65464665 & 846132 & 86124 & 89645446
& 985131 & 95621455 & 956465 & 8465
& 65465 & 865135665645 \\
Australia
& 86465 & 865465 & 8665 & 656165
& 864565 & 989230 & 9846465 & 6548465
& 9846516 & 8746563 \\ \bottomrule
\end{tabular*}
\end{table}
\end{document}
(红线表示文字边框)