即使在位置标识符之后也无法将节标题和表格保留在同一页面中

即使在位置标识符之后也无法将节标题和表格保留在同一页面中

adjustbox无论我用或 I 将表格缩小到多小,即使我使用 ,表格总是会显示在下一页的下一节中\begin{table}[!ht]。如何才能将表格和部分保留在同一页中?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lscape}
\usepackage{adjustbox}
\usepackage[document,margin=2.5cm, top = 0.5cm]{geometry} % set page parameters suitably

\title{CSE Dataset Information}
\author{ }
\date{}

\begin{document}

\maketitle

\section*{Dataset Information}
% Please add the following required packages to your document preamble:
% \usepackage{lscape}
\begin{landscape}
\begin{table}[!hbt]
\begin{adjustbox}{width=1\textwidth}
\begin{tabular}{llllllll}
N      & TaskType                  & N\_Class & K  & P  & max\_cardinality & mean\_cardinality & sum\_cardinality \\ \hline
48790  & Binary Classification     & 2        & 9  & 6  & 41               & 11.22             & 101              \\
32769  & Binary Classification     & 2        & 10 & 0  & 7518             & 1562.8            & 15628            \\
39926  & Binary Classification     & 2        & 5  & 4  & 22381            & 13495.6           & 67478            \\
10108  & Binary Classification     & 2        & 71 & 0  & 129              & 8.3               & 589              \\
72983  & Binary Classification     & 2        & 13 & 20 & 1063             & 167.46            & 2177             \\
8124   & Binary Classification     & 2        & 22 & 0  & 12               & 5.36              & 118              \\
891    & Binary Classification     & 2        & 6  & 5  & 838              & 278.83            & 1673             \\
73354  & Binary Classification     & 2        & 6  & 0  & 4362             & 1432.33           & 8594             \\
1728   & Multiclass Classification & 4        & 7  & 0  & 4                & 3.57              & 25               \\
12960  & Multiclass Classification & 5        & 9  & 0  & 5                & 3.56              & 32               \\
736    & Multiclass Classification & 5        & 6  & 14 & 27               & 13.67             & 82               \\
4331   & Multiclass Classification & 4        & 3  & 5  & 14               & 8.33              & 25               \\
20640  & Regression                & 0        & 1  & 9  & 5                & 5                 & 5                \\
163065 & Regression                & 0        & 5  & 2  & 3201             & 1127              & 5635             \\
2930   & Regression                & 0        & 46 & 35 & 28               & 6.91              & 318              \\
18249  & Regression                & 0        & 2  & 12 & 54               & 28                & 56              
\end{tabular}
\end{adjustbox}
\caption{Description of Datasets}
\label{tab:my-table}
\end{table}
\end{landscape}


\end{document}


答案1

只要您对“基数”信息进行分组,您的表格就可以很好地适应边缘。

我选择将数字右对齐(或在一列中小数点对齐)打印,因为这是预期的数字。

\documentclass{article}
\usepackage[
  a4paper,
  margin=2.5cm,
  top=0.5cm
]{geometry} % set page parameters suitably

\usepackage{booktabs,siunitx}

\title{CSE Dataset Information}
\author{ }
\date{}

\begin{document}

\maketitle

