8

in my document i have a lot of lines like this:

LineExample

I usually do this with a code like this:

\begin{tikzpicture}[node distance = 5cm]
 \node (a) {};
 \node (b) [right of=a] {};
 \draw[red] (a) -- (b);
 \draw[blue, decorate, decoration={snake}] (a) -- (b);
\end{tikzpicture}

I thought it would be easier if i defined an appropriate tikzstyle, so i tried with something like:

\tikzstyle{LL} =[draw, postaction={decorate, blue, draw}, decoration={snake}]

but i can't find a way to make the straight line red... any help will be appreciated.

  • \tikzstyle{LL} =[draw=red, postaction={decorate, blue, draw}, decoration={snake}] – JLDiaz May 12 '14 at 16:50
  • 2
    Also, \tikzstyle syntax is deprecated. A better approach: \tikzset{LL/.style ={draw=red, postaction={decorate, blue, draw}, decoration={snake}}} – JLDiaz May 12 '14 at 16:51
9

You can use

\tikzset{
LL/.style={
  draw=red, 
  postaction={decorate,draw=blue},
  decoration={snake}
  }
}    

notice the change to the more modern \tikzset syntax. A complete example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\tikzset{
LL/.style={
  draw=red, 
  postaction={decorate,draw=blue},
  decoration={snake}
  }
}    

\begin{document}

\begin{tikzpicture}[node distance = 5cm]
 \node (a) {};
 \node (b) [right of=a] {};
 \draw[LL] (a) -- (b);
\end{tikzpicture}

\end{document}

enter image description here

| improve this answer | |

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.