summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/sttools/boundbox.sty
blob: a08ac801f9e3138833be46f559eb767aadf8503f (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%% boundbox.sty
%% Copyright 1997 Sigitas Tolu\v sis
%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
%% e-mail sigitas@vtex.lt
%% http://www.vtex.lt/tex/download/macros/
%%
% 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]
%
\newif\if@withfoot \@withfoottrue
\DeclareOption{nofoot}{\global\@withfootfalse}
\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