# TikZ: cannot extract coordinate from intersection point

I am applying the solution proposed in this answer in order to automatically draw a vertical line at the point where to functions intersect. That solution implies creating a new commands that receives the coordinate as input and gives the x and y coordinates as output. Yet, I get the error

Package tikz Error: Cannot parse this coordinate.

A MWE is below:

\documentclass[tikz,convert=false]{standalone}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usetikzlibrary{calc}

\makeatletter
\newcommand{\gettikzxy}[3]{%
\tikz@scan@one@point\pgfutil@firstofone#1\relax
\edef#2{\the\pgf@x}%
\edef#3{\the\pgf@y}%
}
\makeatother

\begin{document}

\begin{tikzpicture}[scale=0.8,domain=0.8:13]
% Axis
\draw[thick] [->] (0,0) -- (14,0);
\draw[thick] [->] (0,0) -- (0,7);
\node at (14,-0.5) {$A$};
\node at (-0.5,7) {$B$};
% Functions
\draw[thick,name path=MR] plot (\x,{7-0.5*\x}) node[right] {{\small MR}};
\draw[thick,name path=PC] plot (\x,{0.5*\x}) node[right] {{\small PC}};
% Equilibrium
\draw[name intersections={of=MR and PC,by={equi1}}];
\fill (equi1) circle (3pt) node {};
\gettikzxy{equil1)}{\ax}{\ay}
\draw[thick,name path=VPC] [-] (\ax,0) -- (equi1);
\end{tikzpicture}

\end{document}

• Independently of your error (I think something concerning equi1 vs. equil1 might be an issue), there is an easier way to get individual coordinates: \draw[thick,name path=VPC] [-] let \p1 = (equi1) in (\x1,0) -- (equi1);. Look at the pgfmanual's Section 14.15, The Let Operation, if you're interested. – wrtlprnft Apr 18 '16 at 16:42
• This would also work in your case: \draw[thick,name path=VPC] [-] (0,0 -| equi1) -- (equi1);. Less powerful than the let syntax, but quicker to type. The -| “operator” takes the horizontal part of its left operand and the vertical part of its right operator, which is kind of suggested by its symbol. Conversely, |- is also available. – wrtlprnft Apr 18 '16 at 16:48
• I'm sorry but indeed the problem was due to notation error. However, I had no idea of the |- "operator". I will switch to that one. The let seems to be more cumbersome. – luchonacho Apr 19 '16 at 6:55

You don't need this new command. You can use the Tikz operator |- to draw a vertical line that stops at the height of another coordinate/node.

In this case we define O (as Origin) at 0,0 and we use it as reference. Although it's not necessary — as you could say (equi1|-0,0); — it's just easier to reuse.

Also, you can add nodes to the axes paths without having to define them separately.

## Code

\documentclass[tikz,margin=10pt]{standalone}
\usetikzlibrary{calc, intersections}

\begin{document}

\begin{tikzpicture}[scale=0.8,domain=0.8:13]
% Axis
\coordinate (O) at (0,0);
\draw[thick] [->] (0,0) -- (14,0) node[below right] {$A$};
\draw[thick] [->] (0,0) -- (0,7) node[above left] {$B$};
% Functions
\draw[thick,name path=MR] plot (\x,{7-0.5*\x}) node[right] {{\small MR}};
\draw[thick,name path=PC] plot (\x,{0.5*\x}) node[right] {{\small PC}};
% Equilibrium
\draw[name intersections={of=MR and PC,by={equi1}}];
\fill (equi1) circle (3pt) node {};

\draw[thick,name path=VPC] (equi1) -- (equi1|-O);

% don't need these
%\gettikzxy{equil1)}{\ax}{\ay}
%\draw[thick,name path=VPC] [-] (\ax,0) -- (equi1);
\end{tikzpicture}
\end{document}