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:


%% Language and font encodings


\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$}};%
    \fill #4 circle (0.09);%
    \expandafter\xdef\csname colvec#3\endcsname%




Coordinates are $A=\colvecA, B=\colvecB$.


enter image description here

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?

  • 2
    So, this? tex.stackexchange.com/questions/18292/… Mar 10, 2017 at 13:44
  • Why don't you define your drawanchor command 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, 2017 at 0:01
  • As my question states, I know I can do this, but I want to also extract the coordinates of a point for which coordinates were not given.
    – spraff
    Mar 11, 2017 at 9:30
  • 1
    Did you ever look at the link I posted? Seems to me that is exactly what you're after ... Mar 18, 2017 at 0:04
  • @TorbjørnT. Either this is an exact duplicate or it is simply too unclear to be answerable. Or I'm very confused, which is certainly the case.
    – cfr
    Mar 18, 2017 at 2:28

1 Answer 1


Here is a method that utilize \pgftransforminvert.

But this macro is pretty inaccurate and one better employ its own inverse matrix calculator.


% before this command, \pgf@x is the real x-coordinate
    { % not to ruin anything
% after this command, \abs@x is the abstract x-coordinate

        (3,3)coordinate(A)circle(.05)node[above left]{We put $A$ here $\searrow$};
        (3,3)coordinate(B)circle(.05)node[above left]{We put $B$ here $\searrow$};
        (3,3)coordinate(C)circle(.05)node[above left]{We put $C$ here $\searrow$};

    \draw(\abs@x,\abs@y)circle(.1)node[below right]{$\nwarrow$ The estimated coordinate is (\abs@x,\abs@y)};
    \draw(\abs@x,\abs@y)circle(.1)node[below right]{$\nwarrow$ The estimated coordinate is (\abs@x,\abs@y)};
    \draw(\abs@x,\abs@y)circle(.1)node[below right]{$\nwarrow$ The estimated coordinate is (\abs@x,\abs@y)};


  • I don't understand. Why don't the answers to the linked question do the job? Why all this?
    – cfr
    Mar 18, 2017 at 2:27
  • @cfr because \pgf@xy and \pgf@yx are essential but both @Jack and @Paul Gaborit's answers just ignore them. The asker @Martin Scharrer♦ was aware of it. But he then commented there[sic] are zero; for orthogonal coordinate systems which is definitely incorrect.
    – Symbol 1
    Mar 18, 2017 at 2:45
  • Try [x={(0,1)},y={(1,0)}] with their solutions.
    – Symbol 1
    Mar 18, 2017 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.