2

I can not find a way to effectively identify coordinates of the point, if used in the command let in the draw path. My example:

  \draw[gray] let \p1=(D), \p2=(intersect), \p3=(C) in (\x1,\y2)
           -- +(-\x1,0) node[left, red]{$f(c)$} -- (\x1,\y2) node[above, red]{$F$}
           -- (\x3,\y2) node[right, red]{$E$};

Now I would like to create named coordinate for node with text $F$:

  \coordinate (F) at (\x1,\y2);

but with error. How I could I solve it? Thanks.

JardaFait
  • 3,922

3 Answers3

8

You can just name the node ... (\x1,\y2) node[...] (F) {$F$} and then you have access to the node via (F), so you can do something like:

\draw (F) circle (5pt);

If you really need the x and y coordinates you can use the solution from Extract x, y coordinate of an arbitrary point in TikZ:

enter image description here

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

% https://tex.stackexchange.com/questions/33703/extract-x-y-coordinate-of-an-arbitrary-point-in-tikz/33706#33706 \newdimen\XCoord \newdimen\YCoord \newcommand*{\ExtractCoordinate}[1]{\path (#1); \pgfgetlastxy{\XCoord}{\YCoord};}%

\begin{document} \begin{tikzpicture} \coordinate (C) at (0,0); \coordinate (D) at (2,0); \coordinate (intersect) at (1,1);

\draw[gray] let \p1=(D), \p2=(intersect), \p3=(C) in (\x1,\y2) -- +(-\x1,0) node[left, red]{$f(c)$} -- (\x1,\y2) node[above, red] (F) {$F$} -- (\x3,\y2) node[right, red] {$E$};

\draw (F) circle (5pt);% can just use the node name

\ExtractCoordinate{F} node [below] (F) {$(\XCoord,\YCoord)$} \end{tikzpicture} \end{document}

Peter Grill
  • 223,288
2

You can use the orthogonal intersections to avoid let operation, hence the calc library for such applications.

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\coordinate (C) at (2cm,2cm);
\coordinate (D) at (-2cm,-3cm);
\coordinate (intersect) at (1cm,1cm);

\draw[thick,gray] (D |- intersect) coordinate (F) -- 
+([scale=-1]D|-{{(0,0)}}) node[left, red]{$f(c)$} -- 
(F) node[above, red] {$F$}--
(C|-intersect) node[right, red]  {$E$};

\end{tikzpicture}
\end{document}

enter image description here

percusse
  • 157,807
1

Thanks to @Jake, the solution of my problem is trivial:

  \draw[gray] let \p1=(D), \p2=(intersect), \p3=(C) in (\x1,\y2)
              -- +(-\x1,0) node[left, red]{$f(c)$} 
              -- (\x1,\y2) node[above, red]{$F$} coordinate (F) at (\x1,\y2) 
              -- (\x3,\y2) node[right, red]{$E$}; 
JardaFait
  • 3,922