# Define tikzstyle with postaction

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}


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

\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}

• ; (semicolon) after \tikzset is superfluous. :-) – Zarko Jan 19 '18 at 14:23
• Many thanks for the quick answer, it works like a charm. – Jürgen Jan 19 '18 at 14:36