[Xy-pic] diamond-shaped frames

Ross Moore ross at ics.mq.edu.au
Thu Nov 6 00:09:14 CET 2003

Hello Maja,

On Fri, 31 Oct 2003, Maja Karaga wrote:

> Dear all,
> I somehow got stuck with the problem of obtaining diamond-shaped frames
> inside the \xymatrix command.

Below is a revised version of your code example, with a new command
 \diamondframe  allowing for 6 useful parameters, including
labels on each of the 4 sides of the diamond.
Also, a shorter \dframe version that is easier to type.

However, you may find it easier to use \xygraph than \xymatrix
for this kind of diagram, since your diamond frames are not really
frames in the Xy-pic sense (i.e. your frames are part of the
picture, determining where arrows start and finish; normally
Xy-pic frames are just decorations around <object>s).

Using \xymatrix it is a lot harder to use Xy-pic placed <object>s
to determine the end-points of arrows, as these are normally determined
from the size of the textual contents of the matrix cells.

On the other hand, using \xygraph an drawing the diamonds, with the
help of a macro or "graph-escape", you can name the corners of the
diamond more easily, for later use as targets of arrows.

> ....  For now, the only solution I've came up with
> is following:

Here's the modified code --- including, but over-riding, your
original macro definitions.

\newcommand{\deletei}{*=<4ex>[o][F-]{\txt{\scriptsize{$\hspace{1cm} $}}}}

%  \diamondframe[6]   for drawing a diamond-shaped frame
%                     around the current <pos>
%  (just a quick hack, by Ross Moore  2003/11/6)
  \save           % save the current state
    c!C           % center on the current <pos>
   ,*#1+=\frm{}%  % drop empty frame with modifiers, equalized
    ="@f@"        % name it
   ,"@f@"+U,{\ar@{#2}"@f@"+R#3}%   draw each side, allowing labels
   ,"@f@"+R,{\ar@{#2}"@f@"+D#4}%  (could be more efficiently done
   ,"@f@"+D,{\ar@{#2}"@f@"+L#5}%    as a single \PATH)
 \restore         % return to the saved state
% allow the 1st argument to be of variable-length, pre-{

% redefine these user-commands using the new methods

Back to the original example, modified for the new methods

\xymatrix@!=1.7pc{ & \deletei \ar[d] \ar[r] \ar[ddr]
  & \delete\dframe++{-}{^a}{^b}{^c}{^d} \ar[d]
\ar[r] \ar[ddr] & \deletei\dframe++{-}{}{}{}{} \ar[d] \ar[ddr] & \\
          \diame &  \diame  & \diamf & \diame & & \\
          \matchi \ar[u] \ar[r] \ar[uur] & \match \ar[u] \ar[r] \ar[uur] &
\matchiii \ar[u] \ar[r] \ar[uur]& \match \ar[u]\ar[r]& \matchii \\

> which is not satisfactory from obvious reasons (for one, it works properly
> only in .ps version, so please convert to .ps to see results.)

It also worked with PDF, via pdflatex, since the rotations are
implemented with the {graphics} package.

However, with my macros above, you don't need \rotatebox anymore.

> I would appreciate any help or suggestions.

All the best,

	Ross Moore

> Thanks,
> Maja
> M. Karaga,
> Department of Mathematics,
> University of Zagreb
> _______________________________________________
> xy-pic mailing list
> http://tug.org/mailman/listinfo/xy-pic

More information about the xy-pic mailing list