Consider the following LaTeX manuscript featuring a TikZ picture that draws three parallel horizontal line segments. The second line segment is double-stroked. In the beginning of the picture, the line width is set to 2mm inside a pdfinterruptpath
environment.
The expected behavior is that all three lines would have the same width. Instead, the 1st and 3rd lines have width 2mm, whereas the double-stroked line has width 0.4pt. See attached image file.
\documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \begin{pgfinterruptpath} \pgfsetlinewidth{2mm} \end{pgfinterruptpath} \draw (0,0) -- (1,0); \draw[double] (0,1) -- (1,1); \draw (0,2) -- (1,2); \end{tikzpicture} \end{document}
This bug is due to the fact that the pgfinterruptpath
environment attempts to restore the original line width at the end of the environment, but instead of doing it properly by calling \pgfsetlinewidth
, it simply restores the macro \pgflinewidth
. This causes a broken state: the effective line width is the one set inside the pgfinterruptpath
environment, namely 2mm
, but the \pgflinewidth
macro expands to 0.4pt
.
However, in my opinion, the way to fix this bug is not by using\pgfsetlinewidth
at the end of the environment, but rather by not attempting to save-and-restore the line width to begin with, since no other path property (e.g. stroke color) gets this special treatment.
Specifically, in my opinion the bug should be fixed as follows.
\pgfinterruptpath
delete the line \edef\pgfscope@linewidth{\the\pgflinewidth}%
.\endpgfinterruptpath
delete the line \global\pgflinewidth=\pgfscope@linewidth%
.
I'm not sure what should be the proper behaviour here. Both the current and your proposed behaviour seem broken to me.
See https://github.com/pgf-tikz/pgf/issues/442