每页浮动一个浮动

每页浮动一个浮动

我正在写一篇硕士论文,我的导师坚持要求每个图表或表格都应该有自己的页面。不幸的是,我有两个背靠背的表格,它们可以很好地放在一页上,无论我做什么都无法改变。我尝试过使用

\setcounter{topnumber}{1}
\setcounter{bottomnumber}{1}
\setcounter{totalnumber}{1}
\renewcommand{\topfraction}{0.01}
\renewcommand{\bottomfraction}{0.01}
\renewcommand{\textfraction}{0.01}
\renewcommand{\floatpagefraction}{0.01}

在我的序言中,正如我看到建议的那样别处,但这些该死的桌子仍然紧紧地贴在一起,就像溺水了一样(totalnumber仅适用于文本页面,如果我理解正确的话)。

我也尝试过\FloatBarrier在表格 1 和表格 2 之间进行替换,但这会导致文本页面填充不正确(第 3 页)。(第 1 页是文本,第 2 页是图 1,第 3 页是一半文本,一半空白,表格 1 出现在第 4 页,subsection{One}表格 1 之后的所有文本都移到了第 5 页,表格 2 移到了第 6 页。)这也是不可接受的。

我也尝试过将文本移动到两个表格之间,但是因为这是章节和部分的开头,所以第一个表格出现在调用它的文本之前,这也是不可接受的。

如何让两个表格和图 2 分别出现在连续的三页上,并正确填充文本页面?换句话说,第 1 页:文本;第 2 页:图 1;第 3 页:文本,第 4 页:表格 1,第 5 页:表格 2,第 6 页:图 2。

这是我的 MWE(包括我的完整序言,以防万一有干扰):

\documentclass[12pt]{report}
\usepackage{textcomp, graphicx, rotating, amsmath, booktabs, setspace, url, caption, titlesec, fancyhdr}
\usepackage[section]{placeins}
\usepackage[compress]{natbib}
\captionsetup[figure]{name={Fig.}}
\bibpunct{(}{)}{;}{a}{,}{,}
\urlstyle{same}
\doublespacing

\titleformat{\chapter}[display]{\bfseries\centering}{\huge Chapter \thechapter}{1em}{\Huge}
\titlespacing{\chapter}{0cm}{0cm}{1.5cm}

\pagestyle{fancy}
\lhead{} \chead{} \rhead{\thepage}
\lfoot{} \cfoot{} \rfoot{}
\renewcommand{\headrulewidth}{0pt}

\begin{document}
\thispagestyle{fancy}

\chapter{Three}

About 70 words of text.

\section{One}

Figure 1, placed here because that's the only way I could get the float on page 2!

\subsection{One}

About 100 words of text that in short succession call table 1, table 2, and figure 2.

\begin{table}[p]
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{p{3cm} p{2.5cm} c p{4cm}}
\toprule
Station Name & Location & Data Range & Normals \\
\midrule
Cameron Falls & 49$^\circ$09'38'' N, 88$^\circ$21'00" W & 1924-1998 & 1961-1990, 1971-2000, 1981-2010 \\
Cameron Falls (AUT) & 49$^\circ$09'14'' N, 88$^\circ$20'41'' W & 1998-2017 & - \\
Thunder Bay A & 48$^\circ$22'10'' N, 89$^\circ$19'38'' W & 1953-2012 & 1961-1990, 1971-2000 \\
Thunder Bay CS & 48$^\circ$22'10'' N, 89$^\circ$19'38'' W & 2000-2017 & - \\
\bottomrule
\end{tabular}
\caption{The first table.
\label{stationstable}}
\end{table}

\begin{table}[p]
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{l c c c}
\toprule
Month & Mean Air Temp. (\textcelsius{}) & Precipitation (mm) & Snow Fall (cm) \\
\midrule
January & -16.2 & 55.4 & 55.4 \\
February & -13.1 & 32.2 & 29.8 \\
March & -6.5 & 30.2 & 23.4 \\
April & 1.7 & 43.6 & 13.9 \\
May & 8.7 & 62.9 & 1.2 \\
June & 14.0 & 86.3 & 0.0 \\
July & 17.1 & 91.3 & 0.0 \\
August & 16.8 & 94.3 & 0.1 \\
September & 11.3 & 99.4 & 0.9 \\
October & 4.7 & 91.8 & 11.6 \\
November & -4.0 & 73.8 & 43.8 \\
December & -11.9 & 63.7 & 58.1 \\
\bottomrule
\end{tabular}
\caption{The second table.
\label{CFclimatetable}}
\end{table}

Figure 2.

80 words of text.

Another table.

The rest of my chapter.

\end{document}

这是我第一次发布问题,因此如果我需要做出更改,请告诉我。

提前致谢!

答案1

如果需要每页放置一张表,则使用整个页面。

