-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pic angle in a pic doesn't respect pic name/name prefix. #1363
Comments
Even if it wasn't designed that way, I like the idea of using |
Not really, since that returns the
However, the other macros use Here's just the rewrite for the calculation. \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{angles}
\newcommand*\tikzpicname{\pgfkeysvalueof{/tikz/name prefix}}
\makeatletter
\def\tikz@lib@angle@parse#1--#2--#3\pgf@stop{%
% Compute radius:
\pgfmathsetmacro\tikz@lib@angle@rad{\pgfkeysvalueof{/tikz/angle radius}}%
\ifdim\tikz@lib@angle@rad pt>0pt\else\def\tikz@lib@angle@rad{12}\fi
% Compute first coordinate:
\tikz@scan@@absolute\pgf@process(#2)%
\pgf@xa=\pgf@x
\pgf@ya=\pgf@y
\tikz@scan@@absolute\pgf@process(#1)%
\pgf@xb=\pgf@x
\pgf@yb=\pgf@y
\tikz@scan@@absolute\pgf@process(#3)%
\pgf@xc=\pgf@x
\pgf@yc=\pgf@y
\advance\pgf@xb by-\pgf@xa
\advance\pgf@yb by-\pgf@ya
\advance\pgf@xc by-\pgf@xa
\advance\pgf@yc by-\pgf@ya
\pgfmathatantwo@{\pgf@sys@tonumber\pgf@yb}{\pgf@sys@tonumber\pgf@xb}%
\let\tikz@start@angle@temp\pgfmathresult
\pgfmathatantwo@{\pgf@sys@tonumber\pgf@yc}{\pgf@sys@tonumber\pgf@xc}%
\let\tikz@end@angle@temp\pgfmathresult
\ifdim\tikz@end@angle@temp pt<\tikz@start@angle@temp pt
\pgfmathsubtract@{\tikz@start@angle@temp}{360}%
\let\tikz@start@angle@temp\pgfmathresult
\fi
}
\makeatother
\begin{document}
\tikz\pic (name-) {
code={
\coordinate (x) at (right:1) % actually named name-x
coordinate (y) at (up:1) % actually named name-y
coordinate (O) at (0,0); % actually named name-O
\pic[draw, ultra thick] {angle=x--O--y}; % works
\pic[draw=yellow, thick] {angle=name-x--name-O--name-y}; % works as well
\pic[draw=red] {angle=\tikzpicname x--\tikzpicname O--\tikzpicname y}; % workaround still works
}
};
\end{document} |
I didn't follow previous discussions, but the
It seems to support uses of non-node coordinates in |
Yes, I mentioned that in my post but didn't take out the offending code from the example.
I've replaced it now so that the MWE works … and would also work for arbitrary coordinates but the |
Brief outline of the bug
When the pic
angle
(orright angle
) is used inside another pic, coordinates named inside the pic with non-emptyname prefix
orname suffix
can't be used for coordinates of the angle pic.This is, because
\tikz@lib@angle@parse
uses its argument directly with\pgfpointanchor
and doesn't check whether a node named\tikz@pp@name{#?}
exists:pgf/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex
Lines 73 to 84 in ab7c147
My suggestion is to do just that:
Of course, just using
\tikz@scan@one@point
would work, too, while allowing arbitrary coordinates as well, but apparently that wasn't wanted for theangle
pic since the manual points this out explicitly:pgf/doc/generic/pgf/pgfmanual-en-library-angles.tex
Lines 36 to 38 in ab7c147
Minimal working example (MWE)
The text was updated successfully, but these errors were encountered: