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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
%% $Id: xyimport.doc,v 3.6 1998/03/06 01:28:05 krisrose Exp $
%%
%% Xy-pic ``Import feature'' option.
%% Copyright (c) 1993-1997 Ross Moore <ross@mpce.mq.edu.au>
%%
%% This file is part of the Xy-pic package for graphs and diagrams in TeX.
%% See the companion README and INSTALL files for further information.
%% Copyright (c) 1991-1997 Kristoffer H. Rose <krisrose@ens-lyon.fr>
%%
%% The Xy-pic package is free software; you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by the
%% Free Software Foundation; either version 2 of the License, or (at your
%% option) any later version.
%%
%% The Xy-pic package is distributed in the hope that it will be useful, but
%% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
%% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
%% for more details.
%%
%% You should have received a copy of the GNU General Public License along
%% with this package; if not, write to the Free Software Foundation, Inc.,
%% 675 Mass Ave, Cambridge, MA 02139, USA.
%%
\ifx\xyloaded\undefined \input xy \fi
\xyprovide{import}{Import graphics extension}{\stripRCS$Revision: 3.6 $}%
{Ross Moore}{ross@mpce.mq.edu.au}%
{Mathematics Department, Macquarie University, NSW~2109, Australia}
\DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This feature provides the ability to easy add labels and annotations to
graphics prepared outside \TeX\ or \LaTeX. An \Xy-pic graphics environment
is established whose coordinates match that within the contents of the
imported graphic, making it easy to specify exactly where a label should be
placed, or arrow drawn to highlight a particular feature.
\DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph*{Header:}\leavevmode
\DOCHEADER
\DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A command |\xyimport| is defined which is used, in conjunction with
imported graphics, to establish a coordinate system appropriate to the
particular graphics. This enables <pos>itions within the graphic to be easily
located, either for labelling or adding extra embellishing features.
It is used in either of the follow ways:
%
\begin{defs1}
|\xyimport(|{\em width}|,|{\em height}|){|<graphic>|}| \cr
|\xyimport(|{\em width}|,|{\em height}|)(|%
{\em$x$-off}|,|{$y$-off}|){|<graphic>|}|
\end{defs1}
\begin{code}
\def\ellipA{\resizebox{6cm}{!}{%
\includegraphics{import1.eps}}}
\xy
\xyimport(3.7,3.7)(1.4,1.4){\ellipA}*\frm{-}
,!D+<2pc,-1pc>*+!U\txt{%
framed contents of graphics file}\endxy
\qquad\qquad
\xy\xyimport(3.7,3.7)(1.4,1.4){\ellipA}
,!D+<2pc,-1pc>*+!U\txt{Rational points
on the elliptic curve: $x^3+y^3=7$}
,(1,0)*+!U{1},(-1,0)*+!U{-1}
,(0,1)*+!R{1},(0,-1)*+!R{-1}
,(2,-1)*+!RU{P},(-1,2)*+!RU{-P}
,(1.3333,1.6667)*+!UR{-2P}
,(1.6667,1.3333)*!DL{\;2P}
,(-.5,1.9)*++!DL{3P},(1.9,-.5)*!DL{\;-3P}
,(-1,2.3)*+++!D{\infty}*=0{},{\ar+(-.2,.2)}
,(.5,2.3)*+++!D{\infty}*=0{},{\ar+(-.2,.2)}
,(2.3,-1)*+++!L{\infty}*=0{},{\ar+(.2,-.2)}
\endxy
\end{code}
\begin{figure*}[t]
%
% example appears early so it will not float too far away.
%
% Special care needed in case there is no graphics available...
\ifx\includegraphics\undefined \def\resizebox#1#2#3{%
\vbox to6cm{\vss\hbox to6cm{\hss(Picture import1.eps omitted)\hss}\vss}}\fi
$$\docode$$
\caption{importing a graphic for labelling}??=[importing]
\end{figure*}
\noindent
Normally the <graphics> will be a box containing a graphic imported
using the commands from packages such as |graphics|, |epsf| or
|epsfig|, or using other commands provided by the local \TeX\
implementation. However the <graphic> could be {\em any} balanced
\TeX\ material whatsoever; provided it occupies non-zero size, both
vertically and horizontally.
The {\em width} and {\em height} are <number>s given in the coordinate
system for the {\em contents of the <graphics>}. These are not dimensions,
but coordinate-lengths, using the units appropriate to the picture displayed
by <graphic>.
When provided, |(|{\em$x$-off}|,|{$y$-off}|)| give the distance in
coordinate units from bottom-left corner to where the origin of coordinates
should be located, usually within area covered by the <graphic>.
Usually the negatives of these numbers will give the coordinate location
of the bottom-left corner of the <graphic>. If no offsets are supplied
then the origin is presumed to lie at the bottom-left corner.
\DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DOCMODE(
\xydef@\xyimport#1#{\xyimport@{#1}}
\xydef@\xyimport@#1#2{\xydelayimport@{#1}{#2}}
\xydef@\xydelayimport@#1#2{\xy@@ix@{#1{#2}}%
\xy@@{\expandafter\xyextern@\the\toks9}}
\xydef@\xyextern@(#1,#2){\hbox\bgroup\R@c=#1\p@ \U@c=#2\p@\xyextern@i}
\xydef@\xyextern@i#1#{\DN@{#1}%
\ifx\next@\empty \L@c=\z@ \D@c=\z@ \DN@{\xyextern@x}%
\else \DN@{\xyextern@ii#1}\fi \next@ }
\xydef@\xyextern@ii(#1,#2){\L@c=#1\p@ \D@c=#2\p@
\advance\R@c-\L@c \advance\U@c-\D@c \xyextern@x}
\xydef@\xyimportdefault@{3}
\xydef@\xyexportwarning@#1#2#3{\xywarning@{%
#1 for import has zero #2; using \xyimportdefault@#3 default}}
\xydef@\xyextern@x#1{\toks@={\egroup\L@c=}\setboxz@h{#1}%
\dimen@ii=\L@c \advance\dimen@ii\R@c \dimen@=\wdz@
\ifdim\dimen@=\z@ \xyexportwarning@{graphic}{width}{cm}%
\dimen@=\xyimportdefault@ cm\fi
\ifdim\dimen@ii=\z@ \xyexportwarning@{coords}{width}{unit}%
\dimen@ii=\xyimportdefault@\p@\fi
\quotient@\next@\dimen@\dimen@ii \dimen@=\next@\p@
\edef\tmp@{\expandafter\removePT@\the\L@c}\L@c=\tmp@\dimen@
\expandafter\addtotoks@\expandafter{\the\L@c\relax\R@c=}%
\edef\tmp@{\expandafter\removePT@\the\R@c}\R@c=\tmp@\dimen@
\expandafter\addtotoks@\expandafter{\the\R@c\relax\setbase@\z@\z@}%
%
\expandafter\addtotoks@\expandafter{\expandafter{\the\dimen@}\z@\D@c=}%
\dimen@ii=\U@c \advance\dimen@ii\D@c \dimen@=\ht\z@\advance\dimen@\dp\z@
\ifdim\dimen@=\z@ \xyexportwarning@{graphic}{height}{cm}%
\dimen@=\xyimportdefault@ cm\fi
\ifdim\dimen@ii=\z@ \xyexportwarning@{coords}{height}{unit}%
\dimen@ii=\xyimportdefault@\p@\fi
\quotient@\next@\dimen@\dimen@ii \dimen@=\next@\p@
\edef\tmp@{\expandafter\removePT@\the\D@c}\D@c=\tmp@\dimen@
\expandafter\addtotoks@\expandafter{\the\D@c\relax\U@c=}%
\edef\tmp@{\expandafter\removePT@\the\U@c}\U@c=\tmp@\dimen@
\expandafter\addtotoks@\expandafter{\the\U@c\relax\setbase@@\z@}%
\expandafter\addtotoks@\expandafter{\expandafter{\the\dimen@}}%
%
\setboxz@h{\kern-\L@c\lower\D@c\boxz@\kern\L@c}%
\wd\z@=\z@ \ht\z@=\z@ \dp\z@=\z@ \boxz@ \the\toks@ \X@c=\z@ \Y@c=\z@
\ifdim\X@min>-\L@c \X@min=-\L@c \fi \ifdim\X@max<\R@c \X@max=\R@c \fi
\ifdim\Y@min>-\D@c \Y@min=-\D@c \fi \ifdim\Y@max<\U@c \Y@max=\U@c \fi
\idfromc@{import}\POS }
\DOCMODE)
\DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Normally the |\xyimport| command is used at the beginning of an |\xy..\endxy|
environment. It is not necessary to give any basis setup, for this is
deduced by measuring the dimensions of the <graphic> and using the supplied
{\em width}, {\em height} and offsets.
The <graphic> itself defines named <pos> called |"import"|, located at the
origin and having appropriate extents to describe the area covered by
the <graphic>. This makes it particularly easy to surround the <graphic>
with a frame, as on the left side of figure~??[importing],
or to draw axes passing through the origin.
% Special care needed in case there is no graphics available...
\ifx\includegraphics\undefined \def\resizebox#1#2#3{%
\vbox to6cm{\vss\hbox to6cm{\hss(Picture import1.eps omitted)\hss}\vss}}\fi
Here is the code used to apply the labelling in figure~??[importing]:
\displaycode
This example uses the \LaTeXe\ standard |graphics| package to import
the graphics file |import1.eps|; other packages could have been used
instead. e.g. |epsfig|, |epsf|, or the \expandafter|\string\picture|
or \expandafter|\string\illustration| commands in \Textures\ on the
Macintosh.
The only possible problems that can occur are when the graphics package is
loaded after \Xy-pic has been loaded. Generally it is advisable to have
\Xy-pic loading {\em after} all other macro packages.
\DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph*{The end \& Log}\leavevmode
\DOCMODE(
\xyendinput
% $Log: xyimport.doc,v $
% Revision 3.6 1998/03/06 01:28:05 krisrose
% Releasing (with Y&Y fonts).
%
% Revision 3.4 1997/05/18 01:13:24 ross
% Essential bugfixes.
%
% Revision 3.3 1996/12/18 09:19:22 ross
% no changes
%
% Revision 3.1 1995/09/05 20:36:33 ross
% Release!
%
% Revision 3.0 1995/07/07 20:13:19 ross
% Major release w/new User's Guide!
%
% Revision 2.14 1995/07/05 22:10:51 kris
% Buglets...
%
% Revision 2.13 1995/07/04 15:04:51 ross
% Ready for release of v3.
%
%
% NEW for version 3.0 by by Ross Moore.
\DOCMODE)
\DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput
$$
\xy\xyimport(37,37)(18,18){\ellB}
,!D+<1pc,-1pc>*+!U\txt{Rational points
on the elliptic curve: $x^3+y^3=1729$}
,(10,0)*+!U{10},(-10,0)*+!U{-10}
,(0,10)*+!R{10},(0,-10)*+!R{-10}
,(1,12)*+!DL{P_1}
,(12,1)*+!DL{-P_1=(12\,,1)}
,(10,9)*!LD{\;\;\;P_2=(10\,,9)}
,(9,10)*++!D{\;\;-P_2}
,(-15.5,17.5)*+!DL{-P_1-P_2}
,(17.5,-15.5)*+!DL{P_1+P_2}
,(13,-7)*+!UR{-2P_1-P_2\;\;}
,(18,-3)*+++!L{\infty}*=0{},{\ar+(2,-2)}
,(3,18)*+++!D{\infty}*=0{},{\ar+(-2,2)}
\endxy
$$
\end{document}
|