\section*{Dataset Information}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  r
  l
  S[table-format=1.0]
  S[table-format=2.0]
  S[table-format=2.0]
  S[table-format=5.0]
  S[table-format=5.2]
  S[table-format=5.0]
  @{}
}
\toprule
\multicolumn{1}{@{}c}{N} &
TaskType &
{N\_Class} &
{K} &
{P} &
\multicolumn{3}{c}{cardinality} \\
\cmidrule{6-8}
&&&&& max & {mean} & sum \\
\midrule
 48790 & Binary Classification     & 2 &  9 &  6 &    41 &    11.22 &   101 \\
 32769 & Binary Classification     & 2 & 10 &  0 &  7518 &  1562.8  & 15628 \\
 39926 & Binary Classification     & 2 &  5 &  4 & 22381 & 13495.6  & 67478 \\
 10108 & Binary Classification     & 2 & 71 &  0 &   129 &     8.3  &   589 \\
 72983 & Binary Classification     & 2 & 13 & 20 &  1063 &   167.46 &  2177 \\
  8124 & Binary Classification     & 2 & 22 &  0 &    12 &     5.36 &   118 \\
   891 & Binary Classification     & 2 &  6 &  5 &   838 &   278.83 &  1673 \\
 73354 & Binary Classification     & 2 &  6 &  0 &  4362 &  1432.33 &  8594 \\
  1728 & Multiclass Classification & 4 &  7 &  0 &     4 &     3.57 &    25 \\
 12960 & Multiclass Classification & 5 &  9 &  0 &     5 &     3.56 &    32 \\
   736 & Multiclass Classification & 5 &  6 & 14 &    27 &    13.67 &    82 \\
  4331 & Multiclass Classification & 4 &  3 &  5 &    14 &     8.33 &    25 \\
 20640 & Regression                & 0 &  1 &  9 &     5 &     5    &     5 \\
163065 & Regression                & 0 &  5 &  2 &  3201 &  1127    &  5635 \\
  2930 & Regression                & 0 & 46 & 35 &    28 &     6.91 &   318 \\
 18249 & Regression                & 0 &  2 & 12 &    54 &    28    &    56 \\
\bottomrule
\end{tabular*}

\end{document}

在此处输入图片描述

答案2

我看不出有什么令人信服的理由将此表格以横向显示。如果您在标题中提供更多结构并删除一些冗余部分,则表格将很容易适应普通方向,即“纵向”方向。当然,没有必要使用拐杖adjustbox

为了让表格更易读,我会将数据列中的数字与其(显式或隐式)小数点对齐。每隔四行添加一点空格也会增加可读性。

在此处输入图片描述

