TikZ-PGF – How to Add Arrow Tip in the Middle of the Edge in TikZ

tikz-arrowstikz-pgf


\documentclass[12pt, a4paper]{article}
\usepackage{graphicx}
\usepackage{amsfonts}
\usepackage{amsbsy}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{pst-all}    
\usepackage{pstricks}
\usepackage{graphics}
%\usepackage{showkeys}
%\usepackage[notref]{showkeys}
\usepackage{epsfig}
\usepackage{tkz-euclide}
\usepackage{tgbonum}
\usepackage{tikz}
\usepackage{pifont,geometry,txfonts}
\usepackage{hyperref}
%\usepackage{showkeys}
\renewcommand{\baselinestretch}{1.23}
\newcommand{\arrowIn}{
\tikz \draw[-stealth] (-4pt,0) -- (4pt,0);
}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setlength{\textheight}{220mm}
\setlength{\textwidth}{140mm}

%% Common extra environments
\usepackage[numbers,sort&compress]{natbib}% Citation support using natbib.sty
\bibpunct[, ]{[}{]}{,}{n}{,}{,}% Citation support using natbib.sty
\renewcommand\bibfont{\fontsize{10}{12}\selectfont}% Bibliography support using natbib.sty
\makeatletter% @ now becomes a letter
\def\NAT@def@citea{\def\@citea{\NAT@separator}}% Macro to suppress spaces between citations using 
%natbib.sty
\makeatother% @ becomes a symbol again

\def\M{\mathcal{M}}
\def\U{\mathcal{U}_{g}}
%\theoremstyle{plain}% Theorem-like structures provided by amsthm.sty
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{proposition}[theorem]{Proposition}

%\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}

%\theoremstyle{remark}
\newtheorem{remark}{Remark}

\newcommand{\bcomma}{,\allowbreak}
\renewcommand{\baselinestretch}{1.2}
%\renewcommand{\qedsymbol}{$\blacksquare$}

\def\M{\mathcal{M}}

%\DeclareUnicodeCharacter{2212}{-}
%\theoremstyle{definition}
%\newtheorem{definition}{Definition}[section]
\def\w{{\sf w}}

%\begin{document}
\begin{document}



\tikzset{every path/.style=thick,
    acteur/.style={
        circle,
        fill=black,
        thick,
        inner sep=1pt,
        minimum size=.13cm
    },
    curvy line/.style={decorate,,rounded corners=2pt,decoration={random steps,segment length=3mm,
            amplitude=1mm}}}
\tikzset{curvy line/.style={decorate,decoration={snake,segment length=8.5mm,
            amplitude=1mm}}}
        
\begin{figure}[hbt!]
    \begin{center}
        
        \begin{tikzpicture}[scale=.8,every label/.append style={font=\scriptsize}]
            
                \begin{scope}
                    
                    
                    \node (a5) at (3,3) [acteur,label=below:{}]{};
                    \node (a19) at (3.3,6.5) [acteur,label=right:{}]{};
                    \node (a7) at (2.25,5) [acteur,label=above:{}]{};
                    \node (a13) at (1.5,3) [acteur,label=above left:{}]{};
                    
                        \node (a14) at (4.25,5) [acteur,label=above:{$x$}]{};
                
                        \node (a15) at (6.25,5) [acteur,label=above:{$x'$}]{};
                
                       \node (a16) at (8.45,5) [acteur,label=above left:{}]{};
                
                   \node (a17) at (11,3.6) [acteur,label=above left:{}]{};
                
                    \draw [-{Stealth[scale=1.5]}] [green](a13) -- (a5);
                    \draw [red] [dashed](a5) -- (a7);
                    \draw [dashed][red] (a7) -- (a13);
                    \draw[red]  (2.25,5) -- (a19);
                    \draw [dashed][red](2.25,5) -- (2.5,6.65);
                    \draw [dashed][red](2.25,5) -- (1.9,6.65);
                    \draw [dashed][red](2.25,5) -- (2.2,6.65);
                    
                    
                    \draw [dashed][red](8.45,5) -- (11,5.4);
                        \draw [red][dashed](8.45,5) -- (11,4.7);
                            \draw [red][dashed](8.45,5) -- (11,5);
                    \draw [red](8.45,5) -- (a17);
                    
                    
                    \draw[red] [dashed] (2.25,5) -- (a14);
                    
                    
                    \draw[red]  (a15) -- (a14);
                    \draw[red] [dashed] (a15) -- (a16);
                    
                    \draw[dotted] (.5,6.5) .. controls (2.2,3.8) .. (3.9,6.5);
                    \draw[dotted] (9.8,6.5) .. controls (7.8,5) .. (9.8,2.8);
                    
                    \draw[dashed][red] (11.1,5) circle (.7);
                    
                    \draw[dashed][red] (2.25,6.9) circle (.7);
                    \node at (2.2,7.2) {\scriptsize{$T$}};
                    \node at (11.5,4.9) {\scriptsize{$T'$}};
                    \end{scope}
            
            
        \end{tikzpicture} 
        
    \end{center}
\end{figure}

\end{document}
Here I am trying to put the sign of arrow in the middle of the green edge. How we can do this?
Here I am trying to put the sign of arrow in the middle of the green edge. How we can do this?

Best Answer

This has been answered before here.

Use the decorations library to draw an arrow in the middle of the green line, replacing this:

\draw [-{Stealth[scale=1.5]}] [green](a13) -- (a5);

By this:

\draw[green,
      decoration={markings,mark=at position 0.7 with {\arrow{Stealth[scale=1.5]}}},
      postaction={decorate}] (a13) -- (a5);

enter image description here

Related Question