I have a \drawanchor macro which draws and labels a point in a TikZ drawing. For each named point X I want to extract its coordinates and be able to print them later in the document.
I've got it working, except the coordinates are given in final, dimensionful coordinates, but I want the coordinates in terms of the x and y basis vectors. (I'll clarify this below.)
Here's a not-quite-right result:
\documentclass[a4paper]{article}
%% Language and font encodings
\usepackage[english]{babel}
\usepackage{tikz}
\begin{document}
\def\spvec#1{\left(\vcenter{\halign{\hfil$##$\hfil\cr \spvecA#1;;}}\right)}
\def\spvecA#1;{\if;#1;\else #1\cr \expandafter \spvecA \fi}
Demo of \textbackslash spvec: $foo=\spvec{1;2;3}$.
\newcommand{\drawanchor}[4][black]% colour,labelposition,name,coordinate
{%
\coordinate (#3) at #4;%
\path (#3) node[#2]{\textcolor{#1}{$#3$}};%
\pgfgetlastxy{\XCoord}{\YCoord};%
\fill #4 circle (0.09);%
\expandafter\xdef\csname colvec#3\endcsname%
{%
\noexpand\spvec{\XCoord;\YCoord}%
}
}
\begin{tikzpicture}
\drawanchor{left}{A}{(1.2,1.3)}
\drawanchor{right}{B}{(2.1,2.2)}
\end{tikzpicture}
Coordinates are $A=\colvecA, B=\colvecB$.
\end{document}
The desired result would be
Coordinates are A=(1.2), B=(2.1)
(1.3) (2.2)
I know that TikZ converts logical coordinates such as \coordinate (3,4) into physical coordinates 3x+4y where x and y are specified, dimensionful basis vectors, but that's not what I want -- I want the coefficients of the basis vectors.
I can change the definition of \drawanchor to retain the separate coordinate components as arguments, but I am interested in finding out what the logical coordinates are of an arbitrary named point (e.g. if point (foo) was computed via an intersection)
How could I do this?


drawanchorcommand to accepts the x/y coordinates separately, such that you call\drawanchor{left}{A}{1.2}{1.3}. This way you could store the values directly instead of extracting them afterwards. – Timm Mar 11 '17 at 00:01