rlm@510: % P L A C E I N S . S T Y ver 2.2 April 18, 2005 rlm@510: % Donald Arseneau asnd@triumf.ca rlm@510: % rlm@510: % Modified on March 6, 2011 rlm@510: % Lex Fridman lexfridman@gmail.com rlm@510: % See: http://bit.ly/h2Se0u rlm@510: % rlm@510: % Keep floats `in their place'; don't let them float into another section. rlm@510: % Instructions are below. rlm@510: % rlm@510: % placeins.sty is freely released to the public domain. rlm@510: rlm@510: rlm@510: \def\@fb@botlist{\@botlist} rlm@510: \def\@fb@topbarrier{\suppressfloats[t]} rlm@510: rlm@510: \catcode`\V=14 % `V' is a comment character unless [verbose] rlm@510: rlm@510: \@ifundefined{DeclareOption}{}% rlm@510: {\DeclareOption{below}{\def\@fb@botlist{}} rlm@510: \DeclareOption{above}{\def\@fb@topbarrier{}} rlm@510: \DeclareOption{section}{\AtBeginDocument{% rlm@510: \expandafter\renewcommand\expandafter\section\expandafter rlm@510: {\expandafter\@fb@secFB\section}% rlm@510: \newcommand\@fb@secFB{\FloatBarrier rlm@510: \gdef\@fb@afterHHook{\@fb@topbarrier \gdef\@fb@afterHHook{}}} rlm@510: \g@addto@macro\@afterheading{\@fb@afterHHook} rlm@510: \gdef\@fb@afterHHook{} rlm@510: }} rlm@510: \DeclareOption{subsection}{\AtBeginDocument{% rlm@510: \expandafter\renewcommand\expandafter\subsection\expandafter rlm@510: {\expandafter\@fb@subsecFB\subsection}% rlm@510: \newcommand\@fb@subsecFB{\FloatBarrier rlm@510: \gdef\@fb@afterHHook{\@fb@topbarrier \gdef\@fb@afterHHook{}}} rlm@510: \g@addto@macro\@afterheading{\@fb@afterHHook} rlm@510: \gdef\@fb@afterHHook{} rlm@510: }} rlm@510: \DeclareOption{subsubsection}{\AtBeginDocument{% rlm@510: \expandafter\renewcommand\expandafter\subsubsection\expandafter rlm@510: {\expandafter\@fb@subsubsecFB\subsubsection}% rlm@510: \newcommand\@fb@subsubsecFB{\FloatBarrier rlm@510: \gdef\@fb@afterHHook{\@fb@topbarrier \gdef\@fb@afterHHook{}}} rlm@510: \g@addto@macro\@afterheading{\@fb@afterHHook} rlm@510: \gdef\@fb@afterHHook{} rlm@510: }} rlm@510: \DeclareOption{verbose}{\catcode`\V=9 }% Activate things after `V' rlm@510: \ProvidesPackage{placeins}[2005/04/18 \space v 2.2] rlm@510: \ProcessOptions rlm@510: } % end of \@ifundefined rlm@510: rlm@510: \def\FloatBarrier{\par\begingroup \let\@elt\relax rlm@510: V\edef\@tempa{\write\m@ne{Package placeins Info: Float barrier, from rlm@510: V input line \the\inputlineno, processed on page \thepage, lands on rlm@510: V page \noexpand\thepage. }}\@tempa rlm@510: \edef\@tempa{\@fb@botlist\@deferlist\@dbldeferlist}% rlm@510: \ifx\@tempa\@empty V\PackageInfo{placeins}{No floats held,}% rlm@510: \else rlm@510: \ifx\@fltovf\relax % my indicator of recursion rlm@510: \if@firstcolumn V\PackageWarning{placeins}{Some floats are stuck,}% rlm@510: \clearpage rlm@510: \else V\PackageInfo{placeins}{Eject a column and check again:}% rlm@510: \null\newpage\FloatBarrier rlm@510: \fi rlm@510: \else V\PackageInfo{placeins}{Must dump some floats}% rlm@510: \newpage \let\@fltovf\relax V\PackageInfo{placeins}{Check again:}% rlm@510: \FloatBarrier % recurse once only rlm@510: \fi\fi \endgroup rlm@510: \@fb@topbarrier } rlm@510: rlm@510: \catcode`\V=11 rlm@510: \endinput rlm@510: rlm@510: %====================== BEGIN INSTRUCTIONS =========================== rlm@510: rlm@510: p l a c e i n s . s t y ver 2.2 April 18, 2005 rlm@510: Donald Arseneau asnd@triumf.ca rlm@510: rlm@510: rlm@510: Placeins.sty keeps floats `in their place', preventing them from floating rlm@510: past a "\FloatBarrier" command into another section. To use it, declare rlm@510: "\usepackage{placeins}" and insert "\FloatBarrier" at places that floats rlm@510: should not move past, perhaps at every "\section". rlm@510: rlm@510: Option: [section] rlm@510: rlm@510: A more convenient way to stop floats at section boundaries is to change rlm@510: the definition of "\section" to include "\FloatBarrier", either at the rlm@510: beginning, before "\@startsection", or in the `style' specification (see rlm@510: The LaTeX Companion, section 2.2.2; or 2.3 in the 1st ed). If you specify rlm@510: "\usepackage[section]{placeins}", then the "\section" command will be rlm@510: redefined with "\FloatBarrier" inserted at the beginning. rlm@510: rlm@510: Options: [above] [below] rlm@510: rlm@510: Something you may not like is that, by default, "\FloatBarrier" is very rlm@510: strict, and will (try to) prevent a float from appearing above the start rlm@510: of the current section or below the start of the next section, even rlm@510: though the float is still on the same page as its intended section. rlm@510: Each restriction can be relaxed separately by using the "[above]" and rlm@510: "[below]" package options: "[above]" allows floats to appear above their rlm@510: section, if on the same page; "[below]" allows below. rlm@510: rlm@510: NOTE! The original version of placeins.sty acted like it was loaded rlm@510: with the option "[above]" specified. rlm@510: rlm@510: There is a problem with LaTeX's "\suppressfloats" being out of step with rlm@510: the page breaking (see usenet msg and thread) rlm@510: which sometimes allows a float to go above a "\FloatBarrier" placed near rlm@510: the top of a page. Maybe placeins will fix it sometime later. rlm@510: rlm@510: Option: [verbose] rlm@510: rlm@510: There is a package option "[verbose]" that causes many messages to be rlm@510: written in the log file. It might be used to answer the question: rlm@510: `How did *that* get *there*?!?' rlm@510: rlm@510: %====================== END INSTRUCTIONS ======================== rlm@510: rlm@510: Test file integrity: ASCII 32-57, 58-126: !"#$%&'()*+,-./0123456789 rlm@510: :;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~