4

I am trying to draw two lines of different width intersecting at a point. How to make slanted line's cap in triangle shape (or some other) so that the point where two lines join does not look discontinuous?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
 \draw[name path=al] (0,1.4)--(0,1.9);
\path [name path=al2] (.3,1.5)--++(150:.5);
\path [name intersections={of=al and al2,by=A}];
\draw [ultra thick](.3,1.5) --(A);
\end{tikzpicture}
\end{document}

There are possible solutions at Bad intersection of lines in TikZ but they deal with the lines with the same width.

enter image description here

1

While the arrows.meta includes a Triangle Cap and Round Cap, your best bet is to draw too long and clip the excess.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections,calc}
\begin{document}
\begin{tikzpicture}
 \draw[name path=al] (0,1.4)--(0,1.9);
\path [name path=al2] (.3,1.5)--++(150:.5);% will affect bounding box
\path [name intersections={of=al and al2,by=A}];
\begin{scope}
  \clip (current bounding box.south east) rectangle ($(A)+(0,1pt)$);% so as not to flatten the top
  \draw [ultra thick] (.3,1.5)--++(150:.5);
\end{scope}
\end{tikzpicture}
\end{document}

demo

  • Let me remove {scope} environment and move clip command to the main frame. Am I right to expect that anything outside \clip (current bounding box.south east) rectangle ($(A)+(0,1pt)$); will be clipped? If yes than why path al is not getting clipped outside this rectangle? – praveen pathak Jan 1 '17 at 9:39
  • Anything drawn before the \clip will stay. Anything drawn after will be clipped. – John Kormylo Jan 1 '17 at 16:57

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.