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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
%% $Id: pst-abspos.tex 135 2009-09-27 12:33:57Z herbert $
%%
%% This is file `pst-abspos.tex',
%%
%% IMPORTANT NOTICE:
%%
%% Package `pst-abspos.tex'
%%
%% Herbert Voss <voss@perce.de>
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%% `pst-abspos' is a PSTricks package to put objects at absolute coordinates
%%
%% For a ChangeLog go the the end
%%
\csname PSTabsposLoaded\endcsname
\let\PSTabsposLoaded\endinput
% Requires PSTricks, pst-node
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTnodesLoaded\endinput\else\input pst-node.tex\fi
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey \fi
%
\def\fileversion{0.2}
\def\filedate{2009/09/27}
\message{`PST-abspos' v\fileversion, \filedate\space (Herbert Voss)}
%
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
\SpecialCoor
%
\pst@addfams{pst-abspos}
%
\newif\ifpst@lowerleft \pst@lowerleftfalse
\newif\ifpst@notitlepage \pst@notitlepagefalse
\newdimen\pst@xOffset
\newdimen\pst@yOffset
%
\define@key[psset]{pst-abspos}{position}{\edef\psk@abspos@position{#1}}
\psset{position=lb}
%
\let\pst@newpage\newpage
%
\DeclareOption{notitlepage}{\pst@notitlepagetrue}
\DeclareOption{absolute}{%
\ifpst@notitlepage
\def\newpage{\pst@newpage\pstSetAbsoluteOrigin}%
\AtBeginDocument{\pstSetAbsoluteOrigin}
\fi%
}
\DeclareOption{lowerleft}{\pst@lowerlefttrue}
\DeclareOption{relative}{%
\ifpst@notitlepage
\def\newpage{\pst@newpage\pstSetRelativeOrigin(0,0)}%
\AtBeginDocument{\pstSetRelativeOrigin(0,0)}
\fi%
}
\DeclareOption{PostScript}{%
\ifpst@notitlepage
\def\newpage{\pst@newpage\pstSetPostScriptOrigin}%
\AtBeginDocument{\pstSetPostScriptOrigin}
\fi%
}
\ProcessOptions\relax
%
\def\pst@paperheight{\ifpst@lowerleft 1 \else 0 \fi }
%
% save the origin point of the paper plane. This macro must be
% initiated before any other output
%
\def\pstSetRelativeOrigin(#1){\pnode(#1){pst@Origin}}
\def\pstSetAbsoluteOrigin{%
\pst@xOffset=-\oddsidemargin%
\advance\pst@xOffset by -\parindent%
\pst@yOffset=\topmargin%
\advance\pst@yOffset by \headheight%
\advance\pst@yOffset by \headsep%
\advance\pst@yOffset by \topskip%
\bgroup
\psset{unit=1pt}
% \pnode(\strip@pt\pst@xOffset, \strip@pt\pst@yOffset){pstTextOrigin}%
\pnode(0,0){pstTextOrigin}%
\advance\pst@xOffset by -1in%
\advance\pst@yOffset by 1in%
\ifpst@lowerleft
\advance\pst@yOffset by -\paperheight
\advance\pst@yOffset by 1in%
\fi
\pnode(\strip@pt\pst@xOffset, \strip@pt\pst@yOffset){pst@Origin}%
\egroup%
}
\def\pstSetPostScriptOrigin{%
\pst@xOffset=-\oddsidemargin%
\advance\pst@xOffset by -\parindent%
\pst@yOffset=\topmargin%
\advance\pst@yOffset by \headheight%
\advance\pst@yOffset by \headsep%
\advance\pst@yOffset by \topskip%
\bgroup
\psset{unit=1pt}
\pnode(\strip@pt\pst@xOffset, \strip@pt\pst@yOffset){pstTextOrigin}%
\ifpst@lowerleft
\advance\pst@yOffset by -\paperheight
\advance\pst@yOffset by 3in
\fi
\pnode(\strip@pt\pst@xOffset, \strip@pt\pst@yOffset){pst@Origin}%
\egroup}
%
\def\pstPutAbs{\@ifnextchar[{\pst@PutAbs@i}{\pst@PutAbs@i[]}}
\def\pst@PutAbs@i[#1](#2)#3{{%
% #1: options for \rput[#1]{...}
% #2: absolute coordinates relative to the paper (0,0)
% #3: any object to put at (#1)
\psset{#1}
\pnode(0,0){pst@tempNodeA} % the "cursor" position
\pst@getcoor{pst@Origin}\pst@tempa % Origin of the paper
\pst@getcoor{#2}\pst@tempb % Absolute coordinates
\pst@getcoor{pst@tempNodeA}\pst@tempc % relative coordinates
\pnode(! % Special Coor
/XA \pst@tempa pop \pst@number\psxunit div def
/YA \pst@tempa exch pop \pst@number\psyunit div def
/XB \pst@tempb pop \pst@number\psxunit div def
/YB \pst@tempb exch pop \pst@number\psyunit div def
/XC \pst@tempc pop \pst@number\psxunit div def
/YC \pst@tempc exch pop \pst@number\psyunit div def
XB XC sub XA add
YB YC sub YA add \pst@paperheight\space sub){pst@tempNodeB}
\rput[\psk@abspos@position](pst@tempNodeB){#3}%
}}
%
\catcode`\@=\PstAtCode\relax
%
%% END: pst-abspos.tex
\endinput
|