1

I want to draw the following figure with tikz. Anyone have latex code please share it.

enter image description here

Torbjørn T.
  • 206,688
  • With some modifications you can use this. – vi pa Jan 23 '20 at 20:22
  • You could also modify this to get this. –  Jan 23 '20 at 20:31
  • 6
    Welcome to TeX.SX! The short answer is that, yes, this is possible but I have to warn you that questions of the form "Please draw this for me" that show no effort on the part of OP, often don't get answered. You will get more help if you post some code showing what you have tried and give a minimal working example. A quick search on TeX.SX for drawing functions (with tikz or pstricks) will give you an idea of where to start from. –  Jan 23 '20 at 22:02

1 Answers1

7

A very simple way of achieving this is

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[marrow/.style={double,double distance=#1,
    {Straight Barb[width=#1,length=-#1/3].}-{.Straight
    Barb[width=#1,length=#1/3]}},
    marrow/.default=20pt,shorten >=5pt,shorten <=5pt]
  \draw[marrow] (0,0) to[out=10,in=170] node {$a_1$} ++ (2,0) coordinate (aux);
  \draw[marrow] (aux) to[out=-10,in=170] node[pos=0.2] {$a_2$}   ++ (3,-2)  coordinate (aux);
  \draw[marrow] (aux) to[out=-10,in=-90] node {$a_2$}   ++ (2,1) coordinate (aux);
  \draw[marrow] (aux) to[out=90,in=10] node{$a_4$}  ++ (-2,1) coordinate (aux);
  \draw[marrow] (aux) to[out=-170,in=10] node[pos=0.8] {$a_5$}    ++ (-3,-2) coordinate (aux);
  \draw[marrow] (aux) to[out=-170,in=-170,looseness=3] node[pos=0.3] {$a_6$} (0,0);
\end{tikzpicture}
\end{document}

enter image description here

Unfortunately there are some artifacts.

So you may want to use decorations. This is a very quickly written adaptation of this answer.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{decorations,decorations.text} 
\pgfkeys{/tikz/.cd,
    outlined arrow width/.store in=\OutlinedArrowWidth,
    outlined arrow width=15pt,
    outlined arrow step/.store in=\OutlinedArrowStep,
    outlined arrow step=1pt,
    outlined arrow length/.store in=\OutlinedArrowLength,
    outlined arrow length=10pt,
}

\pgfdeclaredecoration{outlined arrow}{initial}
{% initial arrow butt
\state{initial}[width=\OutlinedArrowStep,next state=cont] {
    \pgfmoveto{\pgfpoint{\OutlinedArrowStep}{\OutlinedArrowWidth/2}}
    \pgfpathlineto{\pgfpoint{0.3\pgflinewidth}{\OutlinedArrowWidth/2}}
    \pgfpathlineto{\pgfpoint{\OutlinedArrowLength}{0pt}}
    \pgfpathlineto{\pgfpoint{0.3\pgflinewidth}{-\OutlinedArrowWidth/2}}
    \pgfpathlineto{\pgfpoint{1pt}{-\OutlinedArrowWidth/2}}
    \pgfcoordinate{lastup}{\pgfpoint{1pt}{\OutlinedArrowWidth/2}}
    \pgfcoordinate{lastdown}{\pgfpoint{1pt}{-\OutlinedArrowWidth/2}}
    \xdef\marmotarrowstart{0}
  }
  \state{cont}[width=\OutlinedArrowStep]{
    \ifdim\pgfdecoratedremainingdistance>\OutlinedArrowLength% continue the outlined path
     \pgfmoveto{\pgfpointanchor{lastup}{center}}
     \pgfpathlineto{\pgfpoint{\OutlinedArrowStep}{\OutlinedArrowWidth/2}}
     \pgfcoordinate{lastup}{\pgfpoint{\OutlinedArrowStep}{\OutlinedArrowWidth/2}}
     \pgfmoveto{\pgfpointanchor{lastdown}{center}}
     \pgfpathlineto{\pgfpoint{\OutlinedArrowStep}{-\OutlinedArrowWidth/2}}
     \pgfcoordinate{lastdown}{\pgfpoint{\OutlinedArrowStep}{-\OutlinedArrowWidth/2}}
    \else
     \ifnum\marmotarrowstart=0% draw the arrow head
     \pgfmoveto{\pgfpointadd{\pgfpointanchor{lastup}{center}}{\pgfpoint{-0.5\pgflinewidth}{0}}}
     \pgflineto{\pgfpoint{-0.5\pgflinewidth}{\OutlinedArrowWidth/2}}
     \pgflineto{\pgfpointadd{\pgfpointdecoratedpathlast}{\pgfpoint{-0.5\pgflinewidth}{0}}}
     \pgflineto{\pgfpoint{-0.5\pgflinewidth}{-\OutlinedArrowWidth/2}}
     \pgflineto{\pgfpointadd{\pgfpointanchor{lastdown}{center}}{\pgfpoint{-0.5\pgflinewidth}{0}}}
     \xdef\marmotarrowstart{1}
     \else
     \fi
    \fi%
  }
  \state{final}[width=5pt]
  { % perhaps unnecessary but doesn't hurt either
    \pgfmoveto{\pgfpointdecoratedpathlast}
  }
}
\begin{document}


\begin{tikzpicture}[decoration=outlined arrow,outlined arrow length=10pt,
 ctext/.style={decoration={text along path, text={#1},
  raise=-2.5pt,text align=center},decorate},
  pics/tarrow/.style={code={
  \draw[decorate] #1;
  \draw[ctext=\pgfkeysvalueof{/tikz/tarrow/text}] #1;}},
  tarrow/.cd,text/.initial={}]
  \path pic[tarrow/text={${a_1}$}] {tarrow={(-6,1.5) to[bend left=20] (150:2)}}
  pic[tarrow/text={${a_2}$}] {tarrow={(150:2) to[bend left=10] (-30:2)}}
  pic[tarrow/text={${a_3}$}] {tarrow={(-30:2) to[bend right=20] (6,-1.5)}}
  pic[tarrow/text={${a_4}$}] {tarrow={(6,-1.5) arc[start angle=-90,end
  angle=90,radius=1.5cm]}}
  ;
\end{tikzpicture}  
\end{document}

enter image description here

Maybe this gives you an basis for a better received question.

If you only want upright text, you do not need decorations.text.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{decorations} 
\pgfkeys{/tikz/.cd,
    outlined arrow width/.store in=\OutlinedArrowWidth,
    outlined arrow width=15pt,
    outlined arrow step/.store in=\OutlinedArrowStep,
    outlined arrow step=1pt,
    outlined arrow length/.store in=\OutlinedArrowLength,
    outlined arrow length=10pt,
}

\pgfdeclaredecoration{outlined arrow}{initial}
{% initial arrow butt
\state{initial}[width=\OutlinedArrowStep,next state=cont] {
    \pgfmoveto{\pgfpoint{\OutlinedArrowStep}{\OutlinedArrowWidth/2}}
    \pgfpathlineto{\pgfpoint{0.3\pgflinewidth}{\OutlinedArrowWidth/2}}
    \pgfpathlineto{\pgfpoint{\OutlinedArrowLength}{0pt}}
    \pgfpathlineto{\pgfpoint{0.3\pgflinewidth}{-\OutlinedArrowWidth/2}}
    \pgfpathlineto{\pgfpoint{1pt}{-\OutlinedArrowWidth/2}}
    \pgfcoordinate{lastup}{\pgfpoint{1pt}{\OutlinedArrowWidth/2}}
    \pgfcoordinate{lastdown}{\pgfpoint{1pt}{-\OutlinedArrowWidth/2}}
    \xdef\marmotarrowstart{0}
  }
  \state{cont}[width=\OutlinedArrowStep]{
    \ifdim\pgfdecoratedremainingdistance>\OutlinedArrowLength% continue the outlined path
     \pgfmoveto{\pgfpointanchor{lastup}{center}}
     \pgfpathlineto{\pgfpoint{\OutlinedArrowStep}{\OutlinedArrowWidth/2}}
     \pgfcoordinate{lastup}{\pgfpoint{\OutlinedArrowStep}{\OutlinedArrowWidth/2}}
     \pgfmoveto{\pgfpointanchor{lastdown}{center}}
     \pgfpathlineto{\pgfpoint{\OutlinedArrowStep}{-\OutlinedArrowWidth/2}}
     \pgfcoordinate{lastdown}{\pgfpoint{\OutlinedArrowStep}{-\OutlinedArrowWidth/2}}
    \else
     \ifnum\marmotarrowstart=0% draw the arrow head
     \pgfmoveto{\pgfpointadd{\pgfpointanchor{lastup}{center}}{\pgfpoint{-0.5\pgflinewidth}{0}}}
     \pgflineto{\pgfpoint{-0.5\pgflinewidth}{\OutlinedArrowWidth/2}}
     \pgflineto{\pgfpointadd{\pgfpointdecoratedpathlast}{\pgfpoint{-0.5\pgflinewidth}{0}}}
     \pgflineto{\pgfpoint{-0.5\pgflinewidth}{-\OutlinedArrowWidth/2}}
     \pgflineto{\pgfpointadd{\pgfpointanchor{lastdown}{center}}{\pgfpoint{-0.5\pgflinewidth}{0}}}
     \xdef\marmotarrowstart{1}
     \else
     \fi
    \fi%
  }
  \state{final}[width=5pt]
  { % perhaps unnecessary but doesn't hurt either
    \pgfmoveto{\pgfpointdecoratedpathlast}
  }
}
\begin{document}


\begin{tikzpicture}[decoration=outlined arrow,outlined arrow length=10pt,
    phantom/.style={circle,inner sep=1ex,alias=aux,node contents={}}]
%
  \draw[decorate] (0,0) 
    to[out=10,in=170] node {$a_1$} ++ (2,0) node[phantom];
  \draw[decorate] (aux) to[out=-10,in=170] node[pos=0.2] {$a_2$}   ++ (3,-2)  node[phantom];
  \draw[decorate] (aux) to[out=-10,in=-90] node {$a_2$}   ++ (2,1) node[phantom];
  \draw[decorate] (aux) to[out=90,in=10] node{$a_4$}  ++ (-2,1) node[phantom];
  \draw[decorate] (aux) to[out=-170,in=10] node[pos=0.8] {$a_5$}    ++ (-3,-2) node[phantom];
  \draw[decorate] (aux) to[out=-170,in=-170,looseness=3] node[pos=0.3] {$a_6$} (0,0);
%
  \path[font=\sffamily] (1,-1) node{from}  (5.5,-1) node{to} ; 
\end{tikzpicture}  
\end{document}

enter image description here