\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows,positioning,shapes,arrows,decorations.markings,arrows.meta}
\tikzset{
box/.style={draw,fill=white,rectangle,minimum size=2.5cm,align=center},
diatostealth/.style={draw,{Diamond}-{Stealth}}
}
\begin{document}
\begin{tikzpicture}
\node[box](a){a};
\node[box, below left=1.5cm of a](b){b};
\node[box, below right=1.5cm of a](c){c};
% the arrows
\path[diatostealth] (a.south) -- (b.north){};
\path[diatostealth] (a.south) -- (c.north){};
\end{tikzpicture}
\end{document}
这就是我目前所拥有的。
这就是我想要实现的。
答案1
您可以使用中间坐标。因此,左侧的线可以通过以下方式实现:
\path[diatostealth, thick]
(a.south)
-- ++(0,-0.5cm)
-| (b.north)
;
方法:
- 開始於
(a.south)
。 - 表示最后一个点下方的
++
坐标,-0.5cm
- 该
-|
方法先画一条水平线,然后再画一条垂直线到该点(b.north)
。
代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows,positioning,shapes,arrows,decorations.markings,arrows.meta}
\tikzset{
box/.style={draw,fill=white,rectangle,minimum size=2.5cm,align=center},
diatostealth/.style={draw,{Diamond}-{Stealth}}
}
\begin{document}
\begin{tikzpicture}
\node[box](a){a};
\node[box, below left=1.5cm of a](b){b};
\node[box, below right=1.5cm of a](c){c};
% the arrows
\path[diatostealth, thick]
(a.south)
-- ++(0,-0.5cm)
-| (b.north)
;
\path[diatostealth, thick]
(a.south)
-- ++(0,-0.5cm)
-| (c.north){};
\end{tikzpicture}
\end{document}
答案2
如果它看起来像一棵树,那它应该是一棵forest
……
\documentclass[tikz,border=12pt,mult,varwidth]{standalone}
\usepackage{forest,amssymb}
\usetikzlibrary{shadows,arrows.meta}
\begin{document}
\tikzset{
my shadow/.style={drop shadow={shadow xshift=.25ex, shadow yshift=-.25ex}}
}
\begin{forest}
for tree={
draw,
parent anchor=south,
child anchor=north,
fill=white,
my shadow,
minimum width=20pt,
text height=7.5pt,
font=\sffamily,
edge path={
\noexpand\path [-{Stealth[]}, \forestoption{edge}] (!u.parent anchor) node [inner sep=0pt, anchor=north, outer sep=0pt, scale=.5] {$\blacklozenge$} -- +(0,-5pt) -| (.child anchor)\forestoption{edge label};
},
}
[a
[b]
[c]
]
\end{forest}