4

Suppose my tikzset definitions include:

  vector/.style={%
     decoration={markings, mark= at position 0.5 with {\arrow{Triangle[length=2.5mm, width=2mm]}}}, postaction={decorate}
  },

And suppose I need to use the same arrow style elsewhere. How do I define some arrow style and refer it later? Something like (which doesn't work):

\tikzset{%
myarrow/.style={
   \arrow{Triangle[length=2.5mm, width=2mm]}
},
vector/.style={%
     decoration={markings, mark= at position 0.5 with {myarrow}}, postaction={decorate}
  },
}
0

1 Answer 1

7

Use the keyhandler /.tip:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,decorations.markings}
\tikzset{
  myarrow/.tip={Triangle[length=2.5mm, width=2mm]},
  vector/.style={
    decoration={markings, mark= at position 0.5 with {\arrow{myarrow}}}
  },
}
\begin{document}
\begin{tikzpicture}
  \draw[-myarrow](0,0)--(2,0);
  \draw[myarrow-{myarrow[red]}](0,-.25)--+(2,0);
  \draw[postaction={vector,decorate}](0,-.5)--+(2,0);
\end{tikzpicture}
\end{document}

enter image description here

0

You must log in to answer this question.

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