[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{\match}{*=<3.4ex>[F-]{\txt{\scriptsize{$\hspace{1cm}$}}}}
\newcommand{\matchiii}{*=<3.4ex>[F-]{\txt{\scriptsize{$M_j$}}}}
\newcommand{\matchi}{*=<3.4ex>[F-]{\txt{\tiny{Begin}}}}
\newcommand{\matchii}{*=<3.4ex>[F-]{\txt{\tiny{End}}}}
\newcommand{\delete}{*=<4ex>[o][F-]{\txt{\scriptsize{$D_j$}}}}
\newcommand{\deletei}{*=<4ex>[o][F-]{\txt{\scriptsize{$\hspace{1cm} $}}}}
\newcommand{\inserti}{*=<3ex>[F:<5pt>]{\txt{\scriptsize{$I_j$}}}}
\newcommand{\insertii}{*=<3ex>[F:<5pt>]{\txt{\scriptsize{$\hspace{1cm}$}}}}
\newcommand{\insertix}{*=-<1ex>[F]{\txt{$\hspace{2cm}$\\$\hspace{2cm}$}}}
\newcommand{\diame}{\rotatebox{45}{%
 \frame{\rotatebox{315}{\txt{\scriptsize{$\hspace{0.65cm}$}}}}}}
\newcommand{\diamf}{\rotatebox{45}{%
 \frame{\rotatebox{315}{\txt{\footnotesize{$I_j$}}}}}}

%
%  \diamondframe[6]   for drawing a diamond-shaped frame
%                     around the current <pos>
%
%  (just a quick hack, by Ross Moore  2003/11/6)
%
\newcommand{\diamondframe}[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)
   ,"@f@"+L,{\ar@{#2}"@f@"+U#6}%
 \restore         % return to the saved state
}
% allow the 1st argument to be of variable-length, pre-{
\def\dframe#1#{\diamondframe{#1}}

% redefine these user-commands using the new methods
\renewcommand{\diame}{\txt{\footnotesize\phantom{$I_j$}}%
  \dframe{-}{}{}{}{}}
\renewcommand{\diamf}{\txt{\footnotesize{$I_j$}}%
  \dframe{-}{}{}{}{}}


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