11

The initial code is

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations} 
\usetikzlibrary{decorations.markings}
\begin{document}

\pgfkeys{
/pgf/decoration/.cd,
pre fraction/.style={pre length=#1*\pgfmetadecoratedpathlength},
post fraction/.style={post length=#1*\pgfmetadecoratedpathlength}
}

\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (4,2);

\draw [  
decoration={ 
curveto,
pre=moveto, pre fraction=0,
post=moveto, post fraction=0.3}, decorate, red, ultra thick] (A) to[out=0,in=-90](B);

\draw [decoration={curveto,
                   pre=moveto, pre fraction=0.7,
                   post=moveto, post fraction=0},%
       decorate, blue, ultra thick,dotted] (A) to [out=0,in=-90](B); 

\path [  
decoration={ 
     markings, mark=at position .7  with {\arrow[red,line width=2pt]{>}}},  
     decorate  ] (A) to[out=0,in=-90](B);         
\end{tikzpicture} 

\end{document}

enter image description here

There is a problem if I want to replace to by edge . In some cases, the replacement is useful.

Is it possible to use making with edge ? and how ?

I think that the problem comes from that the edge operation works like a to operation that is added after the main path has been drawn. I get often the error that marking does not work on an empty path !

8

Finally I found the answer here: texblog.net in the article: Decorate a TikZ path. (Author: Stefan Kottwitz thanks!). I do not know why I did not think earlier. There are many questions related to the use of edge that can be resolved like this, example: Strange arrow mark with TikZ edge and anchors.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations} 
\usetikzlibrary{decorations.markings}
\begin{document}

\begin{tikzpicture}
  \tikzset{every loop/.style={min distance=20mm,in=0,out=60,looseness=10}} 

   \draw (0,0) node[circle,draw]{A} edge[red,loop]  ();    
 \path[decoration={ 
     markings, mark=at position .7  with {\arrow[blue,line width=1pt]{>}}}] (0,0) node[circle]{A} edge[decorate,loop]  ();
\end{tikzpicture}

\end{document}

enter image description here

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.