[Tex/LaTex] tikz Join line segments of different thickness with miter

svgtechnical-drawingtikz-pgf

Reading "tikz Multi-segment Line of Varying Thickness" provides a good explanation to join segments, but it seems that the rounded corner transition is the only way to do this nicely?

I would like to join segments of different thickness with a nice sharp miter, getting similar results in the case of these two:

Lines of the same thickness have a nice miter:

\draw [very thick] (0.45,-0.2) to (0.45,0.17) to (0.75,-0.17) to (0.75,0.2);

But if I try to join a thick line to a thin line, there is an artifact:

\draw [very thick] (1.3,0.2) to (1,0) to (1.3,-0.2);
\draw (1,0) to (1.3,-0.2) to (1.3,0.2) to (1,0);    

nice miter same thickness, but nasty joints between two

The resulting mitre would appear thus (except not edited by hand):

desired mitre

Best Answer

This is a work around using \clip.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \clip (1.3,0.2) -- (1,0) -- (1.3,-0.2) -- (1.3,0.2) -- cycle;
  \draw [line width=2pt] (1.3,0.2) to (1,0) to (1.3,-0.2);
  \draw (1.3,-0.2) to (1.3,0.2);
\end{tikzpicture}
\end{document}

enter image description here

Note that a line width of 2pt will give a resultant line width of 1pt as the other part is clipped off. So you have to adjust properly.

If this forms a part of bigger diagram, the \clipping part may be enclosed in a scope so as to limit the clipping:

\begin{scope}
   \clip (1.3,0.2) -- (1,0) -- (1.3,-0.2) -- (1.3,0.2) -- cycle;
   \draw [line width=2pt] (1.3,0.2) to (1,0) to (1.3,-0.2);
   \draw (1.3,-0.2) to (1.3,0.2);
\end{scope}