TransWikia.com

In a diagram, the arrow that does not reach the middle of the child's upper side

TeX - LaTeX Asked on October 5, 2021

Using tikzpicture, I want the length of the arrows to be self-adjusting so that the arrows always arrive in the middle of each child’s upper side. Currently I have fixed length in the following MWE. Specifically in this example, I would like the length of the arrows going to "child1" and "child3" to be adjusted automatically to come to the middle of the child’s top side. Thanks in advance.

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}

One Answer

For the arrows to enter nodes, simply specify (child1.north) and so on.

Like this?

screenshot

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}

Correct answer by AndréC on October 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP