LateX 中的数字在页面上自动流动/分布

发布于 2025-01-11 08:36:02 字数 1109 浏览 0 评论 0原文

我有一个很长的 LaTeX 脚本,用于制作文档,其中大部分部分都有三个数字,并且它们非常适合页面。在一些随机部分,我们有六到九个数字。因此,页面将无法容纳这些额外的数字,它们将覆盖在页面的底部。

如何自动强制最后三个数字显示在单独的页面上,而不需要手动调整每个部分? (换句话说,一种使清晰页面自动完成的方法)。

我正在寻找类似于 longtable – 允许表格跨越页面边界环境自动控制流量。

以下是常规情况和随机情况的示例:

***Regular case***
    \begin{figure}[b!]
    \centering
     \includegraphics[width =\textwidth]{Path/A.png}
     \includegraphics[width =\textwidth]{Path/B.png}
     \includegraphics[width =\textwidth]{Path/C.png}
    \end{figure} 
    \clearpage

***Random case***
    \begin{figure}[b!]
    \centering
     \includegraphics[width =\textwidth]{Path/E.png}
     \includegraphics[width =\textwidth]{Path/F.png}
     \includegraphics[width =\textwidth]{Path/G.png}
     \includegraphics[width =\textwidth]{Path/H.png}
     \includegraphics[width =\textwidth]{Path/I.png}
     \includegraphics[width =\textwidth]{Path/J.png}
     \includegraphics[width =\textwidth]{Path/K.png}
     \includegraphics[width =\textwidth]{Path/L.png}
    \end{figure} 
    \clearpage

I have a long LaTeX script for making a document where most of the sections have three figures and they fit the page very good. In some random sections, we have six or nine figures. Therefore, the page will not fit these extra figures and they will overlay at the bottom of the page.

How can I automatically force the last three figures to appear on a separate page without the need to adjust each of these sections manually? (In other words, a way to make the clear page done automatically).

I am looking for something similar to longtable – Allow tables to flow over page boundaries environment to control the flow automatically.

Here is an example of the regular and random cases:

***Regular case***
    \begin{figure}[b!]
    \centering
     \includegraphics[width =\textwidth]{Path/A.png}
     \includegraphics[width =\textwidth]{Path/B.png}
     \includegraphics[width =\textwidth]{Path/C.png}
    \end{figure} 
    \clearpage

***Random case***
    \begin{figure}[b!]
    \centering
     \includegraphics[width =\textwidth]{Path/E.png}
     \includegraphics[width =\textwidth]{Path/F.png}
     \includegraphics[width =\textwidth]{Path/G.png}
     \includegraphics[width =\textwidth]{Path/H.png}
     \includegraphics[width =\textwidth]{Path/I.png}
     \includegraphics[width =\textwidth]{Path/J.png}
     \includegraphics[width =\textwidth]{Path/K.png}
     \includegraphics[width =\textwidth]{Path/L.png}
    \end{figure} 
    \clearpage

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉殇 2025-01-18 08:36:02

感谢大家的反馈。我在网上查了一些关于这个问题的帖子,有几种方法可以解决这个问题(相当好,但不是 100%)。

第一个解决方案:
正如 @samcarter_is_at_topanswers.xyz 提到的,figure 环境不支持分页符。 \captionof (来自标题包)和 \label 可用于图形标题和引用。

\begingroup
     \centering
     \includegraphics[width =\textwidth]{Path/A.png} 
     \includegraphics[width =\textwidth]{Path/B.png} 
     \includegraphics[width =\textwidth]{Path/C.png} 
     \includegraphics[width =\textwidth]{Path/D.png} 
     \includegraphics[width =\textwidth]{Path/E.png} 
     \includegraphics[width =\textwidth]{Path/F.png} 
     \includegraphics[width =\textwidth]{Path/G.png} 
     \includegraphics[width =\textwidth]{Path/H.png} 
     \includegraphics[width =\textwidth]{Path/J.png} 
     \captionof{figure}{Whatever caption}
     \label{WhateverLabel}
\endgroup 

第二个解决方案(不是最好的自动化解决方案):
figure分成subfigure并使用\ContinuedFloat来分隔页面,但具有相同的标题和标签。

\begin{figure}[b!]
\centering
 \begin{subfigure}[b!]{\textwidth}
 \centering
 \includegraphics[width =\textwidth]{Path/A.png}
 \end{subfigure}
 \begin{subfigure}[b!]{\textwidth}
 \centering
 \includegraphics[width =\textwidth]{Path/B.png}
 \end{subfigure}
 \begin{subfigure}[b!]{\textwidth}
 \centering
 \includegraphics[width =\textwidth]{Path/C.png}
 \end{subfigure}
