在图中,箭头未到达孩子上侧的中间

在图中,箭头未到达孩子上侧的中间

使用tikzpicture,我希望箭头的长度能够自动调整,以便箭头始终到达每个子元素上侧的中间。目前,我在以下 MWE 中具有固定长度。具体来说,在这个例子中,我希望指向“child1”和“child3”的箭头的长度能够自动调整到子元素上侧的中间。提前致谢。

\documentclass{beamer}
\mode<presentation>{\usetheme{Madrid}}


\usepackage[style=verbose]{biblatex}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\tikzset{startstop/.style = {rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30}}
\tikzset{io/.style = {trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30}}
\tikzset{process/.style = {rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30}}
\tikzset{decision/.style = {diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30}}
\tikzset{arrow/.style = {thick,->,>=stealth}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title[tikzpicture with beamer]{}

\begin{document}
\begin{frame}{tikzpicture}{}
\begin{tikzpicture}[node distance=3cm]

\node (root) [process] {root};
\node (child1) [process, below of=root, xshift=-4cm] {child1};
\draw [arrow] (root) -- (child1);

\node<+(1)-> (child2) [process, below of=root, xshift=0cm] {child2};
\draw<.(1)-> [arrow] (root) -- (child2);


\tikzset{process/.style = {rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=blue!30}}
\node<+(1)-> (child3) [process, below of=root, xshift=4cm] {child3};
\draw<.(1)-> [arrow] (root) -- (child3);


\end{tikzpicture}   

\end{frame}

\end{document}

答案1

对于要进入节点的箭头,只需指定(child1.north)等。

像这样?

截屏

\documentclass{beamer}
\mode<presentation>{\usetheme{Madrid}}


\usepackage[style=verbose]{biblatex}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\tikzset{startstop/.style = {rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30}}
\tikzset{io/.style = {trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30}}
\tikzset{process/.style = {rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30}}
\tikzset{decision/.style = {diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30}}
\tikzset{arrow/.style = {thick,->,>=stealth}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title[tikzpicture with beamer]{}

\begin{document}
\begin{frame}{tikzpicture}{}
\begin{tikzpicture}[node distance=3cm]

\node (root) [process] {root};
\node (child1) [process, below of=root, xshift=-4cm] {child1};
\draw [arrow] (root) -- (child1.north);

\node<+(1)-> (child2) [process, below of=root, xshift=0cm] {child2};
\draw<.(1)-> [arrow] (root) -- (child2.north);


\tikzset{process/.style = {rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=blue!30}}
\node<+(1)-> (child3) [process, below of=root, xshift=4cm] {child3};
\draw<.(1)-> [arrow] (root) -- (child3.north);


\end{tikzpicture}   

\end{frame}

\end{document}

相关内容