如何在同一曲线上画出两个相反的箭头?

如何在同一曲线上画出两个相反的箭头?

如何在同一条曲线上绘制相反的箭头?下图显示了我的目标。

!

答案1

正确的方法是使用库decorations.markings并定义放置箭头和标签的样式。

这是有可能的(一些想法来自如何制作带有移动箭头的图形?):

\documentclass[12pt,a4paper]{article}
\usepackage{tikz}

\usetikzlibrary{decorations.markings,arrows} % arrows for *-* tips

\pgfkeys{/tikz/.cd,
  arrow color/.store in=\arrowcolor,
  arrow color=black,
  arrow tip/.store in=\arrowtip,
  arrow tip=to,
  label 1/.store in=\labone,
  label 1={},
  label 2/.store in=\labtwo,
  label 2={},
}

\tikzset{double arrow/.style args={in #1 and #2}{
   postaction=decorate,
   decoration={
    markings,
    mark=at position #2 with {
      \arrow[\arrowcolor,arrows options]{\arrowtip};
      \node[labels options]{\labtwo};
    },
    mark=at position #1 with {
      \arrowreversed[\arrowcolor,arrows options]{\arrowtip};}
      \node[labels options]{\labone};
      }
  },
  arrows options/.style={
    thick
  },
  labels options/.style={
    above=0.1cm  
  }
}

\begin{document}
\begin{tikzpicture}
\draw[-stealth, very thick](0,0)--(6,0) node[below]{$x$};
\draw[-stealth, very thick](0,0)--(0,5) node[left]{$y$};

\draw[thick,
  arrow tip={stealth},
  double arrow=in 0.2 and 0.8, % places 
  label 1={$-C$},
  label 2={$C$},
  *-*, % tips at both sides of the path
  ] 
 (1,1) node[below] {$z_1$}
 .. controls (3,3) and (5,3) .. 
 (5,3) node[below] {$z_2$};

\end{tikzpicture}
\end{document}

结果:

在此处输入图片描述

答案2

另一个版本是tikzv3:

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{decorations.markings,arrows.meta}

\tikzset{
    ->-/.style={decoration={
        markings,
        mark=at position .85 with {\arrow{Latex}}},postaction={decorate}},
    -<-/.style={decoration={
        markings,
        mark=at position .15 with {\arrow{Latex[reversed]}}},postaction={decorate}},
}
\begin{document}
  \begin{tikzpicture}
    \draw (-1,0) -- node[pos=0.1,below] {$O$} (6,0)node[pos=0.98,below] {$x$};
    \draw (0,-1) -- (0,6)node[pos=0.98,left] {$y$};

    \node[inner sep=2pt,circle,fill=black,label={below:$z_{1}$}] at  (1,2) (a) {} ;
    \node[inner sep=2pt,circle,fill=black,label={below:$z_{2}$}] at  (5,3) (b) {} ;
    \draw (a) edge[in=180,out=30,->-,-<-] node[pos=0.1,above]{$-C$} node[pos=0.85,above]{$C$} (b) ;
  \end{tikzpicture}
\end{document}

在此处输入图片描述

答案3

使用 PSTricks 只是为了好玩。

\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-eucl,pstricks-add}

\begin{document}
\begin{pspicture}(-1,-1)(7,4)
    \pstGeonode[PosAngle={-135,-90},PointSymbol={none,default}]{O}(1,1){z_1}(5,3){z_2}
    \psaxes[labels=none,ticks=none](0,0)(-1,-1)(7,4)[$x$,-90][$y$,180]
    \psset{ArrowInside=->,ArrowInsidePos=.8,npos=.8,shortput=nab,arrowscale=1.8}
    \pcarc[arcangle=20](z_1)(z_2)^{$C$}
    \pcarc[arcangle=-20](z_2)(z_1)_{$-C$}
\end{pspicture}
\end{document}

在此处输入图片描述

相关内容