# Why can't I give a coordinate an alias using “late options”?

Here is a small document:

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
%\coordinate (A) at (0, 0);                     % Line A
%\node [coordinate] (A) at (0, 0) {};           % Line B
%\node (A) at (0, 0) {};                        % Line C
%\coordinate [alias=AA] (A) at (0, 0);          % Line D
%\node [coordinate, alias=AA] (A) at (0, 0) {}; % Line E
%\path (A) [late options = {alias=AA}];         % Line ABC
\coordinate (B) at (1, 0);
\draw (AA) -- (B);
\end{tikzpicture}

\end{document}

1. Uncomment lines A and ABC and you get "Package pgf Error: No shape named AA is known."
2. Re-comment line A and uncomment line B and you get the same result.
3. Re-comment line B and uncomment line C and the document compiles successfully.
4. Re-comment lines C and ABC and uncomment line D and the document compiles successfully.
5. Re-comment line D and uncomment line E and the document compiles successfully.

It seems that if a node is of shape coordinate, you can give it an alias, but not using the late options mechanism. If you try to do it with late options, TikZ doesn't report an error, but it doesn't do anything.

I am using PGF/TikZ version 2.10.

-
Interesting. Note that \path (A) [late options = {name=A,alias=AA}]; does work. – Andrew Swann Dec 28 '13 at 16:38
@AndrewSwann That's the proper usage and the answer. Late options need to know to which it should append to. – percusse Dec 28 '13 at 17:00
@percusse, Andrew's comment, while a useful contribution, does not constitute an answer as you say. For one thing, it does not explain why it makes a difference that the node is of shape coordinate (observe that in the cases where no shape is specified, the code works); for another, the PGF/Tikz version 2.10 manual (page 201) gives an example of a use of "late options" which, similarly to the code in my example document, does not make use of "name" to specify or reinforce a choice of node. – Hammerite Dec 28 '13 at 17:15
Quoting from the manual: "The <existing node> is determined as follows: If the name=<existing node> option is used inside the <options>, then this name is used. Otherwise, if the last coordinate on the current path was of the form (<existing node>), then this <existing node> name is used. Otherwise, an error results." This does not say that the node may not be a coordinate in order for the node that is the subject to be identified implicitly from the last point on the path; moreover, it says that if the node can't be identified then an error will occur, and this doesn't happen in my example. – Hammerite Dec 28 '13 at 17:18
From manual Version 3.0; Inside the <options>, you should use the name option to specify the node for which you wish to add late options: This was an issue before and while I was brief in my comment trust me it needs the name. – percusse Dec 28 '13 at 19:14

The most foolproof way to make sure that TikZ correctly identifies the node to which "late options" are to be applied is to supply the "name" property (using the node's existing name) within the "late options" option list:

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\coordinate (A) at (0, 0);
\path [late options = {name=A,alias=AA}];
\coordinate (B) at (1, 0);
\draw (AA) -- (B);
\end{tikzpicture}

\end{document}


As the example in the question shows, TikZ's ability to identify the node implicitly (as the 2.10 manual suggests it should) is somewhat error-prone. The version 3.00 manual (which may be obtained by downloading TikZ/PGF version 3.00 from the project's Sourceforge page) amends (page 251) the content from page 201 of the 2.10 manual to suggest that the "name" property is the only correct way to indicate the node to which the "late options" are to be applied; the suggestion that TikZ will automatically identify the correct node from the context has been eliminated.

Thanks to Andrew Swann and percusse.

-
As contextual solution, you may use node also (from TikZ 3.0.0). – Paul Gaborit Dec 29 '13 at 10:41
Still another way is to use \pgfnodealias. – Hammerite Jan 8 '14 at 21:02