Automating setting node positions in foreach
up vote
1
down vote
favorite
Is there a way to automate setting nodes at the intervals of the foreach
marks so they can be referred to, for drawing the braces; instead of defining their locations manually.
documentclass{beamer}
beamertemplatenavigationsymbolsempty
usepackage{verbatim}
usepackage{tikz}
usepackage{pgfplots}
begin{document}
begin{frame}[t]
frametitle{ci}
begin{tikzpicture}[scale=.9, transform shape]
pgfmathsetmacro{incx}{.88}
draw [thick,-] (0,0) -- +(0:8.8) node [pos=.146](a){a} node [ pos=.296](b){b} node [pos=.44](c){c} node [pos=.586](d){d} node [pos=.876](e){e} node [pos=.73](f){f};
foreach x [evaluate=x as aff using int(x*1)]in {1,...,6}{draw [black, very thick] (incx*1.46*x,.2) -- +(-90:.4);}
draw [blue, thick, decorate, decoration={brace,amplitude=.16cm,mirror}] (b.center|-0,-.4) -- (d.center|-0,-.4) node [blue!80!black, midway, xshift=0cm, yshift=-.5cm] {middle};
draw [blue, thick, decorate, decoration={brace,amplitude=.16cm}] (a.center|-0,.4) -- (b.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] {series};
draw [blue, thick, decorate, decoration={brace,amplitude=.16cm,mirror}] (e.center|-0,.4) -- (f.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] {draw};
end{tikzpicture}
end{frame}
end{document}
tikz-pgf
add a comment |
up vote
1
down vote
favorite
Is there a way to automate setting nodes at the intervals of the foreach
marks so they can be referred to, for drawing the braces; instead of defining their locations manually.
documentclass{beamer}
beamertemplatenavigationsymbolsempty
usepackage{verbatim}
usepackage{tikz}
usepackage{pgfplots}
begin{document}
begin{frame}[t]
frametitle{ci}
begin{tikzpicture}[scale=.9, transform shape]
pgfmathsetmacro{incx}{.88}
draw [thick,-] (0,0) -- +(0:8.8) node [pos=.146](a){a} node [ pos=.296](b){b} node [pos=.44](c){c} node [pos=.586](d){d} node [pos=.876](e){e} node [pos=.73](f){f};
foreach x [evaluate=x as aff using int(x*1)]in {1,...,6}{draw [black, very thick] (incx*1.46*x,.2) -- +(-90:.4);}
draw [blue, thick, decorate, decoration={brace,amplitude=.16cm,mirror}] (b.center|-0,-.4) -- (d.center|-0,-.4) node [blue!80!black, midway, xshift=0cm, yshift=-.5cm] {middle};
draw [blue, thick, decorate, decoration={brace,amplitude=.16cm}] (a.center|-0,.4) -- (b.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] {series};
draw [blue, thick, decorate, decoration={brace,amplitude=.16cm,mirror}] (e.center|-0,.4) -- (f.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] {draw};
end{tikzpicture}
end{frame}
end{document}
tikz-pgf
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Is there a way to automate setting nodes at the intervals of the foreach
marks so they can be referred to, for drawing the braces; instead of defining their locations manually.
documentclass{beamer}
beamertemplatenavigationsymbolsempty
usepackage{verbatim}
usepackage{tikz}
usepackage{pgfplots}
begin{document}
begin{frame}[t]
frametitle{ci}
begin{tikzpicture}[scale=.9, transform shape]
pgfmathsetmacro{incx}{.88}
draw [thick,-] (0,0) -- +(0:8.8) node [pos=.146](a){a} node [ pos=.296](b){b} node [pos=.44](c){c} node [pos=.586](d){d} node [pos=.876](e){e} node [pos=.73](f){f};
foreach x [evaluate=x as aff using int(x*1)]in {1,...,6}{draw [black, very thick] (incx*1.46*x,.2) -- +(-90:.4);}
draw [blue, thick, decorate, decoration={brace,amplitude=.16cm,mirror}] (b.center|-0,-.4) -- (d.center|-0,-.4) node [blue!80!black, midway, xshift=0cm, yshift=-.5cm] {middle};
draw [blue, thick, decorate, decoration={brace,amplitude=.16cm}] (a.center|-0,.4) -- (b.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] {series};
draw [blue, thick, decorate, decoration={brace,amplitude=.16cm,mirror}] (e.center|-0,.4) -- (f.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] {draw};
end{tikzpicture}
end{frame}
end{document}
tikz-pgf
Is there a way to automate setting nodes at the intervals of the foreach
marks so they can be referred to, for drawing the braces; instead of defining their locations manually.
documentclass{beamer}
beamertemplatenavigationsymbolsempty
usepackage{verbatim}
usepackage{tikz}
usepackage{pgfplots}
begin{document}
begin{frame}[t]
frametitle{ci}
begin{tikzpicture}[scale=.9, transform shape]
pgfmathsetmacro{incx}{.88}
draw [thick,-] (0,0) -- +(0:8.8) node [pos=.146](a){a} node [ pos=.296](b){b} node [pos=.44](c){c} node [pos=.586](d){d} node [pos=.876](e){e} node [pos=.73](f){f};
foreach x [evaluate=x as aff using int(x*1)]in {1,...,6}{draw [black, very thick] (incx*1.46*x,.2) -- +(-90:.4);}
draw [blue, thick, decorate, decoration={brace,amplitude=.16cm,mirror}] (b.center|-0,-.4) -- (d.center|-0,-.4) node [blue!80!black, midway, xshift=0cm, yshift=-.5cm] {middle};
draw [blue, thick, decorate, decoration={brace,amplitude=.16cm}] (a.center|-0,.4) -- (b.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] {series};
draw [blue, thick, decorate, decoration={brace,amplitude=.16cm,mirror}] (e.center|-0,.4) -- (f.center|-0,.4) node [blue!80!black, midway, xshift=0cm, yshift=.5cm] {draw};
end{tikzpicture}
end{frame}
end{document}
tikz-pgf
tikz-pgf
asked Dec 8 at 7:03
Hany
1,056415
1,056415
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
You can try something like this:
foreach[count=j] i in {a,b,...,f}
draw[-|] (j,0) -- ++(1,0)node[below]{i}coordinate(i);
to draw lines and name the nodes using foreach
.
MWE
documentclass[border=3mm]{standalone}
usepackage{pgfplots}
tikzset{brce/.style={blue, thick, decorate, decoration={brace,amplitude=.16cm},}}
tikzset{brcetxt/.style={blue!80!black, midway, xshift=0cm,}}
begin{document}
begin{tikzpicture}
foreach[count=j] i in {a,b,...,f}
draw[-|] (j,0) -- ++(1,0)node[below]{i}coordinate(i);
draw (f)--++(1,0);
draw [brce,decoration=mirror] (b|-0,-.4) -- (d|-0,-.4) node [brcetxt,yshift=-.5cm] {middle};
draw [brce] (a|-0,.2) -- (b|-0,.2) node [brcetxt, yshift=.5cm] {series};
draw [brce] (e|-0,.2) -- (f|-0,.2) node [brcetxt, yshift=.5cm] {draw};
end{tikzpicture}
end{document}
Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
– Hany
Dec 8 at 8:22
1
@Hany see the updated answer.
– nidhin
Dec 8 at 8:56
Thank you very much for your time.
– Hany
Dec 8 at 9:22
Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
– Hany
Dec 8 at 9:43
1
@Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
– nidhin
Dec 8 at 10:00
|
show 3 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You can try something like this:
foreach[count=j] i in {a,b,...,f}
draw[-|] (j,0) -- ++(1,0)node[below]{i}coordinate(i);
to draw lines and name the nodes using foreach
.
MWE
documentclass[border=3mm]{standalone}
usepackage{pgfplots}
tikzset{brce/.style={blue, thick, decorate, decoration={brace,amplitude=.16cm},}}
tikzset{brcetxt/.style={blue!80!black, midway, xshift=0cm,}}
begin{document}
begin{tikzpicture}
foreach[count=j] i in {a,b,...,f}
draw[-|] (j,0) -- ++(1,0)node[below]{i}coordinate(i);
draw (f)--++(1,0);
draw [brce,decoration=mirror] (b|-0,-.4) -- (d|-0,-.4) node [brcetxt,yshift=-.5cm] {middle};
draw [brce] (a|-0,.2) -- (b|-0,.2) node [brcetxt, yshift=.5cm] {series};
draw [brce] (e|-0,.2) -- (f|-0,.2) node [brcetxt, yshift=.5cm] {draw};
end{tikzpicture}
end{document}
Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
– Hany
Dec 8 at 8:22
1
@Hany see the updated answer.
– nidhin
Dec 8 at 8:56
Thank you very much for your time.
– Hany
Dec 8 at 9:22
Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
– Hany
Dec 8 at 9:43
1
@Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
– nidhin
Dec 8 at 10:00
|
show 3 more comments
up vote
3
down vote
accepted
You can try something like this:
foreach[count=j] i in {a,b,...,f}
draw[-|] (j,0) -- ++(1,0)node[below]{i}coordinate(i);
to draw lines and name the nodes using foreach
.
MWE
documentclass[border=3mm]{standalone}
usepackage{pgfplots}
tikzset{brce/.style={blue, thick, decorate, decoration={brace,amplitude=.16cm},}}
tikzset{brcetxt/.style={blue!80!black, midway, xshift=0cm,}}
begin{document}
begin{tikzpicture}
foreach[count=j] i in {a,b,...,f}
draw[-|] (j,0) -- ++(1,0)node[below]{i}coordinate(i);
draw (f)--++(1,0);
draw [brce,decoration=mirror] (b|-0,-.4) -- (d|-0,-.4) node [brcetxt,yshift=-.5cm] {middle};
draw [brce] (a|-0,.2) -- (b|-0,.2) node [brcetxt, yshift=.5cm] {series};
draw [brce] (e|-0,.2) -- (f|-0,.2) node [brcetxt, yshift=.5cm] {draw};
end{tikzpicture}
end{document}
Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
– Hany
Dec 8 at 8:22
1
@Hany see the updated answer.
– nidhin
Dec 8 at 8:56
Thank you very much for your time.
– Hany
Dec 8 at 9:22
Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
– Hany
Dec 8 at 9:43
1
@Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
– nidhin
Dec 8 at 10:00
|
show 3 more comments
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You can try something like this:
foreach[count=j] i in {a,b,...,f}
draw[-|] (j,0) -- ++(1,0)node[below]{i}coordinate(i);
to draw lines and name the nodes using foreach
.
MWE
documentclass[border=3mm]{standalone}
usepackage{pgfplots}
tikzset{brce/.style={blue, thick, decorate, decoration={brace,amplitude=.16cm},}}
tikzset{brcetxt/.style={blue!80!black, midway, xshift=0cm,}}
begin{document}
begin{tikzpicture}
foreach[count=j] i in {a,b,...,f}
draw[-|] (j,0) -- ++(1,0)node[below]{i}coordinate(i);
draw (f)--++(1,0);
draw [brce,decoration=mirror] (b|-0,-.4) -- (d|-0,-.4) node [brcetxt,yshift=-.5cm] {middle};
draw [brce] (a|-0,.2) -- (b|-0,.2) node [brcetxt, yshift=.5cm] {series};
draw [brce] (e|-0,.2) -- (f|-0,.2) node [brcetxt, yshift=.5cm] {draw};
end{tikzpicture}
end{document}
You can try something like this:
foreach[count=j] i in {a,b,...,f}
draw[-|] (j,0) -- ++(1,0)node[below]{i}coordinate(i);
to draw lines and name the nodes using foreach
.
MWE
documentclass[border=3mm]{standalone}
usepackage{pgfplots}
tikzset{brce/.style={blue, thick, decorate, decoration={brace,amplitude=.16cm},}}
tikzset{brcetxt/.style={blue!80!black, midway, xshift=0cm,}}
begin{document}
begin{tikzpicture}
foreach[count=j] i in {a,b,...,f}
draw[-|] (j,0) -- ++(1,0)node[below]{i}coordinate(i);
draw (f)--++(1,0);
draw [brce,decoration=mirror] (b|-0,-.4) -- (d|-0,-.4) node [brcetxt,yshift=-.5cm] {middle};
draw [brce] (a|-0,.2) -- (b|-0,.2) node [brcetxt, yshift=.5cm] {series};
draw [brce] (e|-0,.2) -- (f|-0,.2) node [brcetxt, yshift=.5cm] {draw};
end{tikzpicture}
end{document}
edited Dec 8 at 8:55
answered Dec 8 at 7:46
nidhin
2,889926
2,889926
Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
– Hany
Dec 8 at 8:22
1
@Hany see the updated answer.
– nidhin
Dec 8 at 8:56
Thank you very much for your time.
– Hany
Dec 8 at 9:22
Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
– Hany
Dec 8 at 9:43
1
@Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
– nidhin
Dec 8 at 10:00
|
show 3 more comments
Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
– Hany
Dec 8 at 8:22
1
@Hany see the updated answer.
– nidhin
Dec 8 at 8:56
Thank you very much for your time.
– Hany
Dec 8 at 9:22
Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
– Hany
Dec 8 at 9:43
1
@Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
– nidhin
Dec 8 at 10:00
Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
– Hany
Dec 8 at 8:22
Thank you for your answer. I need the tickmarks, with possible node naming (not necessarily a b c d); and the braces.
– Hany
Dec 8 at 8:22
1
1
@Hany see the updated answer.
– nidhin
Dec 8 at 8:56
@Hany see the updated answer.
– nidhin
Dec 8 at 8:56
Thank you very much for your time.
– Hany
Dec 8 at 9:22
Thank you very much for your time.
– Hany
Dec 8 at 9:22
Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
– Hany
Dec 8 at 9:43
Just one more request please. Can the increments between the nodes be controlled, for example making them 1.4cm or so.
– Hany
Dec 8 at 9:43
1
1
@Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
– nidhin
Dec 8 at 10:00
@Hany my bad. change ` draw (j,0) -- ++(1,0); ` to ` draw (j*1.4,0) -- ++(1.4,0);`
– nidhin
Dec 8 at 10:00
|
show 3 more comments
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%2f463773%2fautomating-setting-node-positions-in-foreach%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