我正在使用带有 section 选项的 placins 包。我注意到在某个部分之前似乎有一个分页符。下面是我的代码。如何将第二部分移到上一页?
\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage[section]{placeins}
\begin{document}
\section{First}
\lipsum[1-3]
\begin{figure}[htb]
\centering
\includegraphics[width=0.8\textwidth]{example-image}
\caption{\label{fig:} }
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=0.8\textwidth]{example-image}
\caption{\label{fig:} }
\end{figure}
\begin{figure}[htb]
\centering
\includegraphics[width=0.8\textwidth]{example-image}
\caption{\label{fig:} }
\end{figure}
\section{Second}
\lipsum[4]
\begin{figure}[htb]
\centering
\includegraphics[width=0.8\textwidth]{example-image}
\caption{\label{fig:} }
\end{figure}
\end{document}
答案1
这?
\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{lipsum}
%\usepackage[section]{placeins}
\begin{document}
\section{First}
\lipsum[1-3]
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{example-image}
\caption{\label{fig:} }
\end{figure}
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{example-image}
\caption{\label{fig:} }
\end{figure}
\clearpage
\begin{figure}[ht]
\centering
\includegraphics[width=0.8\textwidth]{example-image}
\caption{\label{fig:} }
\end{figure}
\section{Second}
\lipsum[4]
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{example-image}
\caption{\label{fig:} }
\end{figure}
\end{document}
答案2
将图形的位置说明符从 更改为htb
应该htpb
可以解决问题。
以下是 placeins 的相关来源:
\def\FloatBarrier{\par\begingroup \let\@elt\relax
V\edef\@tempa{\write\m@ne{Package placeins Info: Float barrier, from
V input line \the\inputlineno, processed on page \thepage, lands on
V page \noexpand\thepage. }}\@tempa
\edef\@tempa{\@fb@botlist\@deferlist\@dbldeferlist}%
\ifx\@tempa\@empty V\PackageInfo{placeins}{No floats held,}%
\else
\ifx\@fltovf\relax % my indicator of recursion
\if@firstcolumn V\PackageWarning{placeins}{Some floats are stuck,}%
\clearpage
\else V\PackageInfo{placeins}{Eject a column and check again:}%
\null\newpage\FloatBarrier
\fi
\else V\PackageInfo{placeins}{Must dump some floats}%
\newpage \let\@fltovf\relax V\PackageInfo{placeins}{Check again:}%
\FloatBarrier % recurse once only
\fi\fi \endgroup
\@fb@topbarrier }