是否可以用箭头装饰矩形?我用过:
\node [draw,rectangle,minimum width=4cm,minimum height=4cm](r){};
但是,要将边缘对齐以使其与矩形边缘齐平确实非常困难,有没有更简单的方法?我希望它看起来像:
答案1
您的矩形是node
。因此,您可以在其锚点处放置一个箭头形节点,如south
和east
。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows}
\tikzset{
myarrow/.style={
draw,thick,
single arrow,
text width=1cm,
fill=white
},
}
\begin{document}
\begin{tikzpicture}
\node [draw,rectangle,minimum size=4cm](r){};
\node[myarrow,rotate=90] at (r.east){};
\node[myarrow] at (r.south){};
\end{tikzpicture}%
\end{document}
有关修改箭头的形状,您可以参考pgfmanual
第 725 页第 67.5 节的形状single arrow
。
答案2
这是一个简单的元帖子方法。
prologues := 3;
outputtemplate := "%j%c.eps";
ad_phi = 1/2;
ad_rho = 7/8;
% return the path of an arrow scaled to size "s" at time "t" on path "p"
vardef arrow_decor(expr s, t, p) =
save a; path a;
a = ((1,0) -- (0,ad_rho) -- (0,ad_phi) -- (-1,ad_phi)
-- (-1,-ad_phi) -- (0,-ad_phi) -- (0,-ad_rho) -- cycle)
scaled 1/2 s
rotated angle direction t of p
shifted point t of p;
unfill a;
a
enddef;
beginfig(1);
path R;
R = unitsquare xscaled 55 yscaled 34;
draw R;
for t = 1/2 step 1 until 4:
draw arrow_decor(8, t, R);
endfor
endfig;
end.
调整ad_rho
和来控制箭头的形状。或者只需更改宏中ad_phi
的定义即可。a