分类
LaTeX

如何画 Quiver

Quiver Example

\begin{mpdefs}
u=10pt;
vardef pst(expr labdr)=
 begingroup
  os:=.7u;
  pair odr;
  if (labdr="u") :  odr:=os*up; fi;
  if (labdr="d") :  odr:=os*down; fi;
  if (labdr="l") :  odr:=os*left; fi;
  if (labdr="r") :  odr:=os*right; fi;
 endgroup;
 odr
enddef;

vardef quiver(expr P, Q, labP, labQ, labPQ, pstP, pstQ) =
 begingroup
  os:=0.3u;
  pair dr;
  dr:=unitvector(Q-P);

  pickup pencircle scaled 1pt;
  drawarrow P+os*dr--Q-os*dr;

  pickup pencircle scaled 1pt;
  label(btex $\circ$ etex, P);
  label(labP, pst(pstP)+P);
  label(btex $\circ$ etex,Q);
  label(labQ, pst(pstQ)+ Q);
  label (labPQ, os*(dr rotated 90)+(P+Q)/2);
 endgroup;
enddef;
\end{mpdefs}

  this is a test \begin{mpdisplay}
    z1=origin;
    z2=3u*(down+right);
    z3=z2+3u*(left+down);
    z4=z3+6u*(up+left);
    quiver(z1,z2,"1","2", btex $\alpha_1$ etex, "u", "r");
    quiver(z2,z3,"2","3", btex $\alpha_2$ etex, "r", "d");
    quiver(z3,z4,"3","4", btex $\alpha_3$ etex, "d", "l");
    quiver(z4,z1,"4","1", btex $\alpha_4$ etex, "l", "u");
  \end{mpdisplay} 
  and this is not right

This is just a basic idea, after a while, I find the following complete package METAGRAPH.

发表回复

您的电子邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据