\documentclass[12pt]{report}
\usepackage{textcomp, graphicx, rotating, amsmath, booktabs, setspace, url, caption, titlesec, fancyhdr}
\usepackage[section]{placeins}
\usepackage[compress]{natbib}
\captionsetup[figure]{name={Fig.}}
\bibpunct{(}{)}{;}{a}{,}{,}
\urlstyle{same}
\doublespacing

\titleformat{\chapter}[display]{\bfseries\centering}{\huge Chapter \thechapter}{1em}{\Huge}
\titlespacing{\chapter}{0cm}{0cm}{1.5cm}

\pagestyle{fancy}
\lhead{} \chead{} \rhead{\thepage}
\lfoot{} \cfoot{} \rfoot{}
\renewcommand{\headrulewidth}{0pt}

\begin{document}
\thispagestyle{fancy}

\chapter{Three}

About 70 words of text.

\section{One}

Figure 1, placed here because that's the only way I could get the float on page 2!

\subsection{One}

About 100 words of text that in short succession call table 1, table 2, and figure 2.

\begin{table}[p]
\begin{minipage}[c][\textheight][c]{\textwidth}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{p{3cm} p{2.5cm} c p{4cm}}
\toprule
Station Name & Location & Data Range & Normals \\
\midrule
Cameron Falls & 49$^\circ$09'38'' N, 88$^\circ$21'00" W & 1924-1998 & 1961-1990, 1971-2000, 1981-2010 \\
Cameron Falls (AUT) & 49$^\circ$09'14'' N, 88$^\circ$20'41'' W & 1998-2017 & - \\
Thunder Bay A & 48$^\circ$22'10'' N, 89$^\circ$19'38'' W & 1953-2012 & 1961-1990, 1971-2000 \\
Thunder Bay CS & 48$^\circ$22'10'' N, 89$^\circ$19'38'' W & 2000-2017 & - \\
\bottomrule
\end{tabular}
\caption{The first table.
\label{stationstable}}
\end{minipage}
\end{table}

\begin{table}[p]
\begin{minipage}[c][\textheight][c]{\textwidth}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{l c c c}
\toprule
Month & Mean Air Temp. (\textcelsius{}) & Precipitation (mm) & Snow Fall (cm) \\
\midrule
January & -16.2 & 55.4 & 55.4 \\
February & -13.1 & 32.2 & 29.8 \\
March & -6.5 & 30.2 & 23.4 \\
April & 1.7 & 43.6 & 13.9 \\
May & 8.7 & 62.9 & 1.2 \\
June & 14.0 & 86.3 & 0.0 \\
July & 17.1 & 91.3 & 0.0 \\
August & 16.8 & 94.3 & 0.1 \\
September & 11.3 & 99.4 & 0.9 \\
October & 4.7 & 91.8 & 11.6 \\
November & -4.0 & 73.8 & 43.8 \\
December & -11.9 & 63.7 & 58.1 \\
\bottomrule
\end{tabular}
\caption{The second table.
\label{CFclimatetable}}
\end{minipage}
\end{table}

Figure 2.

80 words of text.

Another table.

The rest of my chapter.

\end{document}

答案2

解决每页一个浮动元素左对齐问题的方法是使用\setcounter{topnumber}{1} 并只添加选项[t],无需将浮动元素填充到整个页面。只要有文本“正确填充”,它就可以工作(否则,无论浮动选项是什么,浮动元素都会被固定)。花点时间了解浮动行为如何影响 LaTeX 中图形和表格等浮动环境的位置?

由于浮点数的类型无关紧要,为了简化代码,我在第一页末尾使用了十次相同的小浮点数(只是为了简化代码,使用宏\topimage),后面跟着 26 段的长文本(只是为了再次简化,使用lipsum包)。结果是前八幅图像位于第 2-9 页的顶部,但最后两幅图像堆叠在一起,因为文本不够(但如果你再添加一些段落,你的主管会很高兴)。

\documentclass[12pt]{report}
\usepackage{graphicx}
\setcounter{topnumber}{1}
% just to simplify the dummy text to commands
\usepackage{lipsum} 
% just to simplify the example float to a command
\def\topimage{%
\begin{figure}[t]\centering%
\includegraphics[scale=.5]{example-image}%
\end{figure}}
\begin{document}
\chapter{Three}
% Eight floats, only one per page  
\topimage
\topimage
\topimage
\topimage
\topimage
\topimage
\topimage
\topimage
% there are not enough text for these float, so they will be  stacked
\topimage
\topimage
\lipsum[1-26]
\end{document}

姆韦

话虽如此,但对于更常见的情况,即每页不严格需要顶部浮动,我的建议是让浮动没有任何选项,并在浮动之间留出合理数量的文本,以便它们可以美观地分布。例如,用这个替换上面示例的内容...

\chapter{Three}
\lipsum[1-2]
\topimage
\lipsum[1-3]
\topimage
\lipsum[1-3]
\topimage
\lipsum[1-3]
\topimage
\lipsum[1-3]
\topimage
\lipsum[1-3]

\setcounter{topnumber}{1}.. 即使您删除该选项,每页也会产生一个顶部浮动[t]

相关内容