loopspace / spath3

TikZ/PGF package for manipulating soft paths, includes the knots and calligraphy TikZ libraries.
16 stars 2 forks source link

Can `every strand/.style` be added to `tikzpicture` environment? #25

Closed Andrew15-5 closed 1 year ago

Andrew15-5 commented 1 year ago

I want to modify example from https://github.com/loopspace/spath3/issues/22#issuecomment-1454947343 like this (just as a silly example):

\begin{tikzpicture}[
    arrow/.style={-Triangle},
    every strand/.style={only when rendering/.style={arrow}},
  ]
  \samecode
  \begin{knot}
    \strand (a.east) -- (b.west);
  \end{knot}
\end{tikzpicture}

But instead of

image

I get

image

There are probably more valid examples of using every strand/.style but it is a useful "command", right? Can it be added?

loopspace commented 1 year ago

Page 10 of the knots documentation covers this. The knot keys are in their own directory, knot diagram, so if you want to define a key outside the knot environment then you need to use a prefix.

Andrew15-5 commented 1 year ago

Right, thanks. But I have a following question. If this works:

\begin{tikzpicture}[
    arrow/.style={-Triangle},
    knot diagram/every knot diagram/.style={only when rendering/.style={arrow}},
  ]
  \samecode
  \begin{knot}[
      % every knot diagram/.style={only when rendering/.style={arrow}},
    ]
    \strand (a.east) -- (b.west);
  \end{knot}
\end{tikzpicture}

Then why this doesn't work:

\begin{tikzpicture}[
    arrow/.style={-Triangle},
    % knot diagram/every knot diagram/.style={only when rendering/.style={arrow}},
  ]
  \samecode
  \begin{knot}[
      every knot diagram/.style={only when rendering/.style={arrow}},
      % knot diagram/every knot diagram/.style={only when rendering/.style={arrow}}, % This also doesn't work
    ]
    \strand (a.east) -- (b.west);
  \end{knot}
\end{tikzpicture}

Do I read documentation incorrectly?

image

loopspace commented 1 year ago

The key every knot diagram is processed at the start of the knot environment, so setting it in the options on that environment is too late.

Andrew15-5 commented 1 year ago

Am I right in understanding that there is no way to set every knot diagram/.style without adding the knot diagram/ prefix? Because this prefix is only implied in the knot environment but setting every knot diagram/.style in it is too late.

loopspace commented 1 year ago

That is correct. I try to keep from polluting the main tikz namespace by putting my keys in families.