![如何显示表格以避免表格脱离页面?](https://linux22.com/image/465843/%E5%A6%82%E4%BD%95%E6%98%BE%E7%A4%BA%E8%A1%A8%E6%A0%BC%E4%BB%A5%E9%81%BF%E5%85%8D%E8%A1%A8%E6%A0%BC%E8%84%B1%E7%A6%BB%E9%A1%B5%E9%9D%A2%EF%BC%9F.png)
我有这个表格,但我无法在页面上显示所有表格,我该如何缩放表格以在页面内显示?
\begin{table}[ht]
\begin{tabular}{|cc|cccc|cccc|}
\hline
\multicolumn{1}{|c|}{\textbf{Dataset}} & \textbf{Data type} & \multicolumn{4}{c|}{\textbf{Some technique for multi dimensional (method one + method two)}} & \multicolumn{4}{c|}{\textbf{time(µ s)}} \\ \hline
\multicolumn{2}{|c|}{\textbf{}} & \multicolumn{1}{c|}{\textbf{n}} & \multicolumn{1}{c|}{\textbf{v}} & \multicolumn{1}{c|}{\textbf{ww}} & \textbf{K\_} & \multicolumn{1}{c|}{\textbf{S}} & \multicolumn{1}{c|}{\textbf{M}} & \multicolumn{1}{c|}{\textbf{WQ}} & \textbf{QR} \\ \hline
\multicolumn{1}{|c|}{A1} & int & \multicolumn{1}{c|}{4} & \multicolumn{1}{c|}{96} & \multicolumn{1}{c|}{1.3} & 1.64 & \multicolumn{1}{c|}{67} & \multicolumn{1}{c|}{117} & \multicolumn{1}{c|}{5623} & 34 \\ \hline
\multicolumn{1}{|c|}{A2} & int & \multicolumn{1}{c|}{81} & \multicolumn{1}{c|}{1.57} & \multicolumn{1}{c|}{2.77} & 3.34 & \multicolumn{1}{c|}{78} & \multicolumn{1}{c|}{875} & \multicolumn{1}{c|}{734} & 2923 \\ \hline
\multicolumn{1}{|c|}{A3} & int & \multicolumn{1}{c|}{33} & \multicolumn{1}{c|}{734} & \multicolumn{1}{c|}{4.59} & 6.68 & \multicolumn{1}{c|}{34} & \multicolumn{1}{c|}{653} & \multicolumn{1}{c|}{8453} & 286 \\ \hline
\multicolumn{1}{|c|}{B1} & int & \multicolumn{1}{c|}{87} & \multicolumn{1}{c|}{7.44} & \multicolumn{1}{c|}{1.75} & 2.53 & \multicolumn{1}{c|}{54} & \multicolumn{1}{c|}{743} & \multicolumn{1}{c|}{8954} & 763 \\ \hline
\multicolumn{1}{|c|}{B2} & int & \multicolumn{1}{c|}{9} & \multicolumn{1}{c|}{678} & \multicolumn{1}{c|}{3.51} & 5.07 & \multicolumn{1}{c|}{66} & \multicolumn{1}{c|}{789} & \multicolumn{1}{c|}{7635} & 834 \\ \hline
\multicolumn{1}{|c|}{B3} & int & \multicolumn{1}{c|}{87} & \multicolumn{1}{c|}{9.61} & \multicolumn{1}{c|}{7.03} & 10.14 & \multicolumn{1}{c|}{379} & \multicolumn{1}{c|}{765} & \multicolumn{1}{c|}{8734} & 562 \\ \hline
\multicolumn{1}{|c|}{C1} & int & \multicolumn{1}{c|}{7} & \multicolumn{1}{c|}{19.89} & \multicolumn{1}{c|}{7.59} & 8.01 & \multicolumn{1}{c|}{843} & \multicolumn{1}{c|}{9268} & \multicolumn{1}{c|}{9834} & 982 \\ \hline
\multicolumn{1}{|c|}{C2} & int & \multicolumn{1}{c|}{44.2} & \multicolumn{1}{c|}{26.52} & \multicolumn{1}{c|}{15.18} & 7 & \multicolumn{1}{c|}{652} & \multicolumn{1}{c|}{9745} & \multicolumn{1}{c|}{8734} & 457 \\ \hline
\multicolumn{1}{|c|}{C4} & int & \multicolumn{1}{c|}{27.31} & \multicolumn{1}{c|}{18.61} & \multicolumn{1}{c|}{6} & 16.48 & \multicolumn{1}{c|}{87} & \multicolumn{1}{c|}{4319} & \multicolumn{1}{c|}{11345} & 693 \\ \hline
\multicolumn{1}{|c|}{C4} & int & \multicolumn{1}{c|}{47.1} & \multicolumn{1}{c|}{75} & \multicolumn{1}{c|}{9} & 21.98 & \multicolumn{1}{c|}{5} & \multicolumn{1}{c|}{7642} & \multicolumn{1}{c|}{8723} & 1137 \\ \hline
\end{tabular}
\end{table}
@samcarter_is_at_topanswers.xyz 答案的输出
日志档案:
答案1
远离这些糟糕的在线表格生成器。由于存在各种干扰\multicolumn
,正确格式化表格比想象的要困难得多。
相反,我建议
使用该
tabularray
包可以轻松合并标题单元格使用该
siunitx
包正确对齐表格中的数字请查看
booktabs
包的文档,了解如何格式化专业表格。提示:垂直线不是此类布局的一部分
\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\UseTblrLibrary{siunitx}
\begin{document}
\begin{table}[ht]
\begin{tblr}{
colspec={
@{}
X[halign=c]
X[halign=c]
S[table-format=2.2]
S[table-format=3.2]
S[table-format=2.2]
S[table-format=2.2]
S[table-format=3.0]
S[table-format=4.0]
S[table-format=5.0]
S[table-format=4.0]
@{}
},
cells={valign=m},
row{1-2}={guard},
hspan=minimal
}
\toprule
\SetCell[r=2]{} Data Set & \SetCell[r=2]{} Data type & \SetCell[c=4]{} Some technique for multi dimensional (method one + method two) &&&& \SetCell[c=4]{} time(µs) &&& \\
\cmidrule[r]{3-6}\cmidrule[l]{7-11}
& & n & v & ww & K\_ & S & M & WQ & QR \\
\midrule
A1 & int & 4 & 96 & 1.3 & 1.64 & 67 & 117 & 5623 & 34 \\
A2 & int & 81 & 1.57 & 2.77 & 3.34 & 78 & 875 & 734 & 2923 \\
A3 & int & 33 & 734 & 4.59 & 6.68 & 34 & 653 & 8453 & 286 \\
B1 & int & 87 & 7.44 & 1.75 & 2.53 & 54 & 743 & 8954 & 763 \\
B2 & int & 9 & 678 & 3.51 & 5.07 & 66 & 789 & 7635 & 834 \\
B3 & int & 87 & 9.61 & 7.03 & 10.14 & 379 & 765 & 8734 & 562 \\
C1 & int & 7 & 19.89 & 7.59 & 8.01 & 843 & 9268 & 9834 & 982 \\
C2 & int & 44.2 & 26.52 & 15.18 & 7 & 652 & 9745 & 8734 & 457 \\
C4 & int & 27.31 & 18.61 & 6 & 16.48 & 87 & 4319 & 11345 & 693 \\
C4 & int & 47.1 & 75 & 9 & 21.98 & 5 & 7642 & 8723 & 1137 \\
\bottomrule
\end{tblr}
\end{table}
\end{document}