%%
%% This is file `boundbox.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% boundbox.dtx  (with options: `package')
%% 
%% Copyright (C) 1997-2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
%% http://www.vtex.lt/tex/download/macros/
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% PURPOSE: Calculate TeX bounding box in rounded points (LaTeX2e)
%%          from left top corner of the paper
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{boundbox}
    [2012/05/29 v1.3 Calculate TeX bounding box in points]
%%
\newif\if@withfoot \@withfoottrue
\newif\if@output@bbox@special \@output@bbox@specialtrue
\DeclareOption{nofoot}{\global\@withfootfalse}
\DeclareOption{nospec}{\global\@output@bbox@specialfalse}
\ProcessOptions
%%
\def\special@bbox@odd@prefix{mt:TeXBBox:odd}
\def\special@bbox@even@prefix{mt:TeXBBox:even}
%%
\def\roundtexdim#1#{\round@tex@dim{#1}}
\def\round@tex@dim#1#2#3{%
  \expandafter\expandafter\csname get@#1@pt@data\endcsname\the#2\to#3\relax
  }
\def\get@floor@pt@data#1.#2#3\to#4{%
  \bgroup
    \@tempcnta=#1\relax
    \xdef#4{\the\@tempcnta}%
  \egroup
  }
\def\get@round@pt@data#1.#2#3\to#4{%
  \bgroup
    \@tempcnta=#1\relax
    \ifnum#2>4\relax
      \advance\@tempcnta by\@ne
    \fi
    \xdef#4{\the\@tempcnta}%
  \egroup
  }
\let\get@@pt@data\get@round@pt@data
\def\get@ceil@pt@data#1.#2#3\to#4{%
  \bgroup
    \@tempcnta=#1\relax
    \afterassignment\@gobbletwo
    \@tempcntb=#2#3\relax
    \ifnum\@tempcntb>0\relax
      \advance\@tempcnta by\@ne
    \fi
    \xdef#4{\the\@tempcnta}%
  \egroup
  }
\def\@calculate@bbox{%
  \bgroup
    \@tempdima=1in\relax
    \advance\@tempdima by\hoffset
    \advance\@tempdima by\oddsidemargin
    \roundtexdim floor{\@tempdima}\bbox@odd@left@pt
    \advance\@tempdima\textwidth
    \roundtexdim ceil{\@tempdima}\bbox@odd@right@pt
    \@tempdima=1in\relax
    \advance\@tempdima by\hoffset
    \advance\@tempdima by\evensidemargin
    \roundtexdim floor{\@tempdima}\bbox@even@left@pt
    \advance\@tempdima\textwidth
    \roundtexdim ceil{\@tempdima}\bbox@even@right@pt
    \@tempdima=1in\relax
    \advance\@tempdima by\voffset
    \advance\@tempdima by\topmargin
    \roundtexdim floor{\@tempdima}\bbox@odd@top@pt
    \global\let\bbox@even@top@pt\bbox@odd@top@pt
    \advance\@tempdima by\headheight
    \advance\@tempdima by\headsep
    \advance\@tempdima\textheight
    \if@withfoot
      \advance\@tempdima\footskip
    \fi
    \roundtexdim ceil{\@tempdima}\bbox@odd@bottom@pt
    \global\let\bbox@even@bottom@pt\bbox@odd@bottom@pt
  \egroup
  }
%%
\AtBeginDocument{%
  \@calculate@bbox
  \if@output@bbox@special
    \special{\special@bbox@odd@prefix\space
           left=\csname bbox@odd@left@pt\endcsname\space
           top=\csname bbox@odd@top@pt\endcsname\space
           right=\csname bbox@odd@right@pt\endcsname\space
           bottom=\csname bbox@odd@bottom@pt\endcsname
           }%
    \special{\special@bbox@even@prefix\space
           left=\csname bbox@even@left@pt\endcsname\space
           top=\csname bbox@even@top@pt\endcsname\space
           right=\csname bbox@even@right@pt\endcsname\space
           bottom=\csname bbox@even@bottom@pt\endcsname
           }%
  \fi
  }
\endinput
%%
%% End of file `boundbox.sty'.
