diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/sttools/boundbox.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/sttools/boundbox.sty | 188 |
1 files changed, 110 insertions, 78 deletions
diff --git a/Master/texmf-dist/tex/latex/sttools/boundbox.sty b/Master/texmf-dist/tex/latex/sttools/boundbox.sty index a08ac801f9e..1799613f736 100644 --- a/Master/texmf-dist/tex/latex/sttools/boundbox.sty +++ b/Master/texmf-dist/tex/latex/sttools/boundbox.sty @@ -1,85 +1,117 @@ -%% boundbox.sty -%% Copyright 1997 Sigitas Tolu\v sis +%% +%% 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 -%% e-mail sigitas@vtex.lt %% 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 %% -% This program can redistributed and/or modified under the terms -% of the LaTeX Project Public License Distributed from CTAN -% archives in directory macros/latex/base/lppl.txt; either -% version 1 of the License, or (at your option) any later version. -% -% PURPOSE: Calculate TeX Bounding Box in points (LaTeX2e) -% -% SHORT DESCRIPTION: -% -% \@calculate -% ----------- -% Internal macro \@calculate writes TeX box dimensions -% to the token list \bound in such format: -% -% \bound{left=x1 top=y1 right=x2 bottom=y2} -% -% x1 - distance in points from the left side of paper -% to the left side of TeX box -% y1 - distance in points from the top of paper -% to the top of TeX box (including head) -% x2 - distance in points from the left side of paper -% to the right side of TeX box -% y2 - distance in points from the top of paper -% to the bottom of TeX box -% (including foot; with option "nofoot" without foot) -% -% \topoint#1#2 -% ------------ -% Dimension #1 in any unit of measure converts to value in points -% and defines it to macro #2 -% -% This package writes such special to DVI: -% \special{mt:TeXBBox left=x1 top=y1 right=x2 bottom=y2} -% -% \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{boundbox}[1998/02/24] -% +\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 -% -\newtoks\bound \bound={}% -\def\@@to#1#2{\begingroup - \xdef\a@act{\global\noexpand#1{\the#1#2}}\a@act -\endgroup} -% -\def\topoint#1#2{% -\@tempdimb=#1 -\@tempcnta=\@tempdimb -\multiply\@tempcnta by10 -\divide\@tempcnta by18647 \advance\@tempcnta by1 -\multiply\@tempcnta by72 \divide\@tempcnta by2540 -\expandafter\def\expandafter#2\expandafter{\the\@tempcnta}} -% -\def\@calculate{% -\@tempdima=1in -\advance\@tempdima by\hoffset -\advance\@tempdima by\oddsidemargin -\topoint{\@tempdima}{\@a}% -\advance\@tempdima\textwidth -\topoint{\@tempdima}{\@c}% -\@tempdima=1in -\advance\@tempdima by\voffset -\advance\@tempdima by\topmargin -\topoint{\@tempdima}{\@b}% -\advance\@tempdima by\headheight -\advance\@tempdima by\headsep -\advance\@tempdima\textheight -\if@withfoot - \advance\@tempdima\footskip -\fi -\topoint{\@tempdima}{\@d}% -\@tempcnta=\@d -\expandafter\def\expandafter\@d\expandafter{\the\@tempcnta}% -\@@to\bound{left=\@a\space top=\@b\space right=\@c\space bottom=\@d}% -} -\AtBeginDocument{\@calculate\special{mt:TeXBBox \the\bound}} -\endinput
\ No newline at end of file +%% +\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'. |