Menu

#443 Line width is ill-restored at the end of a pgfinterruptpath environment

v1.0 (example)
closed-fixed
nobody
None
5
2019-12-01
2017-08-07
Evan Aad
No

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.

  1. In the definitions of \pgfinterruptpath delete the line \edef\pgfscope@linewidth{\the\pgflinewidth}%.
  2. In the definition of \endpgfinterruptpath delete the line \global\pgflinewidth=\pgfscope@linewidth%.
1 Attachments

Discussion

  • Henri Menke

    Henri Menke - 2018-12-27

    I'm not sure what should be the proper behaviour here. Both the current and your proposed behaviour seem broken to me.

     
  • Stefan Pinnow

    Stefan Pinnow - 2019-12-01
    • status: open --> closed-fixed
     
  • Stefan Pinnow

    Stefan Pinnow - 2019-12-01