2

is it possible to ask tikz to extend an inclined line (not parallel to x and y) to a value xmax or ymax as is done between a horizontal and a vertical line.

i know it's feasible by having the intersection calculated by tikz, but as i have a lot of line to stop i would like to avoid

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}


\begin{document}
    \begin{tikzpicture}
    \draw (5,0) coordinate(A) -- ++ (0,3);
    \node[below]at (A){A};
    \draw (0,1) coordinate (B) -- (A|-B);
    \node[left]at (B){B};
    \draw(B) -- ++(10:6);

    \end{tikzpicture}
\end{document}
5

You can start the path in the correct direction and then use intersection:

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}
    \draw (5,0) coordinate(A) -- ++ (0,3) coordinate (A');
    \node[below]at (A){A};
    \draw (0,1) coordinate (B) -- (A|-B);
    \node[left]at (B){B};
    \draw (B) -- ++(10:1)coordinate(B') --(intersection of  A--A' and B--B');

    \end{tikzpicture}
\end{document}

enter image description here

  • 1
    Just a note: this intersection coordinate system is not documented, and according to a comment in pgfmanual-en-tikz-coordinates.tex (line 468) it is considered deprecated. (I don't know why, the implementation obviously hasn't been removed, as it still works.) – Torbjørn T. Mar 10 '18 at 19:25
  • interestingly, op in question ask for solution without use of intersections, but than accept answer using them. i'm slightly confused now :-(. – Zarko Mar 10 '18 at 20:28
2

enter image description here

with small knowledge of geometry:

\documentclass[tikz, margin=3mm]{standalone}

\begin{document}
    \begin{tikzpicture}
\draw (5,0) coordinate[label=below:A] (A) -- ++ (0,3);
\draw (0,1) coordinate[label= left:B] (B) -- (A|-B);
\draw[red] (B) -- ++(10:{5/cos(10)});
    \end{tikzpicture}
\end{document}

where 5 is distance between coordinate and line above coordinate A, resented by black horizontal line.

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.