Skip to content

Commit

Permalink
Fix for nodes in foreach
Browse files Browse the repository at this point in the history
In the code:

```
\draw (A) foreach \nd in {B,C} { -- (\nd) };
```
then the line to `C` is drawn from `A`, not `B`.  This is because the
foreach loop does not update the macro that remembers that the last
coordinate was a node.  This fixes that issue.

See pgf-tikz#1303

Signed-off-by: Andrew Stacey <loopspace@mathforge.org>
  • Loading branch information
loopspace committed Apr 2, 2024
1 parent 292fa1d commit bb712ea
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2582,6 +2582,7 @@

\def\tikz@foreach{%
\def\pgffor@beginhook{%
\global\let\tikz@moveto@waiting\tikz@foreach@moveto@waiting%
\tikz@lastx=\tikz@foreach@save@lastx%
\tikz@lasty=\tikz@foreach@save@lasty%
\tikz@lastxsaved=\tikz@foreach@save@lastxsaved%
Expand All @@ -2590,6 +2591,7 @@
\setbox\tikz@figbox@bg=\box\tikz@tempbox@bg%
\expandafter\tikz@scan@next@command\pgfutil@firstofone}%
\def\pgffor@endhook{\pgfextra{%
\global\let\tikz@foreach@moveto@waiting\tikz@moveto@waiting%
\xdef\tikz@foreach@save@lastx{\the\tikz@lastx}%
\xdef\tikz@foreach@save@lasty{\the\tikz@lasty}%
\xdef\tikz@foreach@save@lastxsaved{\the\tikz@lastxsaved}%
Expand All @@ -2598,6 +2600,7 @@
\global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg%
\pgfutil@gobble}}%
\def\pgffor@afterhook{%
\let\tikz@moveto@waiting\tikz@foreach@moveto@waiting%
\tikz@lastx=\tikz@foreach@save@lastx%
\tikz@lasty=\tikz@foreach@save@lasty%
\tikz@lastxsaved=\tikz@foreach@save@lastxsaved%
Expand All @@ -2614,6 +2617,7 @@
\xdef\tikz@foreach@save@lasty{\the\tikz@lasty}%
\xdef\tikz@foreach@save@lastxsaved{\the\tikz@lastxsaved}%
\xdef\tikz@foreach@save@lastysaved{\the\tikz@lastysaved}%
\global\let\tikz@foreach@moveto@waiting\tikz@moveto@waiting%
\foreach}%


Expand Down

0 comments on commit bb712ea

Please sign in to comment.