summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/chkfloat/chkfloat.sty
blob: 63f28da894f30ab079b58c939dab14f98f031743 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
%%
%% This is file `chkfloat.sty'.
%%
%% Author: Tomas "tohecz" Hejda <tohecz@gmail.com>
%%
%% Licenced under LaTeX-Project Public License version 1.3 or newer.
%% 
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{chkfloat}[2012/08/19 v0.1 chkfloat: check for moved floats]

% tolerances
\PassOptionsToPackage{patch}{kvoptions}
\RequirePackage{kvoptions}
\DeclareStringOption{tolerance}
\def\chkfloat@tolerance{1}
\ProcessKeyvalOptions*

% store original macros \@float and \@caption
\let\chkfloat@float\@float
\let\chkfloat@caption\@caption
% make \@float remember the page where the float should be
\def\@float{\edef\chkfloat@page{\thepage}\chkfloat@float}
% make \@caption write to a file .fof the information about final page, original page and float caption
\def\@caption#1[#2]#3{\chkfloat@caption{#1}[#2]{#3}%
  \addtocontents{fof}{\protect\chkfloat@{\thepage}{\chkfloat@page}{\csname fnum@#1\endcsname: #2}}%
}
% checking macro
\def\chkfloat@#1#2#3{\ifnum#1>\numexpr#2+\chkfloat@tolerance\relax
  \begingroup\let\on@line\@gobble\def\nobreakspace{ }\GenericWarning{}{Float misplaced on pages #2->#1, #3}\endgroup
\fi
}
% process the file .fof
\@starttoc{fof}

\endinput
%%
%% End of file `chkfloat.sty'.
%%