Tikz: creating nodes from a list and adjusting path start position
up vote
3
down vote
favorite
As part of a larger diagram I've written the following, which does basically what I want:
documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[box/.style={rectangle,draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (ReadQueryParametersJSON) at (0,0) {ReadQueryParametersJSON};
node[box] (ParseParametricLine) [below=of ReadQueryParametersJSON,anchor=west,xshift=-1cm] {ParseParametricLine};
node[box] (ReadJSONFile) [below=of ParseParametricLine.west,anchor=west] {ReadJSONFile};
node[box] (GUIMapping) [below=of ReadJSONFile.west,anchor=west] {GUIMapping};
path [->] (node cs:name=ReadQueryParametersJSON,angle=-169.69) edge [vh path] (GUIMapping)
(node cs:name=ReadQueryParametersJSON,angle=-168.69) edge [vh path] (ReadJSONFile)
(node cs:name=ReadQueryParametersJSON,angle=-167.47) edge [vh path] (ParseParametricLine);
%node[box] (root) at (0,-4) {root};
%foreach name in {aa,bb,cc,dd}
% node[box] (name) at ++(0,-1) {name};
end{tikzpicture}
end{document}
The only mechanism I could find to offset the starting point for the arrows was to use the angle, which means that for even spacing, the parameter depends on the arctan and the dimensions of the box. That's sort of complicated. Is there a better way?
I need to make a structure like this several times, so I tried write a loop to generate this structure automatically, starting with the code that is commented out. This code places the root node down at (1,-4) and all of the listed nodes on top of each other at the absolute location (1,-1) even though I used ++ to get relative location. Why doesn't this work? How can I write this loop (without absolute coordinates so that the child nodes are positioned relative to the parent)?
tikz-pgf
New contributor
Adrian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
3
down vote
favorite
As part of a larger diagram I've written the following, which does basically what I want:
documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[box/.style={rectangle,draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (ReadQueryParametersJSON) at (0,0) {ReadQueryParametersJSON};
node[box] (ParseParametricLine) [below=of ReadQueryParametersJSON,anchor=west,xshift=-1cm] {ParseParametricLine};
node[box] (ReadJSONFile) [below=of ParseParametricLine.west,anchor=west] {ReadJSONFile};
node[box] (GUIMapping) [below=of ReadJSONFile.west,anchor=west] {GUIMapping};
path [->] (node cs:name=ReadQueryParametersJSON,angle=-169.69) edge [vh path] (GUIMapping)
(node cs:name=ReadQueryParametersJSON,angle=-168.69) edge [vh path] (ReadJSONFile)
(node cs:name=ReadQueryParametersJSON,angle=-167.47) edge [vh path] (ParseParametricLine);
%node[box] (root) at (0,-4) {root};
%foreach name in {aa,bb,cc,dd}
% node[box] (name) at ++(0,-1) {name};
end{tikzpicture}
end{document}
The only mechanism I could find to offset the starting point for the arrows was to use the angle, which means that for even spacing, the parameter depends on the arctan and the dimensions of the box. That's sort of complicated. Is there a better way?
I need to make a structure like this several times, so I tried write a loop to generate this structure automatically, starting with the code that is commented out. This code places the root node down at (1,-4) and all of the listed nodes on top of each other at the absolute location (1,-1) even though I used ++ to get relative location. Why doesn't this work? How can I write this loop (without absolute coordinates so that the child nodes are positioned relative to the parent)?
tikz-pgf
New contributor
Adrian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
As part of a larger diagram I've written the following, which does basically what I want:
documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[box/.style={rectangle,draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (ReadQueryParametersJSON) at (0,0) {ReadQueryParametersJSON};
node[box] (ParseParametricLine) [below=of ReadQueryParametersJSON,anchor=west,xshift=-1cm] {ParseParametricLine};
node[box] (ReadJSONFile) [below=of ParseParametricLine.west,anchor=west] {ReadJSONFile};
node[box] (GUIMapping) [below=of ReadJSONFile.west,anchor=west] {GUIMapping};
path [->] (node cs:name=ReadQueryParametersJSON,angle=-169.69) edge [vh path] (GUIMapping)
(node cs:name=ReadQueryParametersJSON,angle=-168.69) edge [vh path] (ReadJSONFile)
(node cs:name=ReadQueryParametersJSON,angle=-167.47) edge [vh path] (ParseParametricLine);
%node[box] (root) at (0,-4) {root};
%foreach name in {aa,bb,cc,dd}
% node[box] (name) at ++(0,-1) {name};
end{tikzpicture}
end{document}
The only mechanism I could find to offset the starting point for the arrows was to use the angle, which means that for even spacing, the parameter depends on the arctan and the dimensions of the box. That's sort of complicated. Is there a better way?
I need to make a structure like this several times, so I tried write a loop to generate this structure automatically, starting with the code that is commented out. This code places the root node down at (1,-4) and all of the listed nodes on top of each other at the absolute location (1,-1) even though I used ++ to get relative location. Why doesn't this work? How can I write this loop (without absolute coordinates so that the child nodes are positioned relative to the parent)?
tikz-pgf
New contributor
Adrian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
As part of a larger diagram I've written the following, which does basically what I want:
documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[box/.style={rectangle,draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (ReadQueryParametersJSON) at (0,0) {ReadQueryParametersJSON};
node[box] (ParseParametricLine) [below=of ReadQueryParametersJSON,anchor=west,xshift=-1cm] {ParseParametricLine};
node[box] (ReadJSONFile) [below=of ParseParametricLine.west,anchor=west] {ReadJSONFile};
node[box] (GUIMapping) [below=of ReadJSONFile.west,anchor=west] {GUIMapping};
path [->] (node cs:name=ReadQueryParametersJSON,angle=-169.69) edge [vh path] (GUIMapping)
(node cs:name=ReadQueryParametersJSON,angle=-168.69) edge [vh path] (ReadJSONFile)
(node cs:name=ReadQueryParametersJSON,angle=-167.47) edge [vh path] (ParseParametricLine);
%node[box] (root) at (0,-4) {root};
%foreach name in {aa,bb,cc,dd}
% node[box] (name) at ++(0,-1) {name};
end{tikzpicture}
end{document}
The only mechanism I could find to offset the starting point for the arrows was to use the angle, which means that for even spacing, the parameter depends on the arctan and the dimensions of the box. That's sort of complicated. Is there a better way?
I need to make a structure like this several times, so I tried write a loop to generate this structure automatically, starting with the code that is commented out. This code places the root node down at (1,-4) and all of the listed nodes on top of each other at the absolute location (1,-1) even though I used ++ to get relative location. Why doesn't this work? How can I write this loop (without absolute coordinates so that the child nodes are positioned relative to the parent)?
tikz-pgf
tikz-pgf
New contributor
Adrian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Adrian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Adrian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 5 hours ago
Adrian
161
161
New contributor
Adrian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Adrian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Adrian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
If I understood your question correctly, you can use the above of= key in this way:

documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[
box/.style={draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (root) at (0,-4) {root};
foreach name [remember= name as n (initially root)]in {aa,bb,cc,dd}
node[box, above=of n] (name) {name};
end{tikzpicture}
end{document}
That does what I need. I wrapped that foreach loop in a newcommand and generated my list of nodes. But now I find that I can't refer to the nodes outside the command I generated. When I try to draw the arrows nothing happens. Are the nodes names scoped? Is there a way to make them available at a larger scope? Where can I find full documentation for foreach? I have not seen anything that explains these optional arguments like [remember...], and it seems there are several of them.
– Adrian
4 hours ago
@Adrian Can you update the question with this new problem and your new code (while leaving this one visible)? You will find the syntax of[remember...]page 905 of the tikz-pgf manual3.0.1actan.org/pkg/pgf
– AndréC
4 hours ago
add a comment |
up vote
0
down vote
R you looking for the good old xshift?
documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[box/.style={rectangle,draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (ReadQueryParametersJSON) at (0,0) {ReadQueryParametersJSON};
node[box] (ParseParametricLine) [below=of ReadQueryParametersJSON,anchor=west,xshift=-1cm] {ParseParametricLine};
node[box] (ReadJSONFile) [below=of ParseParametricLine.west,anchor=west] {ReadJSONFile};
node[box] (GUIMapping) [below=of ReadJSONFile.west,anchor=west] {GUIMapping};
path [->] ([xshift=4mm]ReadQueryParametersJSON.south west) edge [vh path] (GUIMapping)
([xshift=6mm]ReadQueryParametersJSON.south west) edge [vh path] (ReadJSONFile)
([xshift=8mm]ReadQueryParametersJSON.south west) edge [vh path] (ParseParametricLine);
%node[box] (root) at (0,-4) {root};
%foreach name in {aa,bb,cc,dd}
% node[box] (name) at ++(0,-1) {name};
end{tikzpicture}

add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
If I understood your question correctly, you can use the above of= key in this way:

documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[
box/.style={draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (root) at (0,-4) {root};
foreach name [remember= name as n (initially root)]in {aa,bb,cc,dd}
node[box, above=of n] (name) {name};
end{tikzpicture}
end{document}
That does what I need. I wrapped that foreach loop in a newcommand and generated my list of nodes. But now I find that I can't refer to the nodes outside the command I generated. When I try to draw the arrows nothing happens. Are the nodes names scoped? Is there a way to make them available at a larger scope? Where can I find full documentation for foreach? I have not seen anything that explains these optional arguments like [remember...], and it seems there are several of them.
– Adrian
4 hours ago
@Adrian Can you update the question with this new problem and your new code (while leaving this one visible)? You will find the syntax of[remember...]page 905 of the tikz-pgf manual3.0.1actan.org/pkg/pgf
– AndréC
4 hours ago
add a comment |
up vote
1
down vote
If I understood your question correctly, you can use the above of= key in this way:

documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[
box/.style={draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (root) at (0,-4) {root};
foreach name [remember= name as n (initially root)]in {aa,bb,cc,dd}
node[box, above=of n] (name) {name};
end{tikzpicture}
end{document}
That does what I need. I wrapped that foreach loop in a newcommand and generated my list of nodes. But now I find that I can't refer to the nodes outside the command I generated. When I try to draw the arrows nothing happens. Are the nodes names scoped? Is there a way to make them available at a larger scope? Where can I find full documentation for foreach? I have not seen anything that explains these optional arguments like [remember...], and it seems there are several of them.
– Adrian
4 hours ago
@Adrian Can you update the question with this new problem and your new code (while leaving this one visible)? You will find the syntax of[remember...]page 905 of the tikz-pgf manual3.0.1actan.org/pkg/pgf
– AndréC
4 hours ago
add a comment |
up vote
1
down vote
up vote
1
down vote
If I understood your question correctly, you can use the above of= key in this way:

documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[
box/.style={draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (root) at (0,-4) {root};
foreach name [remember= name as n (initially root)]in {aa,bb,cc,dd}
node[box, above=of n] (name) {name};
end{tikzpicture}
end{document}
If I understood your question correctly, you can use the above of= key in this way:

documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[
box/.style={draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (root) at (0,-4) {root};
foreach name [remember= name as n (initially root)]in {aa,bb,cc,dd}
node[box, above=of n] (name) {name};
end{tikzpicture}
end{document}
answered 5 hours ago
AndréC
6,62711140
6,62711140
That does what I need. I wrapped that foreach loop in a newcommand and generated my list of nodes. But now I find that I can't refer to the nodes outside the command I generated. When I try to draw the arrows nothing happens. Are the nodes names scoped? Is there a way to make them available at a larger scope? Where can I find full documentation for foreach? I have not seen anything that explains these optional arguments like [remember...], and it seems there are several of them.
– Adrian
4 hours ago
@Adrian Can you update the question with this new problem and your new code (while leaving this one visible)? You will find the syntax of[remember...]page 905 of the tikz-pgf manual3.0.1actan.org/pkg/pgf
– AndréC
4 hours ago
add a comment |
That does what I need. I wrapped that foreach loop in a newcommand and generated my list of nodes. But now I find that I can't refer to the nodes outside the command I generated. When I try to draw the arrows nothing happens. Are the nodes names scoped? Is there a way to make them available at a larger scope? Where can I find full documentation for foreach? I have not seen anything that explains these optional arguments like [remember...], and it seems there are several of them.
– Adrian
4 hours ago
@Adrian Can you update the question with this new problem and your new code (while leaving this one visible)? You will find the syntax of[remember...]page 905 of the tikz-pgf manual3.0.1actan.org/pkg/pgf
– AndréC
4 hours ago
That does what I need. I wrapped that foreach loop in a newcommand and generated my list of nodes. But now I find that I can't refer to the nodes outside the command I generated. When I try to draw the arrows nothing happens. Are the nodes names scoped? Is there a way to make them available at a larger scope? Where can I find full documentation for foreach? I have not seen anything that explains these optional arguments like [remember...], and it seems there are several of them.
– Adrian
4 hours ago
That does what I need. I wrapped that foreach loop in a newcommand and generated my list of nodes. But now I find that I can't refer to the nodes outside the command I generated. When I try to draw the arrows nothing happens. Are the nodes names scoped? Is there a way to make them available at a larger scope? Where can I find full documentation for foreach? I have not seen anything that explains these optional arguments like [remember...], and it seems there are several of them.
– Adrian
4 hours ago
@Adrian Can you update the question with this new problem and your new code (while leaving this one visible)? You will find the syntax of
[remember...] page 905 of the tikz-pgf manual 3.0.1a ctan.org/pkg/pgf– AndréC
4 hours ago
@Adrian Can you update the question with this new problem and your new code (while leaving this one visible)? You will find the syntax of
[remember...] page 905 of the tikz-pgf manual 3.0.1a ctan.org/pkg/pgf– AndréC
4 hours ago
add a comment |
up vote
0
down vote
R you looking for the good old xshift?
documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[box/.style={rectangle,draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (ReadQueryParametersJSON) at (0,0) {ReadQueryParametersJSON};
node[box] (ParseParametricLine) [below=of ReadQueryParametersJSON,anchor=west,xshift=-1cm] {ParseParametricLine};
node[box] (ReadJSONFile) [below=of ParseParametricLine.west,anchor=west] {ReadJSONFile};
node[box] (GUIMapping) [below=of ReadJSONFile.west,anchor=west] {GUIMapping};
path [->] ([xshift=4mm]ReadQueryParametersJSON.south west) edge [vh path] (GUIMapping)
([xshift=6mm]ReadQueryParametersJSON.south west) edge [vh path] (ReadJSONFile)
([xshift=8mm]ReadQueryParametersJSON.south west) edge [vh path] (ParseParametricLine);
%node[box] (root) at (0,-4) {root};
%foreach name in {aa,bb,cc,dd}
% node[box] (name) at ++(0,-1) {name};
end{tikzpicture}

add a comment |
up vote
0
down vote
R you looking for the good old xshift?
documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[box/.style={rectangle,draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (ReadQueryParametersJSON) at (0,0) {ReadQueryParametersJSON};
node[box] (ParseParametricLine) [below=of ReadQueryParametersJSON,anchor=west,xshift=-1cm] {ParseParametricLine};
node[box] (ReadJSONFile) [below=of ParseParametricLine.west,anchor=west] {ReadJSONFile};
node[box] (GUIMapping) [below=of ReadJSONFile.west,anchor=west] {GUIMapping};
path [->] ([xshift=4mm]ReadQueryParametersJSON.south west) edge [vh path] (GUIMapping)
([xshift=6mm]ReadQueryParametersJSON.south west) edge [vh path] (ReadJSONFile)
([xshift=8mm]ReadQueryParametersJSON.south west) edge [vh path] (ParseParametricLine);
%node[box] (root) at (0,-4) {root};
%foreach name in {aa,bb,cc,dd}
% node[box] (name) at ++(0,-1) {name};
end{tikzpicture}

add a comment |
up vote
0
down vote
up vote
0
down vote
R you looking for the good old xshift?
documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[box/.style={rectangle,draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (ReadQueryParametersJSON) at (0,0) {ReadQueryParametersJSON};
node[box] (ParseParametricLine) [below=of ReadQueryParametersJSON,anchor=west,xshift=-1cm] {ParseParametricLine};
node[box] (ReadJSONFile) [below=of ParseParametricLine.west,anchor=west] {ReadJSONFile};
node[box] (GUIMapping) [below=of ReadJSONFile.west,anchor=west] {GUIMapping};
path [->] ([xshift=4mm]ReadQueryParametersJSON.south west) edge [vh path] (GUIMapping)
([xshift=6mm]ReadQueryParametersJSON.south west) edge [vh path] (ReadJSONFile)
([xshift=8mm]ReadQueryParametersJSON.south west) edge [vh path] (ParseParametricLine);
%node[box] (root) at (0,-4) {root};
%foreach name in {aa,bb,cc,dd}
% node[box] (name) at ++(0,-1) {name};
end{tikzpicture}

R you looking for the good old xshift?
documentclass{report}
usepackage{tikz}
usetikzlibrary{arrows,positioning}
begin{document}
begin{tikzpicture}[box/.style={rectangle,draw=black},
vh path/.style={to path={|- (tikztotarget)}}
]
node[box] (ReadQueryParametersJSON) at (0,0) {ReadQueryParametersJSON};
node[box] (ParseParametricLine) [below=of ReadQueryParametersJSON,anchor=west,xshift=-1cm] {ParseParametricLine};
node[box] (ReadJSONFile) [below=of ParseParametricLine.west,anchor=west] {ReadJSONFile};
node[box] (GUIMapping) [below=of ReadJSONFile.west,anchor=west] {GUIMapping};
path [->] ([xshift=4mm]ReadQueryParametersJSON.south west) edge [vh path] (GUIMapping)
([xshift=6mm]ReadQueryParametersJSON.south west) edge [vh path] (ReadJSONFile)
([xshift=8mm]ReadQueryParametersJSON.south west) edge [vh path] (ParseParametricLine);
%node[box] (root) at (0,-4) {root};
%foreach name in {aa,bb,cc,dd}
% node[box] (name) at ++(0,-1) {name};
end{tikzpicture}

answered 5 hours ago
marmot
80.3k491172
80.3k491172
add a comment |
add a comment |
Adrian is a new contributor. Be nice, and check out our Code of Conduct.
Adrian is a new contributor. Be nice, and check out our Code of Conduct.
Adrian is a new contributor. Be nice, and check out our Code of Conduct.
Adrian is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f463021%2ftikz-creating-nodes-from-a-list-and-adjusting-path-start-position%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown