将浮动屏障视为页面边框吗?

将浮动屏障视为页面边框吗?

当我使用figure环境时,我喜欢使用[bt]选项。我现在有子部分充当浮动屏障(使用extraplaceins包),并且由于我的限制子部分, [b]/[t]不起作用。如果我用[!t]或强制它[!b],它确实有效,但会将屏障(连接的子部分)推到上一页/下一页。虽然我认为是正确的,但这不是我想要的。

理想情况下,它应该将子部分(floatbarriers)视为页面边框,这意味着,例如,[b]如果它与新子部分共享一个页面,则将我的图形放在其子部分的末尾。这种行为容易实现吗?

编辑:添加 MWE:

\documentclass[10pt]{article}
\usepackage[section]{extraplaceins}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[demo]{graphicx}
\usepackage{color}

\begin{document}

\section*{Section ONE}
\blindtext
\begin{figure}[h]
\includegraphics[width=0.4\textwidth,height=2cm]{myimg.png}
\caption{\color{red} In next example I move this figure to the bottom of \underline{this section} with the [b] option}
\end{figure}
\blindtext

\section*{Section TWO}
\blindtext

\clearpage

%
{\color{red} Second illustration : Undesired effect of [b]}
\section*{Section ONE}
\blindtext
\begin{figure}[b]
\includegraphics[width=0.4\textwidth,height=2cm]{myimg.png}
\caption{\color{red} All that whitespace! [b] pushes section into next page instead of just placing float at bottom of section. How to change behaviour?}
\end{figure}
\blindtext

\section*{Section TWO}
\blindtext


\end{document}

答案1

我找不到该extraplaceins加拿大运输安全局,但假设它类似于placeins包中,您可以借助afterpage包和宏的小修补\@fb@secFB。我用的是xpatch包。我相信这为您的 MWE 提供了所需的行为。对于更困难的情况,浮动很大并且不适合当前部分的页面底部,但有大量剩余空间,浮动可能会在下一节开始后出现在页面上。不清楚您希望在这种情况下发生什么。

\documentclass[10pt]{article}
% \usepackage[section]{extraplaceins}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[demo]{graphicx}
\usepackage{color}


\usepackage[section]{placeins}
\usepackage{afterpage}
\usepackage{xpatch}
\makeatletter
\AtBeginDocument{\xpatchcmd{\@fb@secFB}{\FloatBarrier}{\afterpage{\FloatBarrier}}{}{}}
\makeatother


\begin{document}

\section*{Section ONE}
\blindtext
\begin{figure}[h]
\includegraphics[width=0.4\textwidth,height=2cm]{myimg.png}
\caption{\color{red} In next example I move this figure to the bottom of \underline{this section} with the [b] option}
\end{figure}
\blindtext

\section*{Section TWO}
\blindtext

\clearpage

%
{\color{red} Second illustration : Undesired effect of [b]}
\section*{Section ONE}
\blindtext
\begin{figure}[b]
\includegraphics[width=0.4\textwidth,height=2cm]{myimg.png}
\caption{\color{red} All that whitespace! [b] pushes section into next page instead of just placing float at bottom of section. How to change behaviour?}
\end{figure}
\blindtext

\section*{Section TWO}
\blindtext

\clearpage

%
\section*{Section ONE}
\blindtext
\begin{figure}[h]
\includegraphics[width=0.4\textwidth,height=10cm]{myimg.png}
\caption{\color{red} In next example I move this figure to the bottom of \underline{this section} with the [b] option}
\end{figure}
\blindtext

\section*{Section TWO}
\blindtext

\clearpage

%
{\color{red} Second illustration : Undesired effect of [b]}
\section*{Section ONE}
\blindtext
\begin{figure}[b]
\includegraphics[width=0.4\textwidth,height=10cm]{myimg.png}
\caption{\color{red} All that whitespace! [b] pushes section into next page instead of just placing float at bottom of section. How to change behaviour?}
\end{figure}
\blindtext

\section*{Section TWO}
\blindtext

\end{document}

相关内容