这是我的代码,有些变量名很长:
\usepackage{tabularx}
\newcolumntype{b}{>{\hsize=0.9\hsize}X}
\newcolumntype{s}{>{\hsize=0.8\hsize}X}
\begin{table}[htbp]
\begin{tabularx}{\linewidth}{|b|b|s|s|s|s|s|s|s|}
\hline
aaaa aaaaa aaaaa & djfh & aaaaaaa aaaaaaaa aaaaaa & aaaaaaaaaa aaaaaaaaa & \multicolumn{5}{c|}{total}\\
\hline
- & - & - & - & kih & 1111 & 111 & 111 & 111 \\
\hline
aaaaaaa\_bbb & aaaaaaaaaaaaaa & 0 & 00 & - & - & - & - & - \\
\hline
aaaaaaaaaa & aaaaaaaaaa & 0 & 1111 & 0.000000 & 0.000000 & 0.000000 & 0.000000& 0.000000 \\
\hline
aaaaaaaa aa & aaaaaaaaaa & 0 & 1111 & 0.000000 & 0.000000 & 0.000000 & 0.000000& 0.000000 \\
\hline
\end{tabularx}
\end{table}
答案1
如果没有换行符,我就不会使用,tabularx
而且您没有提供示例文档,所以我们不知道页面大小,但在标准article
文档中,这需要\tiny
适合,这只是可读的。
\documentclass{article}
\newcommand\hd[2]{\multicolumn{1}{#1}{\begin{tabular}[t]{@{}c@{}}#2\end{tabular}}}
\usepackage{tabularx}
\begin{document}
\newcolumntype{b}{>{\hsize=0.9\hsize}X}
\newcolumntype{s}{>{\hsize=0.8\hsize}X}
\begin{table}[htbp]
\begin{tabularx}{\linewidth}{|b|b|s|s|s|s|s|s|s|}
\hline
aaaa aaaaa aaaaa & djfh & aaaaaaa aaaaaaaa aaaaaa & aaaaaaaaaa aaaaaaaaa & \multicolumn{5}{c|}{total}\\
\hline
- & - & - & - & kih & 1111 & 111 & 111 & 111 \\
\hline
aaaaaaa\_bbb & aaaaaaaaaaaaaa & 0 & 00 & - & - & - & - & - \\
\hline
aaaaaaaaaa & aaaaaaaaaa & 0 & 1111 & 0.000000 & 0.000000 & 0.000000 & 0.000000& 0.000000 \\
\hline
aaaaaaaa aa & aaaaaaaaaa & 0 & 1111 & 0.000000 & 0.000000 & 0.000000 & 0.000000& 0.000000 \\
\hline
\end{tabularx}
\end{table}
\noindent X\dotfill text text\dotfill X
\begin{table}[htbp]
\tiny
\centering
\setlength\tabcolsep{3.5pt}
\begin{tabular}{@{}|*{9}{l|}@{}}
\hline
\hd{|c|}{aaaa\\ aaaaa\\ aaaaa} & djfh & \hd{c|}{aaaaaaa\\ aaaaaaaa\\ aaaaaa} & \hd{c|}{aaaaaaaaaa\\ aaaaaaaaa} & \multicolumn{5}{c|}{total}\\
\hline
- & - & - & - & kih & 1111 & 111 & 111 & 111 \\
\hline
aaaaaaa\_bbb & aaaaaaaaaaaaaa & 0 & 00 & - & - & - & - & - \\
\hline
aaaaaaaaaa & aaaaaaaaaa & 0 & 1111 & 0.000000 & 0.000000 & 0.000000 & 0.000000& 0.000000 \\
\hline
aaaaaaaa aa & aaaaaaaaaa & 0 & 1111 & 0.000000 & 0.000000 & 0.000000 & 0.000000& 0.000000 \\
\hline
\end{tabular}
\end{table}
\end{document}
实际上,我会删除所有水平和垂直线,因为这并不能提高可读性。