5

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

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}
|improve this answer|||||
  • 2
    ; (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

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.