2

MWE:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc,intersections,through,backgrounds,matrix,patterns}

\begin{document}

    \begin{tikzpicture}
    \draw[<->] (0,8)--(0,0)--(8,0); 
    \draw[name path = A] (0,0) ..controls (3,8) and (4,8) .. (7,0) node[above right]{$A$};
    \draw[name path = B] (0,2)--(7,5) node[right]{$B$};

    \path [name intersections={of=A and B, by = {I1,I2}}];

    \draw[dashed] let \p1 = (I1) in (\x1,0) node[below]{$k^*$} --(\x1,\y1)--(0,\y1); 

    \end{tikzpicture}

\end{document}

If you compile this second, you will notice that there are two intersections between A and B which I have specified thanks to @marmot's answer here.

I'd like to know if there's a way I can use the x and y-components of both intersections in the \draw command beneath the \path command.

For instance, something like this (my own creation - it doesn't work):

\draw[dashed] let {\p1,\p2} = {(I1),(I2)} in (\x1,0) node[below]{$k^*$} --(\x1,\y2)--(0,\y2);

Thev
  • 1,568
  • 3
    Try let \p1=(point1), \p2=(point2) in ... instead – koleygr Oct 17 '18 at 16:49
  • 2
    You do not need calc for that: \draw (I1-|O) -- (I1|-I2)-- (O|-I2); along with \coordinate (O) at (0,0). That is, you can mix x and y components of coordinates without calc. –  Oct 17 '18 at 16:53

1 Answers1

4

kolegyr has provided you with the relevant information on the calc syntax:

 \draw[dashed] let \p1=(I1),\p2=(I2) in (\x1,0) node[below]{$k^*$} --(\x1,\y2)--(0,\y2);

However, in this case you do not even need calc, without it the code becomes even shorter. This is explained very nicely in this beautiful answer.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}

    \begin{tikzpicture}
    \draw[<->] (0,8)--(0,0) coordinate (O) --(8,0); 
    \draw[name path = A] (0,0) ..controls (3,8) and (4,8) .. (7,0) node[above right]{$A$};
    \draw[name path = B] (0,2)--(7,5) node[right]{$B$};

    \path [name intersections={of=A and B, by = {I1,I2}}];

    %\draw[dashed] let \p1 = (I1) in (\x1,0) node[below]{$k^*$} --(\x1,\y1)--(0,\y1); 
    \draw[dashed] (I1-|O) node[below]{$k^*$} -- (I1)-- (O|-I2); 
    \end{tikzpicture}

\end{document}

enter image description here