\documentclass{article}
%%\usepackage[utf8]{inputenc} % that's the default nowadays
\usepackage[T1]{fontenc}
\usepackage[margin=2.5cm, top=0.5cm]{geometry} % set as needed
\usepackage{booktabs} % for well-spaced horizontal rules
\usepackage[group-digits=false]{siunitx} % for 'S' column type
\newcolumntype{T}[1]{S[table-format=#1]}

\begin{document}

\section*{Dataset Information}

\begin{table}[!hbt]

\centering
\begin{tabular}{@{} T{6} l c T{2} T{2} T{5} T{5.2} T{5} @{}}
\toprule
{$N$} & Task Type & $N$\_Class & {$K$} & {$P$} & \multicolumn{3}{c@{}}{Cardinality} \\
\cmidrule(l){6-8}
&&&&& {max} & {mean} & {sum} \\ 
\midrule
48790  & Binary Classification     & 2        & 9  & 6  & 41               & 11.22             & 101              \\
32769  & Binary Classification     & 2        & 10 & 0  & 7518             & 1562.8            & 15628            \\
39926  & Binary Classification     & 2        & 5  & 4  & 22381            & 13495.6           & 67478            \\
10108  & Binary Classification     & 2        & 71 & 0  & 129              & 8.3               & 589              \\ 
\addlinespace
72983  & Binary Classification     & 2        & 13 & 20 & 1063             & 167.46            & 2177             \\
8124   & Binary Classification     & 2        & 22 & 0  & 12               & 5.36              & 118              \\
891    & Binary Classification     & 2        & 6  & 5  & 838              & 278.83            & 1673             \\
73354  & Binary Classification     & 2        & 6  & 0  & 4362             & 1432.33           & 8594             \\ 
\addlinespace
1728   & Multiclass Classification & 4        & 7  & 0  & 4                & 3.57              & 25               \\
12960  & Multiclass Classification & 5        & 9  & 0  & 5                & 3.56              & 32               \\
736    & Multiclass Classification & 5        & 6  & 14 & 27               & 13.67             & 82               \\
4331   & Multiclass Classification & 4        & 3  & 5  & 14               & 8.33              & 25               \\ 
\addlinespace
20640  & Regression                & 0        & 1  & 9  & 5                & 5                 & 5                \\
163065 & Regression                & 0        & 5  & 2  & 3201             & 1127              & 5635             \\
2930   & Regression                & 0        & 46 & 35 & 28               & 6.91              & 318              \\
18249  & Regression                & 0        & 2  & 12 & 54               & 28                & 56               \\
\bottomrule
\end{tabular}
\caption{Description of Datasets}
\label{tab:my-table}
\end{table}

\end{document}

答案3

\rotatebox{90}{<definition of tabular>}如果我想垂直保留该表,我会使用它。

但是宽度可以减小。例如,我删除了多余的单词基数并将其移至表格底部的注释中。数字也可以通过 进行格式化siunitx。将所有内容放在一起时,表格在页面内水平放置。参见示例。

梅威瑟:

\documentclass{article}
\usepackage[margin=2.5cm,top=0.5cm]{geometry} % set page parameters suitably
\usepackage[skip=0.5\baselineskip]{caption} 
\usepackage{booktabs}                         % Predefined rules
\usepackage{siunitx}                          % Extended number alignments

\newcommand\st[1]{#1\rlap{\textsuperscript{*}}}   % For annotation
\newcommand\sst[1]{#1\rlap{\textsuperscript{**}}}   % For annotation


\title{CSE Dataset Information}
\author{ }
\date{}


\begin{document}
\maketitle

\section*{Dataset Information}
% Please add the following required packages to your document preamble:
\begin{table}[!htbp]
    \setlength{\tabcolsep}{0pt}
    \renewcommand{\arraystretch}{1.1}
    \centering
    \caption{Description of Datasets}\label{tab:my-table}
    \begin{tabular*}{0.75\textwidth}{
            @{\hspace{6pt}} @{\extracolsep{\fill}}
            S[table-format=6, table-number-alignment=right]
            l
            *3{c}
            S[table-format=5]
            S[table-format=5.2]
            S[table-format=5]
            @{\hspace{6pt}}
        }
        \toprule
        {N} &
        {\st{Task Type}} &
        {N\_Class} &
        {K} &
        {P} &
        {\sst{Max}} &
        {\sst{Mean}} &
        {\sst{Sum}} \\
        \midrule
        48790  & Binary      & 2        & 9  & 6  & 41               & 11.22             & 101              \\
        32769  & Binary       & 2        & 10 & 0  & 7518             & 1562.8            & 15628            \\
        39926  & Binary       & 2        & 5  & 4  & 22381            & 13495.6           & 67478            \\
        10108  & Binary       & 2        & 71 & 0  & 129              & 8.3               & 589              \\
        72983  & Binary       & 2        & 13 & 20 & 1063             & 167.46            & 2177             \\
        8124   & Binary       & 2        & 22 & 0  & 12               & 5.36              & 118              \\
        891    & Binary       & 2        & 6  & 5  & 838              & 278.83            & 1673             \\
        73354  & Binary       & 2        & 6  & 0  & 4362             & 1432.33           & 8594             \\
        1728   & Multiclass   & 4        & 7  & 0  & 4                & 3.57              & 25               \\
        12960  & Multiclass   & 5        & 9  & 0  & 5                & 3.56              & 32               \\
        736    & Multiclass   & 5        & 6  & 14 & 27               & 13.67             & 82               \\
        4331   & Multiclass   & 4        & 3  & 5  & 14               & 8.33              & 25               \\
        20640  & Regression   & 0        & 1  & 9  & 5                & 5                 & 5                \\
        163065 & Regression   & 0        & 5  & 2  & 3201             & 1127              & 5635             \\
        2930   & Regression   & 0        & 46 & 35 & 28               & 6.91              & 318              \\
        18249  & Regression   & 0        & 2  & 12 & 54               & 28                & 56 \\
        \bottomrule
        \multicolumn{8}{l}{%
            \rule{0pt}{2.5ex}%
            \hspace{6pt}\textsuperscript{*} Classification,
            \hspace{6pt}\textsuperscript{**} Cardinarity}
    \end{tabular*}
\end{table}

\end{document}

在此处输入图片描述

相关内容