# [Xy-pic] Problem with skewing(?)

Richard Lewis xypic at rtf.org.uk
Thu Apr 8 01:32:43 CEST 2004

Ross Moore <ross at ics.mq.edu.au> writes:

> Hello Richard,
>
> On 24/03/2004, at 9:58 PM, Richard Lewis wrote:
>
>> Hi everyone,
>>
>> I am trying to define a command \SliceObj (that will take three
>> arguments: top, label and bottom) to typeset a vertical arrow,
>> framed  with parentheses (...),
>> whose reference point should be the middle of the label.
>>
>> Something like
>>
>>    /       \
>>   |  {#1}   |
>>   |   |     |
>>   |   |{#2} |
>>   |   |     |
>>   |   V     |
>>   |  {#3}   |
>>    \       /
>>
>> with the reference in the middle of {#2}
>>

> Provided that I understand correctly what you are trying to do,
> I find 3 "errors" in your coding...
>
>> \newcommand{\SliceObj}[3]{%
>>   %%% vertical arrow: #1=source, #2=target, #3=LABEL
>>   %% 1. c is where we start.  We draw an arrow starting 0.6cm above
>> c,  and
>>   %%    ending 0.6cm under c.
>>   \POS+<0cm,0.6cm>*+{#1}="TOP"+<0cm,-1.2cm>*+{#3}="BASE"
>>   \POS\ar"TOP";"BASE"^-{#2}="LABEL"
>>   %% 2. join all 3 bits together, reference is at "LABEL"
>>   \POS"LABEL"."TOP"."BASE"
>>   %% 3. add brackets (' and )' around the joined thing
>>   *\frm{(}*\frm{)}="joined-thing",
>>   %% 4. Add margin, using !C to ensure we get equal space all around
>> the
>>   %%    joined-thing
>>   %%    [I am using *+\frm{.} so we can see where the object at
>>   %%    "SOBJ-with-margin" extends to---when i get \SliceObj to work i
>>   %%    will want to use *+\frm{}, to get a margin (but no frame)]
>>   "joined-thing"!C*+\frm{.}="SOBJ-with-margin",
>>   %% 5. now set the reference point
>>   "SOBJ-with-margin"*{\circ},        %we are here before skew
>>   "joined-thing"*{\oplus},           %want reference to be here
>>   %% try and skew reference of SOBJ-with-margin to joined-thing
>>   "SOBJ-with-margin"!"joined-thing"="here"*{\otimes},
>       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------- see below
>>   "here"                             %here is where our reference ended
>> }
>
>
> Firstly:
>
>    %% try and skew reference of SOBJ-with-margin to joined-thing
>     "joined-thing"."SOBJ-with-margin"="here"*{\otimes},
>      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Doesn't this do what you want ?

aha! that does indeed get the \otimes into the place i wanted it,
thanks very much.

Ah...in the refernece manual, it says (table on page 8) that you can do

<POS>!<COORD>

and <COORD> can be "<ID>", according to the table on page 8.  Should
it say

<POS>!<VECTOR>

[When i try
\begin{xy}
0;<2cm,0pc>:<0pc,2cm>::0,
0*{0},
(1,1)*+{\oplus}="ref",
(0,2)*+{\Omega}="omega",
"omega"!"ref"*{Z}
\end{xy}

It puts the Z at (1,3), which is "omega" shifted by the vector (1,1),
rather than at (1,1) which the manual seems to suggest

>
> The reference point of a merged object is at the coords
> of the reference-point of the 1st <POS> in the merge.
>
> The skew (!) operator is not the appropriate thing for
> merging different <POS>s. It is for shifting the base-point
> within a given <POS>.
>
>
> Now the \otimes and \oplus should coincide for each of
> your SOBJs.  --- call these the  (x+)-points.

yes indeed, thanks very much

>
>>
>> %\sobj gives a stand alone' \SliceObj
>> \newcommand{\sobj}[3]{\xygraph{[]!{\SliceObj{#1}{#2}{#3}}}}
>>
>
> Secondly:
>
> While this \SliceObj is a valid command for adding to
> an Xy-pic diagram, it does not create just a single <object>.
>
> To make a single <object>, with your current approach,
> you need a slight modification, using \xybox :
>
> \newcommand{\SliceObj}[3]{\drop\xybox{%
>    ....
>    ....
>     }%  end of \xybox
> }%  end of \SliceObj
>

AHA! (this one i can't blame on the manual!)

>
>> \section{More complicated Diagrams}
>> More complicated diagram: We \emph{should} get a corner' and then $x$
>> and $y$ on top of each other in the bottom-left position\ldots
>
> This doesn't happen because the <POS> before your [d] hop
> is further to the right than you want it to be, since
> \SliceObj  has placed several <object>s, at different places.
>
> Using \xybox, so that there is just one compound <object>
> placed, you now get the 'x' and 'y' coinciding.

yep

>
>
> However, the place where they coincide may not be where
> you want them to be...
>
> ... that is, the arrows between your SOBJs do not
> emanate from the (x+)-points, and the 'xy' does
> not align with the  (x-)-points.
>
>
> Thirdly:
>
>    the \xybox  does not allow control over *where*,
> inside the <object> that it builds,
> the reference point is to be located.
>
> Accordingly, I've just devised a variant that builds
> the same kind of compound <object>, but also sets
> its reference-point to be at the <coord> of the
> last <POS> within the box; i.e., the <coord> for
> the <object> that has been built is at the current
> <POS> when the Xy-pic parsing has been completed.
> The LRUD extents are the size of the complete box;
> i.e., *not* the extents of the final <POS>.
>
> Here is coding that should go in your document's
> preamble -- eventually it should be added to  xy.tex
>

<snip definition of \xyobjbox>

Thanks very much, i have been experimenting with \xyobjbox  and it is
very useful for several things

> Now, if your definition starts:
>
>    \newcommand{\SliceObj}[3]{\drop\xyobjbox{%
>                              ^^^^^^^^^^^^^^
>
> then you should get the correct (?) alignments.
>

yep, thanks very much