pgf icon indicating copy to clipboard operation
pgf copied to clipboard

`double` does not work as `scope` parameter

Open ismagilli opened this issue 2 years ago • 5 comments

Brief outline of the bug

I drew paths inside scope and set various line parameters as scope parameters, but the double parameter does not work. Other parameters work fine, e.g. red (see MWE).

Minimal working example (MWE)

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

    \begin{tikzpicture}

        \draw[double] (0,0) -- (1,1);

        \begin{scope}[xshift=1cm, double]
            \draw (0,0) -- (1,1);
        \end{scope}

        \begin{scope}[xshift=2cm, red]
            \draw (0,0) -- (1,1);
        \end{scope}

    \end{tikzpicture}

\end{document}

test_1

ismagilli avatar May 15 '22 12:05 ismagilli

It's a path option so you need to add it to every path style as scope parameter or to similar style keys. That's why it won't enable from scope.

ilayn avatar May 15 '22 12:05 ilayn

No, there is something fishy. For example very thick is also a path option but propagates correctly to the scoped paths. That said, double is a bit of a special case, because it needs to perform special setup and teardown on each path it applies to, so this might not be easy to fix.

hmenke avatar May 15 '22 18:05 hmenke

double is currently (implemented as) a tikz mode, like draw, fill, and clip. All mode changes are collected (through \tikz@addmode and stored in \tikz@mode), then used after all modes get reset, at the end of every path (\tikz@finish). So \begin{scope}[double] is not effective, just like \begin{scope}[fill]. As Henri commented, "this might not be easy to fix".

Also the doc for double lacks intro to special value none and empty value, which make it more like a mode. https://github.com/pgf-tikz/pgf/blob/acfa21c9fb09909ce5fa8f9760f0a706e32753e5/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex#L192-L203 https://github.com/pgf-tikz/pgf/blob/acfa21c9fb09909ce5fa8f9760f0a706e32753e5/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex#L2230-L2245

muzimuzhi avatar May 15 '22 19:05 muzimuzhi

Should work is a different story. But the proper way is to put things in right places. I don't mind if this thing permeates everything.

ilayn avatar May 15 '22 19:05 ilayn

@a-is Just thought of, you can use \begin{scope}[every path/.append style={double}] as a workaround.

muzimuzhi avatar Jun 06 '22 22:06 muzimuzhi