Skip to content

Commit

Permalink
Fix `name prefix' for pics
Browse files Browse the repository at this point in the history
There were two issues:

1. Pile-up of `name prefix' #311

    There is an extensive and very nice answer on TeX.SX:
    https://tex.stackexchange.com/questions/176900
    I have now implemented the first suggestion of just overriding
    `name prefix'.  I still have to test how this interacts with manual
    setting of `name prefix', but that doesn't seem to be very common
    (at least it doesn't seem to occur in the manual).

2. No resolution of global node names #717

    This had the effect that when requesting `current subpath start' (or
    any other global name) from within a pic, the resolution would add
    the prefix and suffix with \tikz@pp@name and if the resulting local
    name was undefined, throw an error.  Now I have implemented a two
    step resolution which first checks whether the local name exists and
    if it doesn't tries the global name.  I hope nobody is relying on
    the fact that before global names weren't resolved.
  • Loading branch information
hmenke committed Nov 4, 2019
1 parent 08275e3 commit 88951be
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4823,7 +4823,7 @@
\let\tikz@picmode\tikz@mode%
\tikzset{name prefix ../.style/.expanded={/tikz/name prefix=\pgfkeysvalueof{/tikz/name prefix}}}%
\ifx\tikz@fig@name\pgfutil@empty\else%
\tikzset{name prefix/.prefix/.expanded=\tikz@fig@name}%
\tikzset{name prefix/.expanded=\tikz@fig@name}%
\fi%
\pgfkeysvalueof{/tikz/pics/setup code}%
\pgfkeysgetvalue{/tikz/pics/code}{\tikz@pic@code}
Expand Down Expand Up @@ -5424,19 +5424,27 @@
\else%
\tikz@calc@anchor#2.center\tikz@stop% to be on the save side, in
% case iftikz@shapeborder is ignored...
\expandafter\ifx\csname pgf@sh@ns@\tikz@pp@name{#2}\endcsname\tikz@coordinate@text%
\else
\tikz@shapebordertrue%
\def\tikz@shapeborder@name{\tikz@pp@name{#2}}%
\fi%
\ifcsname pgf@sh@ns@\tikz@pp@name{#2}\endcsname
\expandafter\ifx\csname pgf@sh@ns@\tikz@pp@name{#2}\endcsname\tikz@coordinate@text%
\else
\tikz@shapebordertrue%
\def\tikz@shapeborder@name{\tikz@pp@name{#2}}%
\fi%
\fi
\fi%
\expandafter\let\expandafter\tikz@declared@coordinate\csname tikz@dcl@coord@\tikz@pp@name{#2}\endcsname
\edef\tikz@marshal{\noexpand#1{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}%
\tikz@marshal%
}%
\def\tikz@calc@anchor#1.#2\tikz@stop{%
\pgfpointanchor{\tikz@pp@name{#1}}{#2}%
% Check if a shape with name prefix exists, otherwise try the global name
% without prefix.
\ifcsname pgf@sh@ns@\tikz@pp@name{#1}\endcsname%
\pgfpointanchor{\tikz@pp@name{#1}}{#2}%
\else
\pgfpointanchor{#1}{#2}%
\fi
}%
Expand Down

0 comments on commit 88951be

Please sign in to comment.