%% $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 %% %% 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 %% %% 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 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}|){||}| \cr |\xyimport(|{\em width}|,|{\em height}|)(|% {\em$x$-off}|,|{$y$-off}|){||}| \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 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 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 s given in the coordinate system for the {\em contents of the }. These are not dimensions, but coordinate-lengths, using the units appropriate to the picture displayed by . 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 . Usually the negatives of these numbers will give the coordinate location of the bottom-left corner of the . 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 and using the supplied {\em width}, {\em height} and offsets. The itself defines named called |"import"|, located at the origin and having appropriate extents to describe the area covered by the . This makes it particularly easy to surround the 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}