如何将箭头置于循环中间

如何将箭头置于循环中间

我试图重现下图:

我尝试重现的图片

到目前为止,我的问题是将箭头放在c_{1}循环的中间。

这就是我已经做的事情:

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-graph}
\usetikzlibrary{decorations.markings,arrows}
\newcommand{\midarrow}{\tikz \draw[-triangle 70] (0,0) -- +(.1,0);}
\begin{document}
\begin{center}
\begin{tikzpicture}
  [decoration    = {markings,mark=at position 0.5 with
  {\arrow[black,line width=0.5mm]{stealth'}}},
vertex/.style = {inner sep=2pt,circle,fill,draw,label={#1}},
edge/.style   = {postaction={decorate},thick}]
  \newcommand\R{2.7}
  \coordinate (A) at (0:\R);
  \coordinate (B) at (90:\R);
  \coordinate (C) at (180:\R);
  \coordinate (D) at (270:\R);
  \draw[edge] (C) -- (B) node[midway, left]{$a_{1}$};
  \draw[edge] (B) -- (A) node[midway, above]{$b_{1}$};
  \draw[edge] (A) -- (D) node[midway, right]{$a_{1}$};
  \draw[edge] (D) -- (C) node[midway, below]{$b_{1}$};
  \Loop[dir=WE,dist=3cm,label={$c_{1}$},labelstyle={left},style={
  ->,thick}](A)
\end{tikzpicture}
\begin{tikzpicture}
  [decoration    = {markings,mark=at position 0.5 with
  {\arrow[black,line width=0.5mm]{stealth'}}},
vertex/.style = {inner sep=2pt,circle,fill,draw,label={#1}},
edge/.style   = {postaction={decorate},thick}]
  \newcommand\R{2.7}
  \coordinate (A) at (0:\R);
  \coordinate (B) at (90:\R);
  \coordinate (C) at (180:\R);
  \coordinate (D) at (270:\R);
  \draw[edge] (C) -- (B) node[midway, left]{$a_{2}$};
  \draw[edge] (B) -- (A) node[midway, above]{$b_{2}$};
  \draw[edge] (A) -- (D) node[midway, right]{$a_{2}$};
  \draw[edge] (D) -- (C) node[midway, below]{$b_{2}$};
  \Loop[dir=EA,dist=3cm,label={$c_{2}$},labelstyle={right},style={
  ->,thick}](C)
\end{tikzpicture}
\end{center}
\end{document}  

答案1

您需要 postaction={decorate}\Loop命令中指定放置箭头的位置(并->从选项中删除,因为您不想要结束箭头。)

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-graph}
\usetikzlibrary{decorations.markings,arrows}
\newcommand{\midarrow}{\tikz \draw[-triangle 70] (0,0) -- +(.1,0);}
\begin{document}

\begin{tikzpicture}
  [decoration    = {markings,mark=at position 0.5 with
  {\arrow[black,line width=0.5mm]{stealth'}}},
vertex/.style = {inner sep=2pt,circle,fill,draw,label={#1}},
edge/.style   = {postaction={decorate},thick}]
  \newcommand\R{2.7}
  \coordinate (A) at (0:\R);
  \coordinate (B) at (90:\R);
  \coordinate (C) at (180:\R);
  \coordinate (D) at (270:\R);
  \draw[edge] (C) -- (B) node[midway, left]{$a_{1}$};
  \draw[edge] (B) -- (A) node[midway, above]{$b_{1}$};
  \draw[edge] (A) -- (D) node[midway, right]{$a_{1}$};
  \draw[edge] (D) -- (C) node[midway, below]{$b_{1}$};
  \Loop[dir=WE,dist=3cm,label={$c_{1}$},labelstyle={left},style={
  ,thick,postaction={decorate}}](A)
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容