强制将当前未放置的图形放置在某个文本块之前

强制将当前未放置的图形放置在某个文本块之前

我正在写的一篇论文包含大量的图表,其中一节的图表比正文还多。不幸的是,正因为如此,图表分散到了论文的其余部分,甚至出现在正文结束后的几页上。我希望通过确保所有图表都放在论文的某个位置之前(靠近末尾)来避免这种情况(例如参考文献部分)。是否有命令强制 LaTeX 将文本中某个位置尚未放置的所有图表放在文本的该位置?

我想强调的是,我并不想使用[H]说明符。我完全可以接受 LaTeX 帮我定位图表,我只是希望它们都放在论文中的某个位置之前。

另请注意,\newpage\clearpage不是我的选项。我不想强制分页;我希望后续文本自然地跟随图形,而图形和以下文本之间没有分页符。我基本上想要浮动放置行为,而\newpage实际上不创建新页面。

这是一个最小工作示例,尝试解释我在说什么。目前,此代码将所有文本放在第一页上,与所有图形交错,两列宽的图形*放在第二页上。我的做法是让第一节的文本出现在第一页上,并尽可能多地显示图形(这是正常的 LaTeX 做法),然后让第二页显示所有剩余的图形(本例中是较大的图形*),并显示第二节的文本这个数字和不是作为新页面,但与该图在同一页上。

\documentclass[twocolumn]{article}
\usepackage{lipsum} %used to generate filler text

 \usepackage[demo]{graphicx}

\begin{document}

\section{Section with figures}
\lipsum[66]

\begin{figure*}
\includegraphics[width=\linewidth]{}
\end{figure*}
Some more text.
\begin{figure}
\includegraphics[width=\linewidth]{}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{}
\end{figure}
Some more text yet again.
\begin{figure}
\includegraphics[width=\linewidth]{}
\end{figure}
And, yet again, more text.
\begin{figure}
\includegraphics[width=\linewidth]{}
\end{figure}

\section{After figures}
I want this text to appear {\bf after} all the figures above, but not
simply on a fresh page after the last figure.  I would like it to
start running after the last figure.  For instance, if the last figure
takes a page, I would like this text to continue right after it
such that the figure is on the top half and this text is on the bottom
half of the page.

\lipsum[66]

\end{document}

答案1

你提到无需担心浮点数,所以我的建议是放弃单列的任何类型的浮动figure。为此,请使用[H]浮点说明符:

在此处输入图片描述

\documentclass[twocolumn]{article}
\usepackage{lipsum} %used to generate filler text

\usepackage{afterpage,float}
\usepackage[demo]{graphicx}

\begin{document}

\section{Section with figures}
\lipsum[66]

\begin{figure*}
  \includegraphics[width=\linewidth]{}
\end{figure*}

Some more text.

\begin{figure}[H]
\includegraphics[width=\linewidth]{}
\end{figure}

\begin{figure}[H]
\includegraphics[width=\linewidth]{}
\end{figure}

\begin{figure}[H]
\includegraphics[width=\linewidth]{}
\end{figure}

Some more text yet again.

\begin{figure}[H]
\includegraphics[width=\linewidth]{}
\end{figure}

And, yet again, more text.

\begin{figure}[H]
\includegraphics[width=\linewidth]{}
\end{figure}

\newpage

\section{After figures}
I want this text to appear \textbf{after} all the figures above, but not
simply on a fresh page after the last figure.  I would like it to
start running after the last figure.  For instance, if the last figure
takes a page, I would like this text to continue right after it
such that the figure is on the top half and this text is on the bottom
half of the page.

\lipsum[66]

\end{document}

两列figure*放置在 之后\newpage。但是,您可以在没有实际文档文本的情况下尝试放置此浮点数(再次忽略浮点数编号)。

答案2

由于两列浮动元素必须跨越下一页的顶部,并且(在 latex 2015 版本中,或使用fixltx2e较旧的格式)所有浮动元素都保持顺序,因此单列浮动元素必须在其之后,我不知道如何避免第一节之后出现大量空白,但是你可以这样做

在此处输入图片描述

\documentclass[twocolumn]{article}
\usepackage{lipsum} %used to generate filler text

 \usepackage[demo]{graphicx}

\begin{document}
\begin{figure*}
\includegraphics[width=\linewidth]{}
\end{figure*}

\section{Section with figures}
\lipsum[66]
Some more text.
\begin{figure}
\includegraphics[width=\linewidth]{}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{}
\end{figure}
\begin{figure}
\includegraphics[width=\linewidth]{}
\end{figure}
Some more text yet again.
\begin{figure}
\includegraphics[width=\linewidth]{}
\end{figure}
And, yet again, more text.
\begin{figure}
\includegraphics[width=\linewidth]{}
\end{figure}

\newpage\mbox{}\newpage

\section{After figures}
I want this text to appear \textbf{after} all the figures above, but not
simply on a fresh page after the last figure.  I would like it to
start running after the last figure.  For instance, if the last figure
takes a page, I would like this text to continue right after it
such that the figure is on the top half and this text is on the bottom
half of the page.

\lipsum[66]

\end{document}

相关内容