# Tikz obtain node coordinates

In tikzpicture, how do I get a single coordinate of a node?

This is the circuit I'm making, and I need to know the x coordinate of the node (opamp.out) so that i can make R2 vertically aligned with that node, and link it with a vertical line. This is my code for R2:

\draw (opamp.-) to [short,*-] ++(0,1) node{} to [R,l=$R_2$] ++(2,0);

where, instead of ++(2,0), I would like to input ++(opamp.out.x-opamp.-.x,0);

• \draw let \p1=(opamp.out),\p2=(opamp.-) in (opamp.-) to [short,*-] ++(0,1) node{} to [R,l=$R_2$] ++($(\x1,0)-(\x2,0)$); Note that you have to \usetikzlibrary{calc} – Astrinus Dec 11 '14 at 9:55
• Glad it worked. I've not tested it XD. I'll turn into an answer. – Astrinus Dec 11 '14 at 10:05
• Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – Astrinus Dec 12 '14 at 17:14

An alternative: use of orthogonal coordinate

Code

\documentclass[border=10pt,varwidth]{standalone}
\usepackage{tikz}
\usepackage[american,siunitx]{circuitikz}
\usetikzlibrary{calc,positioning}
\begin{document}

An alternative solution

\begin{circuitikz}
\draw
(0,0) node[op amp](opamp){}
(opamp.out) to[short,*-o] (2,0)node[]{} node[right]{$v_{out}$};
\draw (opamp.-) -- ++(-0.2,0) to[R,l_=$R_1$] ++ (-2,0)node[ground,rotate=-90]{};
\draw (opamp.+) to[short,-o] ++ (-0.5,0)node[left]{$V_{in}$};

\draw (opamp.-) to [short,*-] ++(0,1) node{} to [R,l=$R_2$] ([yshift=1cm]opamp.- -|opamp.out);
\end{circuitikz}

\medskip

@Astrinus' solution

\begin{circuitikz}
\draw
(0,0) node[op amp](opamp){}
(opamp.out) to[short,*-o] (2,0)node[]{} node[right]{$v_{out}$};

\draw (opamp.-) -- ++(-0.2,0) to[R,l_=$R_1$] ++ (-2,0)node[ground,rotate=-90]{};
\draw (opamp.+) to[short,-o] ++ (-0.5,0)node[left]{$V_{in}$};

\draw let \p1=(opamp.out),\p2=(opamp.-) in (opamp.-) to [short,*-] ++(0,1)
node{} to [R,l=$R_2$] ++($(\x1,0)-(\x2,0)$);
\end{circuitikz}

\end{document}


\draw let \p1=(opamp.out),\p2=(opamp.-) in (opamp.-) to [short,*-] ++(0,1) node{} to [R,l=$R_2$] ++($(\x1,0)-(\x2,0)$);

Note that you have to \usetikzlibrary{calc}.

The let syntax let you alias the points with names \p1 ... \pN, where N is the number of points. Then, after in, you could access points' coordinates with the syntax \x1 .. \xN and \y1 .. \yN (I think it's possible to access also polar coordinates but honestly I don't remember the syntax :-8), matching the order of \p assignments.

The library calc let you make calculations with coordinates and get the resulting coordinates, with the syntax ($<calculations>$).

Look at pgfmanual.pdf or at "TikZ pour l'impatient" if you read french (I can't speak french at all, but since my mother language is neo latin I had absolutely no problem reading it).