Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pgf-tikz-bot opened this issue Aug 7, 2017 · 6 comments
Closed
Assignees
Milestone

Comments

@pgf-tikz-bot
Copy link

Migrated from SourceForge
Author: evan-aad
Timestamp: 2017-08-07 16:58:12.831000

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%.
@pgf-tikz-bot
Copy link
Author

Migrated from SourceForge
Author: hmenke
Timestamp: 2018-12-27 22:05:18.836000

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

@hmenke hmenke removed the open label Apr 2, 2019
@hmenke hmenke self-assigned this Jul 13, 2019
@hmenke hmenke added this to the 3.1.5 milestone Nov 5, 2019
@hmenke
Copy link
Member

hmenke commented Nov 28, 2019

That is by design, pgfinterruptpath is not a scope. This works as expected.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \begin{scope}
    \begin{pgfinterruptpath}
      \pgfsetlinewidth{2mm}
      \draw (0,-1) -- (1,-1);
    \end{pgfinterruptpath}
  \end{scope}
  \draw (0,0) -- (1,0);
  \draw[double] (0,1) -- (1,1);
  \draw (0,2) -- (1,2);
\end{tikzpicture}
\end{document}

@hmenke hmenke closed this as completed Nov 28, 2019
hmenke added a commit to hmenke/pgf that referenced this issue Nov 28, 2019
@hmenke hmenke reopened this Nov 28, 2019
@hmenke hmenke closed this as completed Nov 28, 2019
@hmenke
Copy link
Member

hmenke commented Nov 28, 2019

@EvanAad Are you the same person as evan-aad on SourceForge?

@EvanAad
Copy link

EvanAad commented Nov 29, 2019 via email

@hmenke
Copy link
Member

hmenke commented Nov 29, 2019

@EvanAad Great! I've recently acted on some of the issues that you opened, but of course you weren't notified. Maybe you want to have a look and comment:
https://github.com/pgf-tikz/pgf/issues?q=is%3Aissue+sort%3Aupdated-desc+evan-aad

@EvanAad
Copy link

EvanAad commented Nov 29, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants