如何显示表格以避免表格脱离页面?

如何显示表格以避免表格脱离页面?

我有这个表格,但我无法在页面上显示所有表格,我该如何缩放表格以在页面内显示?

\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}

在此处输入图片描述

答案2

如果行宽较大,前两列就会太大。因此,我稍微修改了 samcarter_is_at_topanswers.xyz 优秀答案,将表格居中,并将前两列的宽度固定:

\begin{table}[ht]
        \centering
        \begin{tblr}{
                colspec={
                    @{}
                    X[halign=c,.5in]
                    X[halign=c,.5in]
    ...

在序言中,我修复了页面的不同(更大)几何形状。输出如下:

在此处输入图片描述

相关内容