2

Main Question

I want to change all properties of certain TikZ elements in the style of TikZ’ append. However, unlike its name suggests, append provides only defaults. By contrast, I wish to override any detailed settings made in the specific TiKZ commands. Is there any general way to do this?

I noticed that the handle every axis plot post in PGF Plots does something similar, but I lack the knowledge to translate its source to my problem.

Example

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \tikzset{every path/.append style={dashed,draw=red}}
    \draw[dotted]        (0,0) -- (1,1);
    \draw[dotted,dashed] (0,1) -- (1,0);
\end{tikzpicture}
\end{document}

Output of example code

Here, the dotted argument of the \draw command superseeds the general style dashed by append. Only literally appending the dashed property (second line) works.

I am looking for something to write at the beginning of the tikzpicture looking like:

\tikzset{every path/.override style={dashed}}

and causing all lines in the above to be dashed. For me it would suffice to explicitly override the dotted property here.

Actual Application

I have a plot file generated with tikzplotlib (using add_axis_environment=False) featuring dashed lines and I want to change the dash pattern without manually changing the file. I know I could programmatically modify the plot file, but then my format specifications would not be bundled in one place (my TEX file) any more.

  • Append appends to every path, i.e. to the defaults of that key. But the every path key is executed before any of the settings for a single path apply (this is a usual pattern to allow local overrides for global configs). So you are setting the wrong key… – TeXnician Jul 16 '19 at 14:25
  • Do you know in advance which effects you want to nullify? – TeXnician Jul 16 '19 at 14:26
  • @TeXnician: Do you know in advance which effects you want to nullify? – Yes, see the last section. – Wrzlprmft Jul 16 '19 at 14:31
  • Well, it was more a question which effect you want to nullify in the sense of "is it a specific set of keys or may it be arbitrary"? In the first case one could locally undeclare these keys. If it's the last one we'll have to wait for a TikZpert. – TeXnician Jul 16 '19 at 14:34
  • @TeXnician: I am not fully sure I got you right, but please see my edit. – Wrzlprmft Jul 16 '19 at 14:40
3

If you just want to "nullify" the effect of a style, you can redefine it:

\tikzset{dotted/.style={dashed}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.