&*+{\sum_{i=n}^m {i^2}} &*+{+}&*+{p} \\
& {\bullet} & D \ar[ul] && f \ar[ul]

i want to reduce the spacing between terms and different colors for arrows.i'm using kile under ubuntu.is it necessary to include tiKZ ,if so explain me


I would recommend using tikz rather than xy. Here's how I would think of implementing this. (The following was adapted from this TeXample.net example, with an eye towards code abstraction; the picture in the original is also fancier.)



% Define how TiKZ will draw the nodes
\tikzstyle{every picture}+=[remember picture]


% Designate a term in a math environment to point to
% Syntax: \mathterm[node label]{some math}
   \tikz [baseline] { \node [mathterm] (#1) {$#2$}; }}

% A command to draw an arrow from the current position to a labelled math term
% Default color=black, default arrow head=stealth
% Syntax: \indicate[color]{term to point to}[path options]
   \tikz [baseline] \node [inner sep=0pt,anchor=base] (i#2) {\vphantom|};
   {\color{#1} \tikz[overlay] \path[line width=1pt,draw=#1,-stealth] (i#2) edge (#2);}}
   {\color{#1} \tikz[overlay] \path[line width=1pt,draw=#1,-stealth] (i#2) [#3] edge (#2);}}


Document body:

   \mathterm[t1]{   \sum_{i=n}^m {i^2}   }   +
   \mathterm[t2]{   \int_0^t \mathrm d\:\!\tau   }   +
   \Gamma\bigl(n + \tfrac{1}{2}\bigr)   + 
   \mathterm[t3]{   \tfrac{1}{2}m\|\mathbf v\|^2   }

   \item  Power series \indicate[red]{t1}[out=0,in=-75]
   \item  Definite integral \indicate[blue]{t2}[out=0,in=-90]
   \item  Non-relativistic kinetic energy \indicate{t3}[out=0,in=-90]

Result: equation with boxed and indicated terms

  • environment gather undefined – user4852 Apr 13 '11 at 16:23
  • Ah, sorry, you must also \usepackage{amsmath}. I'll add that to the pre-amble above. Note that gather is just one of my preferred choices of math environments; any other displayed math environment would do here, although the AMS ones are better as a rule. – Niel de Beaudrap Apr 13 '11 at 16:25
  • oh..again problem.arrows are not visible.i'm using kile under ubuntu – user4852 Apr 13 '11 at 16:37
  • 1
    @Niel: if instead of using the <pre> tag, you use the code environment provided by markdown (indent all your code by 4 extra spaces, or select them and hit the "code symbol" in the editor), you can benefit from syntax highlighting for your code example. – Willie Wong Apr 13 '11 at 18:32
  • 1
    @user4852: if you say so — the editor really shouldn't make any difference. – Niel de Beaudrap Apr 14 '11 at 7:38

An example with overlays

\def\VPh{\vphantom{\displaystyle\sum_{i=n}^m {i^2}}}


   \only<1->{\rnode{t1}{\psBox{green!30}{\sum_{i=n}^m {i^2}}} +} 
   \only<2->{\rnode{t2}{\psBox{blue!30}{\int_0^t \mathrm d\:\!\tau}} + 
             \Gamma\bigl(n +\frac{1}{2}\bigr)+ }
   \only<3->{\rnode{t3}{\psBox{red!30}{\frac{1}{2}m\|\mathbf v\|^2}}}

   \item  Power \rnode[rc]{T1}{series} \nccurve[angleB=-75]{T1}{t1}
   \item  Definite \rnode[rc]{T2}{integral}\nccurve[angleB=-90]{T2}{t2} 
   \item  Non-relativistic kinetic \rnode[rc]{T3}{energy}\nccurve[angleB=-90]{T3}{t3}


enter image description here


If you like to use Xy-pic, simply omit the "+" :

& *{\sum_{i=n}^m {i^2}} & + & *{p} \\
& {\bullet} & D \ar@[red][ul] && f \ar@[blue][ul]

Indeed, the construction *{object} put the object without margin, the "+" add the margin. In fact, *+{object} is equivalent to {object} and even (if the object doesn't start with a macro) simply object .

For the color, simply use the @[color] modifier, for more about color, see xyref p.30.

Another solution is to define directly "longarrow", for example :

\def\longar@[#1][#2]{\ar@[#1]@{-l}[#2] \ar@[#1]@{m-m}[#2]}
&{\sum_{i=n}^m {i^2}} &+&p \\
& {\bullet} & D \longar@[red][ul] && f \longar@[blue][ul]
  • color is not changing – user4852 Apr 14 '11 at 1:25
  • @user4852 short way : normally it does. Long way, if you want color you have to use the package color but the beamer class (at least in recent version) automatically load this package. – Matsaya Apr 14 '11 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.