6

Is it possible to use postaction in a tikzstyle command? If yes, how?

\documentclass{standalone}
\usepackage[ngerman]{babel}
\usepackage{tikz}
%
\begin{document}
\begin{tikzpicture}
 \tikzstyle{ground/.style}={%
    \draw[postaction={draw,line width=0.35mm,red,dash pattern=on 3pt off 5pt,
          dash phase=4pt,thick}]
    [blue,dash pattern= on 3pt off 5pt,thick,rounded corners]};
 \draw[ground] (0,0) -- (3,3);
\end{tikzpicture}
\end{document}

1 Answer 1

10

Personally I would use \tikzset over \tikzstyle, but all in all your code works pretty well if you remove the unnecessary \draw.

pattern

\documentclass{standalone}
\usepackage[ngerman]{babel}
\usepackage{tikz}
%
\begin{document}
\begin{tikzpicture}
 \tikzset{ground/.style={%
    postaction={draw,line width=0.35mm,red,dash pattern=on 3pt off 5pt,
          dash phase=4pt,thick},
        blue,dash pattern= on 3pt off 5pt,thick,rounded corners}}
 \draw[ground] (0,0) -- (3,3);
\end{tikzpicture}
\end{document}
2
  • 3
    ; (semicolon) after \tikzset is superfluous. :-)
    – Zarko
    Commented Jan 19, 2018 at 14:23
  • Many thanks for the quick answer, it works like a charm.
    – Jürgen
    Commented Jan 19, 2018 at 14:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .