SHARE
TWEET

Arrows

a guest Mar 4th, 2014 16 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. \documentclass[tikz,border=5pt]{standalone}
  2. \usetikzlibrary{decorations.markings}
  3. \usepackage{ifthen}
  4. \newcommand{\forloop}[5][1]%
  5. {%
  6. \setcounter{#2}{#3}%
  7. \ifthenelse{#4}%
  8.                 {%
  9.                 #5%
  10.                 \addtocounter{#2}{#1}%
  11.                 \forloop[#1]{#2}{\value{#2}}{#4}{#5}%
  12.                 }%
  13. % Else
  14.                 {%
  15.                 }%
  16. }%
  17. \newcounter{ct}
  18. \setcounter{ct}{1}
  19.  
  20. \newcommand{\arrowN}[1]{%
  21. \forloop{ct}{1}{\value{ct} < #1}%
  22. {%
  23. \pgfmathparse{\arabic{ct}/(1+#1)}\pgfmathresult,
  24. }%
  25. \pgfmathparse{\arabic{ct}/(1+#1)}\pgfmathresult
  26. \setcounter{ct}{1}}
  27.  
  28. \tikzset{
  29.    set arrow inside/.code={\pgfqkeys{/tikz/arrow inside}{#1}},
  30.    set arrow inside={end/.initial=>, opt/.initial=},
  31.    /pgf/decoration/Mark/.style={
  32.        mark/.expanded=at position #1 with
  33.        {
  34.            \noexpand\arrow[\pgfkeysvalueof{/tikz/arrow inside/opt}]{\pgfkeysvalueof{/tikz/arrow inside/end}}
  35.        }
  36.    },
  37.    arrow inside/.style 2 args={
  38.        set arrow inside={#1},
  39.        postaction={
  40.            decorate,decoration={
  41.                markings,Mark/.list={#2}
  42.            }
  43.        }
  44.    },
  45. }
  46. \begin{document}
  47.  
  48. \arrowN{3}
  49.  
  50. \clearpage
  51.  
  52. \begin{tikzpicture}
  53.    \begin{scope}[scale=2]
  54.        \node[label=below:$A$] (A) at (0,0) {};
  55.        \node[label=below:$B$] (B) at (2,0.25){};
  56.        \draw plot [smooth,tension=1]
  57.        coordinates {(A) (1,0) (1.14,-0.6) (0.5,-0.5) (0.5,0.5) (1.5,0) (B)}
  58.        [red,arrow inside={end=stealth,opt={scale=2}}{0.25, 0.5, 0.75}];
  59.        \draw [black] plot [smooth,tension=1]
  60.        coordinates {(A) (1,0) (1.14,-0.6) (0.5,-0.5) (0.5,0.5) (1.5,0) (B)};
  61.    \end{scope}
  62.    \draw [fill=black] (A) circle (1pt);
  63.    \draw [fill=black] (B) circle (1pt);
  64. \end{tikzpicture}
  65. \end{document}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top