TeX - LaTeX Asked by user136555 on January 15, 2021
I would appreciate an advice on how to change the distance between two given nodes in a TikZ picture. Here is my working example:
documentclass[oneside,a4paper,12pt]{report}
usepackage{polyglossia}
usepackage{microtype}
setmainlanguage{english}
usepackage{vmargin}
setmarginsrb{3cm}{3cm}{3cm}{3cm}{0pt}{0mm}{0pt}{13mm}
usepackage{tikz}
usetikzlibrary{positioning, shapes.geometric, shapes.misc}
tikzstyle{arrow} = [very thick,->,>=stealth]
begin{document}
begin{tikzpicture}[node distance=1cm,
stage/.style={
% The shape:
rounded rectangle,
minimum width=3cm,
minimum height=1cm,
text centered,
text width=6cm,
% The rest
very thick,draw=black!50,
top color=white,bottom color=black!20,
font=bfseries}]
node (node1) [stage] { Some text in Node1};
node (node2) [stage, below=of node1] {More text in Node 2!};
draw [arrow] (node1) -- (node2);
node (node3) [stage, right=of node2] {Text for node 3.};
draw [arrow] (node2) -- (node3)
node [above,align=center,midway]
{replacement text here
};
end{tikzpicture}
end{document}
I would like to keep 1cm distance between node 1 and node 2, however, I would like to increase distance between node 2 and node 3 to accommodate text, which I would like to place above the arrow.
Thank you!
documentclass[oneside,a4paper,12pt]{report}
usepackage{polyglossia}
usepackage{microtype}
setmainlanguage{english}
usepackage{vmargin}
setmarginsrb{3cm}{3cm}{3cm}{3cm}{0pt}{0mm}{0pt}{13mm}
usepackage{tikz}
usetikzlibrary{positioning, shapes.geometric, shapes.misc}
tikzstyle{arrow} = [very thick,->,>=stealth]
begin{document}
begin{tikzpicture}[node distance=1cm,
stage/.style={
% The shape:
rounded rectangle,
minimum width=3cm,
minimum height=1cm,
text centered,
text width=6cm,
% The rest
very thick,draw=black!50,
top color=white,bottom color=black!20,
font=bfseries}]
node (node1) [stage] { Some text in Node1};
node (node2) [stage, below=of node1] {More text in Node 2!};
draw [arrow] (node1) -- (node2);
node (node3) [stage, right=4cm of node2] {Text for node 3.};
draw [arrow] (node2) -- (node3)
node [above,align=center,midway]
{replacement text here
};
end{tikzpicture}
end{document}
Correct answer by js bibra on January 15, 2021
An alternative ...
documentclass[oneside,a4paper,12pt]{report}
usepackage{polyglossia}
usepackage{microtype}
setmainlanguage{english}
usepackage{vmargin}
setmarginsrb{3cm}{3cm}{3cm}{3cm}{0pt}{0mm}{0pt}{13mm}
usepackage{tikz}
usetikzlibrary{positioning, quotes, shapes.misc}
begin{document}
begin{tikzpicture}[
node distance = 1cm and 3cm,
stage/.style = {
% The shape:
rounded rectangle, align=center,
minimum height=1cm, text width=5.4cm,
% The rest
very thick, draw=black!50,
top color=white, bottom color=black!20,
font=bfseries},
arr/.style = {very thick,-stealth},
every edge quotes/.append style = {font=small, align=center},
]
node (node1) [stage] {Some text in Node1};
node (node2) [stage, below=of node1] {More text in Node 2!};
draw [arr] (node1) -- (node2);
node (node3) [stage, right=of node2] {Text for node 3.};
draw [arr] (node2) to["replacement text here"] (node3);
end{tikzpicture}
end{document}
Answered by Zarko on January 15, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP