5

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 Answers1

2

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

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • 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 01 '17 at 09:39
  • Anything drawn before the \clip will stay. Anything drawn after will be clipped. – John Kormylo Jan 01 '17 at 16:57