\caption{whatever caption}
\label{WhateverLabel}  
\end{figure}
\clearpage

\begin{figure}[b!]
\ContinuedFloat
 \begin{subfigure}[b!]{\textwidth}
 \centering
 \includegraphics[width =\textwidth]{Path/D.png}
 \end{subfigure}
 \begin{subfigure}[b!]{\textwidth}
 \centering
 \includegraphics[width =\textwidth]{Path/E.png}
 \end{subfigure}
 \begin{subfigure}[b!]{\textwidth}
 \centering
 \includegraphics[width =\textwidth]{Path/F.png}
 \end{subfigure} 
\caption{whatever caption}
\label{WhateverLabel} 
\end{figure}
\clearpage

第二种解决方案参考: LaTeX 中的 Subfigure – 完整指南

第三种解决方案: 使用@Prof 创建的figureSeries 包。托马斯·韦斯.不幸的是,它已经有一段时间没有更新了。

第三种解决方案参考:GitHub 上的figureSeries包Stack Exchange 上的figureSeries 包

Thanks everyone for the feedback. I checked couple of posts on the internet regarding the issue and there are couple of ways to solve the problem (fairly good but not 100%).

First Solution:
As mentioned by @samcarter_is_at_topanswers.xyz , the figure environment does not support page breaks. \captionof (from the caption package) and \label can be used for figure captioning and referencing.

\begingroup
     \centering
     \includegraphics[width =\textwidth]{Path/A.png} 
     \includegraphics[width =\textwidth]{Path/B.png} 
     \includegraphics[width =\textwidth]{Path/C.png} 
     \includegraphics[width =\textwidth]{Path/D.png} 
     \includegraphics[width =\textwidth]{Path/E.png} 
     \includegraphics[width =\textwidth]{Path/F.png} 
     \includegraphics[width =\textwidth]{Path/G.png} 
     \includegraphics[width =\textwidth]{Path/H.png} 
     \includegraphics[width =\textwidth]{Path/J.png} 
     \captionof{figure}{Whatever caption}
     \label{WhateverLabel}
\endgroup 

Second Solution (Not the best automated solution):
Divide the figure into subfigure and use \ContinuedFloat to break the pages but with the same caption and label.

\begin{figure}[b!]
\centering
 \begin{subfigure}[b!]{\textwidth}
 \centering
 \includegraphics[width =\textwidth]{Path/A.png}
 \end{subfigure}
 \begin{subfigure}[b!]{\textwidth}
 \centering
 \includegraphics[width =\textwidth]{Path/B.png}
 \end{subfigure}
 \begin{subfigure}[b!]{\textwidth}
 \centering
 \includegraphics[width =\textwidth]{Path/C.png}
 \end{subfigure}
\caption{whatever caption}
\label{WhateverLabel}  
\end{figure}
\clearpage

\begin{figure}[b!]
\ContinuedFloat
 \begin{subfigure}[b!]{\textwidth}
 \centering
 \includegraphics[width =\textwidth]{Path/D.png}
 \end{subfigure}
 \begin{subfigure}[b!]{\textwidth}
 \centering
 \includegraphics[width =\textwidth]{Path/E.png}
 \end{subfigure}
 \begin{subfigure}[b!]{\textwidth}
 \centering
 \includegraphics[width =\textwidth]{Path/F.png}
 \end{subfigure} 
\caption{whatever caption}
\label{WhateverLabel} 
\end{figure}
\clearpage

Reference of Second Solution: Subfigure in LaTeX – Full Guide

Third Solution: Use figureSeries package created by @Prof. Thomas Weise. Unfortunately, it has not been updated since a while.

References of Third Solution: figureSeries Package on GitHub and figureSeries Package on Stack Exchange

你怎么敢 2025-01-18 08:36:02

figure 环境不支持分页符。如果你想要一些东西来打破页面,不要使用figure环境。

如果您仍然需要标题和类似的东西,您可以使用 caption 包,如下所示:

\documentclass{article}

\usepackage{graphicx}
\usepackage{caption}

\begin{document}

\begingroup
    \centering
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \captionof{figure}{whatever caption}
\endgroup 

\end{document}

The figure environment does not support page breaks. If you want something to break pages, don't use the figure environment.

In case you still need a caption and similar stuff, you can use the caption package like this:

\documentclass{article}

\usepackage{graphicx}
\usepackage{caption}

\begin{document}

\begingroup
    \centering
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \includegraphics[width =\textwidth]{example-image-duck}
     \captionof{figure}{whatever caption}
\endgroup 

\end{document}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文