![需要帮助将表格保持在文本和页脚之间而无需转到下一页](https://linux22.com/image/431183/%E9%9C%80%E8%A6%81%E5%B8%AE%E5%8A%A9%E5%B0%86%E8%A1%A8%E6%A0%BC%E4%BF%9D%E6%8C%81%E5%9C%A8%E6%96%87%E6%9C%AC%E5%92%8C%E9%A1%B5%E8%84%9A%E4%B9%8B%E9%97%B4%E8%80%8C%E6%97%A0%E9%9C%80%E8%BD%AC%E5%88%B0%E4%B8%8B%E4%B8%80%E9%A1%B5.png)
我有两个表格,我设法将它们放在另一个表格的顶部。我希望将两个表格放在一组文本下,然后将剩余的文本放在下一页。例如:
Lorem ipsum dolor sit amet,consectetur adipiscing elit。 Praesent quis ornare mi。我死而复活,车子却倒下,我死而复活。 Aliquam rhoncus,ante id convallis porta,ligula lectus rutrum justo,sed vehicula nunc sapien eu augue。南海的口水和无水的海水,以及射手座的渴望。 Phasellus elementum,痛苦和召唤时间,没有直径的物体,没有智慧和毛茸茸的躯体。 Fusce venenatis odio lorem,blandit lobortis arcu viverra sed。
表格1
表 2
页脚
Duis vitae justo eros。佩伦特斯克居民在悲伤中度过余生,并遭受欺骗和诽谤。 Aenean eu dignissim magna。在法雷特拉乌尔纳 (pharetra urna) 完成。 Sed neque massa,eleifend ut ornare in,ullamcorper quis ex。
下图显示了该间隙:
我尝试了所有方法,但它还是停留在下一页,在文本末尾和页脚之间留下了很大的空隙。两个表格都可以完美地放进去。当我尝试使用 \vspace{-5mm} 时,它会将表格向上移动到文本上。然后我尝试删除 \begin{table}[htbp] 和 \caption{text},改用 \captionof{table}{text},但第二个表格仍然停留在另一页,但它的标题位于我希望它所在的页面上方。
下面是我的代码:
\documentclass{article}
\usepackage[skip=0.5\baselineskip,labelfont=bf,format=plain,labelsep=newline,singlelinecheck=false]{caption}
\usepackage[utf8]{inputenc}
\usepackage[hyphens]{url}
\usepackage[authoryear,round]{natbib}
\usepackage{fullpage}
\usepackage{graphicx}
%\usepackage[left=0.5in, right=0.5in, top=.70in]{geometry}
\setlength{\footskip}{25mm}
\begin{document}
\hspace{-5mm}\textbf{\large{3. Methods}}
\vspace{2mm}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas at auctor tellus. Cras auctor viverra euismod. Cras faucibus eu quam vitae varius. Ut fringilla bibendum consectetur. Duis libero tortor, imperdiet sed dignissim in, commodo ac odio. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent pellentesque diam ut mauris ultrices, quis efficitur metus maximus. Aenean velit ligula, efficitur ut pulvinar a, sodales vel metus. Morbi pellentesque scelerisque erat quis porta.Ut scelerisque imperdiet odio ut tincidunt. Vestibulum elementum scelerisque tincidunt. Sed vel nunc rhoncus ligula mollis tempor. Maecenas sit amet mi risus. Nulla sed ultricies sapien, et aliquam tellus. Aliquam sed mauris at felis tempus varius vel eu erat. Quisque id lectus aliquet, fringilla nibh sed, mollis enim. Mauris turpis sem, ullamcorper ac mattis ac, egestas a erat. Maecenas auctor mi non venenatis luctus. Phasellus gravida elementum est vitae dictum. Curabitur sollicitudin sodales est, non semper magna facilisis sit amet. Nam posuere eget ligula ut hendrerit. Nulla non porttitor augue. Curabitur euismod augue tincidunt, faucibus justo sed, fermentum eros.
\pagebreak
\begin{table}[htbp]
\centering
\caption{The training and test data frequencies for each city for Case 1.}
\label{tab:case1}
\resizebox{\textwidth}{!}{%
\setlength{\tabcolsep}{7pt}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{lcccc}
\hline
\multicolumn{1}{c}{Training Set} & Test Set & Dates for Training Set & Dates for Test Set & Dates for Test Set \\
\hline
Seattle & 750 & 367 & January 1, 2018 - January 20, 2020 & January 21, 2020 - January 21, 2021 \\ [0.5ex]
San Francisco & 750 & 370 & January 1, 2018 - January 20, 2020 & January 21, 2020 - January 24, 2021 \\ [0.5ex]
Los Angeles & 750 & 364 & January 1, 2018 - January 20, 2020 & January 21, 2020 - January 18, 2021 \\[0.5ex]
Philadelphia & 750 & 370 & January 1, 2018 - January 20, 2020 & January 21, 2020 - January 24, 2021 \\ \hline
\end{tabular}}
\bigskip
\caption{The training and test data frequencies for each city for Case 2.}
\label{tab:case2}
\resizebox{\textwidth}{!}{%
\setlength{\tabcolsep}{7pt}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{lcccc}
\hline
\multicolumn{1}{c}{Training Set} & Test Set & Dates for Training Set & Dates for Test Set & Dates for Test Set \\ \hline
Seattle & 876 & 241 & January 1, 2018 - May 25, 2020 & May 26, 2020 - January 21, 2021 \\
San Francisco & 876 & 244 & January 1, 2018 - May 25, 2020 & May 26, 2020 - January 24, 2021 \\
Los Angeles & 876 & 238 & January 1, 2018 - May 25, 2020 & May 26, 2020 - January 18, 2021 \\
Philadelphia & 876 & 244 & January 1, 2018 - May 25, 2020 & May 26, 2020 - January 24, 2021 \\ \hline
\end{tabular}}
\end{table}
\vspace{5mm}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas at auctor tellus. Cras auctor viverra euismod. Cras faucibus eu quam vitae varius. Ut fringilla bibendum consectetur. Duis libero tortor, imperdiet sed dignissim in, commodo ac odio. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent pellentesque diam ut mauris ultrices, quis efficitur metus maximus. Aenean velit ligula, efficitur ut pulvinar a, sodales vel metus. Morbi pellentesque scelerisque erat quis porta.Ut scelerisque imperdiet odio ut tincidunt. Vestibulum elementum scelerisque tincidunt. Sed vel nunc rhoncus ligula mollis tempor. Maecenas sit amet mi risus. Nulla sed ultricies sapien, et aliquam tellus. Aliquam sed mauris at felis tempus varius vel eu erat. Quisque id lectus aliquet, fringilla nibh sed, mollis enim. Mauris turpis sem, ullamcorper ac mattis ac, egestas a erat. Maecenas auctor mi non venenatis luctus. Phasellus gravida elementum est vitae dictum. Curabitur sollicitudin sodales est, non semper magna facilisis sit amet. Nam posuere eget ligula ut hendrerit. Nulla non porttitor augue. Curabitur euismod augue tincidunt, faucibus justo sed, fermentum eros.\\
\hspace{-5mm}\textbf{\large{4. Results}}
\vspace{2mm}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas at auctor tellus. Cras auctor viverra euismod. Cras faucibus eu quam vitae varius. Ut fringilla bibendum consectetur. Duis libero tortor, imperdiet sed dignissim in, commodo ac odio. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent pellentesque diam ut mauris ultrices, quis efficitur metus maximus. Aenean velit ligula, efficitur ut pulvinar a, sodales vel metus. Morbi pellentesque scelerisque erat quis porta.Ut scelerisque imperdiet odio ut tincidunt. Vestibulum elementum scelerisque tincidunt. Sed vel nunc rhoncus ligula mollis tempor. Maecenas sit amet mi risus. Nulla sed ultricies sapien, et aliquam tellus. Aliquam sed mauris at felis tempus varius vel eu erat. Quisque id lectus aliquet, fringilla nibh sed, mollis enim. Mauris turpis sem, ullamcorper ac mattis ac, egestas a erat. Maecenas auctor mi non venenatis luctus. Phasellus gravida elementum est vitae dictum.\\
\end{document}
我将非常感激任何帮助,如果我能提供更多信息,请告诉我。
答案1
如果它适合并且仍然满足您的需要,您可以将两个表合并。
\documentclass{article}
\usepackage[
skip=0.5\baselineskip,
labelfont=bf,
format=plain,
labelsep=newline,
singlelinecheck=false
]{caption}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage{graphicx,multirow,booktabs}
\setlength{\footskip}{25mm}
\begin{document}
\begin{table}[htbp]
\centering
\caption{The training and test data frequencies for each city.}
\label{tab:cases}
\resizebox{\textwidth}{!}{%
\setlength{\tabcolsep}{7pt}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{llcccc}
\toprule
& Training Set & Test Set & Dates for Training Set & Dates for Test Set & Dates for Test Set \\
\midrule
\multirow{4}{*}{\rotatebox[origin=c]{90}{Case1}} & Seattle & 750 & 367 & Jan 1, 2018 - Jan 20, 2020 & Jan 21, 2020 - Jan 21, 2021 \\
& San Francisco & 750 & 370 & Jan 1, 2018 - Jan 20, 2020 & Jan 21, 2020 - Jan 24, 2021 \\
& Los Angeles & 750 & 364 & Jan 1, 2018 - Jan 20, 2020 & Jan 21, 2020 - Jan 18, 2021 \\
& Philadelphia & 750 & 370 & Jan 1, 2018 - Jan 20, 2020 & Jan 21, 2020 - Jan 24, 2021 \\ \cmidrule{2-6}
\multirow{4}{*}{\rotatebox[origin=c]{90}{Case2}} & Seattle & 876 & 241 & Jan 1, 2018 - May 25, 2020 & May 26, 2020 - Jan 21, 2021 \\
& San Francisco & 876 & 244 & Jan 1, 2018 - May 25, 2020 & May 26, 2020 - Jan 24, 2021 \\
& Los Angeles & 876 & 238 & Jan 1, 2018 - May 25, 2020 & May 26, 2020 - Jan 18, 2021 \\
& Philadelphia & 876 & 244 & Jan 1, 2018 - May 25, 2020 & May 26, 2020 - Jan 24, 2021 \\ \bottomrule
\end{tabular}
}
\end{table}
\end{document}
请告诉我节省的空间是否足够。
答案2
这可能无法回答您的问题,但您可能需要考虑这一点。\resizebox
可能会解决表格与页面宽度不匹配的问题,但同时会更改表格的字体大小。为了避免这种情况,您可以使用tabularx
我的表格 1 中所示的方法。
我还添加了\section
以使其保持井然有序。
\documentclass{article}
\usepackage[skip=0.5\baselineskip,labelfont=bf,format=plain,labelsep=newline,singlelinecheck=false]{caption}
\usepackage[utf8]{inputenc}
\usepackage[hyphens]{url}
\usepackage[authoryear,round]{natbib}
\usepackage{fullpage}
\usepackage{graphicx}
%\usepackage[left=0.5in, right=0.5in, top=.70in]{geometry}
\setlength{\footskip}{25mm}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}%middle aligns X column type
\usepackage{lipsum}
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage} %pagebreak after new section
\begin{document}
\section{Methods}
\lipsum[1-2]
\begin{table}[htbp]
\centering
\caption{The training and test data frequencies for each city for Case 1.}
\label{tab:case1}
%\resizebox{\textwidth}{!}{%
%\setlength{\tabcolsep}{7pt}
\renewcommand{\arraystretch}{1.5}
\begin{tabularx}{\textwidth}{@{}l *5{>{\centering\arraybackslash}X}@{}}
\hline
\multicolumn{1}{c}{Training Set} & Test Set & Dates for Training Set & Dates for Test Set & Dates for Test Set \\
\hline
Seattle & 750 & 367 & January 1, 2018 - January 20, 2020 & January 21, 2020 - January 21, 2021 \\ [0.5ex]
San Francisco & 750 & 370 & January 1, 2018 - January 20, 2020 & January 21, 2020 - January 24, 2021 \\ [0.5ex]
Los Angeles & 750 & 364 & January 1, 2018 - January 20, 2020 & January 21, 2020 - January 18, 2021 \\[0.5ex]
Philadelphia & 750 & 370 & January 1, 2018 - January 20, 2020 & January 21, 2020 - January 24, 2021 \\ \hline
\end{tabularx}
\bigskip
\caption{The training and test data frequencies for each city for Case 2.}
\label{tab:case2}
\resizebox{\textwidth}{!}{%
\setlength{\tabcolsep}{7pt}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{lcccc}
\hline
\multicolumn{1}{c}{Training Set} & Test Set & Dates for Training Set & Dates for Test Set & Dates for Test Set \\ \hline
Seattle & 876 & 241 & January 1, 2018 - May 25, 2020 & May 26, 2020 - January 21, 2021 \\
San Francisco & 876 & 244 & January 1, 2018 - May 25, 2020 & May 26, 2020 - January 24, 2021 \\
Los Angeles & 876 & 238 & January 1, 2018 - May 25, 2020 & May 26, 2020 - January 18, 2021 \\
Philadelphia & 876 & 244 & January 1, 2018 - May 25, 2020 & May 26, 2020 - January 24, 2021 \\ \hline
\end{tabular}}
\end{table}
\section{Results}
\vspace{2mm}
\lipsum[1-3]\\
\end{document}