Problem when applying foreach loop Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)How to properly smuggle (with or even without TikZ)?foreach limit computed through an operation between pgfmathsetlengthmacrosRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?Numerical conditional within tikz keys?Why do I get an extra white page before my TikZ picture?TikZ: Drawing an arc from an intersection to an intersectionDrawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themHow to draw a square and its diagonals with arrows?Compound Pathway Problem with holesInclude node at end point tikz decorations
Putting class ranking in CV, but against dept guidelines
As a beginner, should I get a Squier Strat with a SSS config or a HSS?
What initially awakened the Balrog?
Is a ledger board required if the side of my house is wood?
Is it possible for SQL statements to execute concurrently within a single session in SQL Server?
Time to Settle Down!
Can the Great Weapon Master feat's damage bonus and accuracy penalty apply to attacks from the Spiritual Weapon spell?
Why is the AVR GCC compiler using a full `CALL` even though I have set the `-mshort-calls` flag?
Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?
Crossing US/Canada Border for less than 24 hours
AppleTVs create a chatty alternate WiFi network
How often does castling occur in grandmaster games?
What is a fractional matching?
What do you call the main part of a joke?
How do living politicians protect their readily obtainable signatures from misuse?
ArcGIS Pro Python arcpy.CreatePersonalGDB_management
Project Euler #1 in C++
Amount of permutations on an NxNxN Rubik's Cube
Performance gap between vector<bool> and array
Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?
Most bit efficient text communication method?
What is this clumpy 20-30cm high yellow-flowered plant?
How can I reduce the gap between left and right of cdot with a macro?
Find 108 by using 3,4,6
Problem when applying foreach loop
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)How to properly smuggle (with or even without TikZ)?foreach limit computed through an operation between pgfmathsetlengthmacrosRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?Numerical conditional within tikz keys?Why do I get an extra white page before my TikZ picture?TikZ: Drawing an arc from an intersection to an intersectionDrawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themHow to draw a square and its diagonals with arrows?Compound Pathway Problem with holesInclude node at end point tikz decorations
I'm trying to find the minimum x coordinate in a set of TikZ coordinates.
Consider this code
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
path (1.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
path (2.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
path (3.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
and this code
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
foreach i in 1,2,3
path (i.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
These are the outputs of the first code (left) and the second code (right) side by side:
Look at the dot at the bottom. The first code gives the intended output, but the second doesn't.
Why? And how to modify the foreach
loop in the second code so that it gives the same output as the first?
tikz-pgf loops dimensions
add a comment |
I'm trying to find the minimum x coordinate in a set of TikZ coordinates.
Consider this code
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
path (1.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
path (2.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
path (3.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
and this code
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
foreach i in 1,2,3
path (i.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
These are the outputs of the first code (left) and the second code (right) side by side:
Look at the dot at the bottom. The first code gives the intended output, but the second doesn't.
Why? And how to modify the foreach
loop in the second code so that it gives the same output as the first?
tikz-pgf loops dimensions
add a comment |
I'm trying to find the minimum x coordinate in a set of TikZ coordinates.
Consider this code
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
path (1.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
path (2.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
path (3.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
and this code
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
foreach i in 1,2,3
path (i.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
These are the outputs of the first code (left) and the second code (right) side by side:
Look at the dot at the bottom. The first code gives the intended output, but the second doesn't.
Why? And how to modify the foreach
loop in the second code so that it gives the same output as the first?
tikz-pgf loops dimensions
I'm trying to find the minimum x coordinate in a set of TikZ coordinates.
Consider this code
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
path (1.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
path (2.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
path (3.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
and this code
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
foreach i in 1,2,3
path (i.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
These are the outputs of the first code (left) and the second code (right) side by side:
Look at the dot at the bottom. The first code gives the intended output, but the second doesn't.
Why? And how to modify the foreach
loop in the second code so that it gives the same output as the first?
tikz-pgf loops dimensions
tikz-pgf loops dimensions
asked Apr 14 at 14:46
JouleVJouleV
14k22664
14k22664
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
In the foreach
variant, you are in a group when setting the dimension, so the "outside" value won't change. So you need to make the dimension global (or smuggle it out of the group). Here I made it global by just adding global
before xmin=x
.
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
foreach i in 1,2,3
path (i.west); pgfgetlastxyxy
ifdimx<xmin globalxmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
ADDENDUM: Of course, there are loops which do not introduce groups. The arguably simplest of those is the built-in loop
.
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
newcounterloopi
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
setcounterloopi0
loop
stepcounterloopi
path (numbervalueloopi.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
ifnumnumbervalueloopi<3repeat
endtikzpicture
enddocument
@JouleV You only change the local but not the outside value. (This is also the reason whydraw[blue] ...
renders only the...
but not every other path blue. Likewise, if you saytikz[blue]....
everything in thetikzpicture
will be blue, but not outside, and so on.) In TeX all macros are local unless you explicitly make them global.
– marmot
Apr 14 at 14:56
1
You are, as always, the best marmot in the marmot tikzita Very New World marmot type :)) Will accept once allowed.
– JouleV
Apr 14 at 14:57
add a comment |
You can use a different loop that doesn't do grouping. Instead of i
you use simply #1
.
documentclass[border=4]standalone
usepackagexparse
usepackagetikz
usetikzlibrarypositioning
ExplSyntaxOn
NewDocumentCommandnforeachmmm
cs_set:Nn joulev_nforeach:n #3
int_step_function:nnN #1 #2 joulev_nforeach:n
ExplSyntaxOff
newdimenx
newdimenxmin
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
xmin=10000pt
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
nforeach13
path (#1.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
Maybe I will have to start learningexpl3
syntax soon. What does those commands insideExplSyntax
mean?
– JouleV
Apr 14 at 15:27
@JouleV The first line sets a temporary function according to the code in the third argument; the second line does a loop from the starting point (first argument) to the final point (second argument). No fancy syntax likeforeach
, but for most cases it's sufficient. You find a more elaborate implementation at tex.stackexchange.com/a/329628/4427
– egreg
Apr 14 at 15:30
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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%2f484808%2fproblem-when-applying-foreach-loop%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In the foreach
variant, you are in a group when setting the dimension, so the "outside" value won't change. So you need to make the dimension global (or smuggle it out of the group). Here I made it global by just adding global
before xmin=x
.
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
foreach i in 1,2,3
path (i.west); pgfgetlastxyxy
ifdimx<xmin globalxmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
ADDENDUM: Of course, there are loops which do not introduce groups. The arguably simplest of those is the built-in loop
.
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
newcounterloopi
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
setcounterloopi0
loop
stepcounterloopi
path (numbervalueloopi.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
ifnumnumbervalueloopi<3repeat
endtikzpicture
enddocument
@JouleV You only change the local but not the outside value. (This is also the reason whydraw[blue] ...
renders only the...
but not every other path blue. Likewise, if you saytikz[blue]....
everything in thetikzpicture
will be blue, but not outside, and so on.) In TeX all macros are local unless you explicitly make them global.
– marmot
Apr 14 at 14:56
1
You are, as always, the best marmot in the marmot tikzita Very New World marmot type :)) Will accept once allowed.
– JouleV
Apr 14 at 14:57
add a comment |
In the foreach
variant, you are in a group when setting the dimension, so the "outside" value won't change. So you need to make the dimension global (or smuggle it out of the group). Here I made it global by just adding global
before xmin=x
.
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
foreach i in 1,2,3
path (i.west); pgfgetlastxyxy
ifdimx<xmin globalxmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
ADDENDUM: Of course, there are loops which do not introduce groups. The arguably simplest of those is the built-in loop
.
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
newcounterloopi
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
setcounterloopi0
loop
stepcounterloopi
path (numbervalueloopi.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
ifnumnumbervalueloopi<3repeat
endtikzpicture
enddocument
@JouleV You only change the local but not the outside value. (This is also the reason whydraw[blue] ...
renders only the...
but not every other path blue. Likewise, if you saytikz[blue]....
everything in thetikzpicture
will be blue, but not outside, and so on.) In TeX all macros are local unless you explicitly make them global.
– marmot
Apr 14 at 14:56
1
You are, as always, the best marmot in the marmot tikzita Very New World marmot type :)) Will accept once allowed.
– JouleV
Apr 14 at 14:57
add a comment |
In the foreach
variant, you are in a group when setting the dimension, so the "outside" value won't change. So you need to make the dimension global (or smuggle it out of the group). Here I made it global by just adding global
before xmin=x
.
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
foreach i in 1,2,3
path (i.west); pgfgetlastxyxy
ifdimx<xmin globalxmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
ADDENDUM: Of course, there are loops which do not introduce groups. The arguably simplest of those is the built-in loop
.
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
newcounterloopi
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
setcounterloopi0
loop
stepcounterloopi
path (numbervalueloopi.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
ifnumnumbervalueloopi<3repeat
endtikzpicture
enddocument
In the foreach
variant, you are in a group when setting the dimension, so the "outside" value won't change. So you need to make the dimension global (or smuggle it out of the group). Here I made it global by just adding global
before xmin=x
.
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
foreach i in 1,2,3
path (i.west); pgfgetlastxyxy
ifdimx<xmin globalxmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
ADDENDUM: Of course, there are loops which do not introduce groups. The arguably simplest of those is the built-in loop
.
documentclass[tikz]standalone
usetikzlibrarypositioning
newdimenx
newdimenxmin
xmin=10000pt
newdimeny
newcounterloopi
begindocument
begintikzpicture[every node/.style=draw]
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
setcounterloopi0
loop
stepcounterloopi
path (numbervalueloopi.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
ifnumnumbervalueloopi<3repeat
endtikzpicture
enddocument
edited Apr 14 at 16:16
answered Apr 14 at 14:49
marmotmarmot
119k6154289
119k6154289
@JouleV You only change the local but not the outside value. (This is also the reason whydraw[blue] ...
renders only the...
but not every other path blue. Likewise, if you saytikz[blue]....
everything in thetikzpicture
will be blue, but not outside, and so on.) In TeX all macros are local unless you explicitly make them global.
– marmot
Apr 14 at 14:56
1
You are, as always, the best marmot in the marmot tikzita Very New World marmot type :)) Will accept once allowed.
– JouleV
Apr 14 at 14:57
add a comment |
@JouleV You only change the local but not the outside value. (This is also the reason whydraw[blue] ...
renders only the...
but not every other path blue. Likewise, if you saytikz[blue]....
everything in thetikzpicture
will be blue, but not outside, and so on.) In TeX all macros are local unless you explicitly make them global.
– marmot
Apr 14 at 14:56
1
You are, as always, the best marmot in the marmot tikzita Very New World marmot type :)) Will accept once allowed.
– JouleV
Apr 14 at 14:57
@JouleV You only change the local but not the outside value. (This is also the reason why
draw[blue] ...
renders only the ...
but not every other path blue. Likewise, if you say tikz[blue]....
everything in the tikzpicture
will be blue, but not outside, and so on.) In TeX all macros are local unless you explicitly make them global.– marmot
Apr 14 at 14:56
@JouleV You only change the local but not the outside value. (This is also the reason why
draw[blue] ...
renders only the ...
but not every other path blue. Likewise, if you say tikz[blue]....
everything in the tikzpicture
will be blue, but not outside, and so on.) In TeX all macros are local unless you explicitly make them global.– marmot
Apr 14 at 14:56
1
1
You are, as always, the best marmot in the marmot tikzita Very New World marmot type :)) Will accept once allowed.
– JouleV
Apr 14 at 14:57
You are, as always, the best marmot in the marmot tikzita Very New World marmot type :)) Will accept once allowed.
– JouleV
Apr 14 at 14:57
add a comment |
You can use a different loop that doesn't do grouping. Instead of i
you use simply #1
.
documentclass[border=4]standalone
usepackagexparse
usepackagetikz
usetikzlibrarypositioning
ExplSyntaxOn
NewDocumentCommandnforeachmmm
cs_set:Nn joulev_nforeach:n #3
int_step_function:nnN #1 #2 joulev_nforeach:n
ExplSyntaxOff
newdimenx
newdimenxmin
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
xmin=10000pt
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
nforeach13
path (#1.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
Maybe I will have to start learningexpl3
syntax soon. What does those commands insideExplSyntax
mean?
– JouleV
Apr 14 at 15:27
@JouleV The first line sets a temporary function according to the code in the third argument; the second line does a loop from the starting point (first argument) to the final point (second argument). No fancy syntax likeforeach
, but for most cases it's sufficient. You find a more elaborate implementation at tex.stackexchange.com/a/329628/4427
– egreg
Apr 14 at 15:30
add a comment |
You can use a different loop that doesn't do grouping. Instead of i
you use simply #1
.
documentclass[border=4]standalone
usepackagexparse
usepackagetikz
usetikzlibrarypositioning
ExplSyntaxOn
NewDocumentCommandnforeachmmm
cs_set:Nn joulev_nforeach:n #3
int_step_function:nnN #1 #2 joulev_nforeach:n
ExplSyntaxOff
newdimenx
newdimenxmin
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
xmin=10000pt
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
nforeach13
path (#1.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
Maybe I will have to start learningexpl3
syntax soon. What does those commands insideExplSyntax
mean?
– JouleV
Apr 14 at 15:27
@JouleV The first line sets a temporary function according to the code in the third argument; the second line does a loop from the starting point (first argument) to the final point (second argument). No fancy syntax likeforeach
, but for most cases it's sufficient. You find a more elaborate implementation at tex.stackexchange.com/a/329628/4427
– egreg
Apr 14 at 15:30
add a comment |
You can use a different loop that doesn't do grouping. Instead of i
you use simply #1
.
documentclass[border=4]standalone
usepackagexparse
usepackagetikz
usetikzlibrarypositioning
ExplSyntaxOn
NewDocumentCommandnforeachmmm
cs_set:Nn joulev_nforeach:n #3
int_step_function:nnN #1 #2 joulev_nforeach:n
ExplSyntaxOff
newdimenx
newdimenxmin
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
xmin=10000pt
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
nforeach13
path (#1.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
You can use a different loop that doesn't do grouping. Instead of i
you use simply #1
.
documentclass[border=4]standalone
usepackagexparse
usepackagetikz
usetikzlibrarypositioning
ExplSyntaxOn
NewDocumentCommandnforeachmmm
cs_set:Nn joulev_nforeach:n #3
int_step_function:nnN #1 #2 joulev_nforeach:n
ExplSyntaxOff
newdimenx
newdimenxmin
newdimeny
begindocument
begintikzpicture[every node/.style=draw]
xmin=10000pt
node (1) 182;
node[below=of 1] (2) 183731468;
node[below=of 2] (3) 74632;
nforeach13
path (#1.west); pgfgetlastxyxy
ifdimx<xmin xmin=x fi
fill[red] (xmin,y) circle (1pt);
endtikzpicture
enddocument
answered Apr 14 at 15:14
egregegreg
735k8919343257
735k8919343257
Maybe I will have to start learningexpl3
syntax soon. What does those commands insideExplSyntax
mean?
– JouleV
Apr 14 at 15:27
@JouleV The first line sets a temporary function according to the code in the third argument; the second line does a loop from the starting point (first argument) to the final point (second argument). No fancy syntax likeforeach
, but for most cases it's sufficient. You find a more elaborate implementation at tex.stackexchange.com/a/329628/4427
– egreg
Apr 14 at 15:30
add a comment |
Maybe I will have to start learningexpl3
syntax soon. What does those commands insideExplSyntax
mean?
– JouleV
Apr 14 at 15:27
@JouleV The first line sets a temporary function according to the code in the third argument; the second line does a loop from the starting point (first argument) to the final point (second argument). No fancy syntax likeforeach
, but for most cases it's sufficient. You find a more elaborate implementation at tex.stackexchange.com/a/329628/4427
– egreg
Apr 14 at 15:30
Maybe I will have to start learning
expl3
syntax soon. What does those commands inside ExplSyntax
mean?– JouleV
Apr 14 at 15:27
Maybe I will have to start learning
expl3
syntax soon. What does those commands inside ExplSyntax
mean?– JouleV
Apr 14 at 15:27
@JouleV The first line sets a temporary function according to the code in the third argument; the second line does a loop from the starting point (first argument) to the final point (second argument). No fancy syntax like
foreach
, but for most cases it's sufficient. You find a more elaborate implementation at tex.stackexchange.com/a/329628/4427– egreg
Apr 14 at 15:30
@JouleV The first line sets a temporary function according to the code in the third argument; the second line does a loop from the starting point (first argument) to the final point (second argument). No fancy syntax like
foreach
, but for most cases it's sufficient. You find a more elaborate implementation at tex.stackexchange.com/a/329628/4427– egreg
Apr 14 at 15:30
add a comment |
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.
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%2f484808%2fproblem-when-applying-foreach-loop%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