從一個邊緣到另一個邊緣繪製彎曲箭頭(tikz 圖片)

從一個邊緣到另一個邊緣繪製彎曲箭頭(tikz 圖片)

我正在研究以下 tex 代碼:

     \begin{tikzpicture}[x=7mm]
\draw[->] (0,0) -- (11,0);
\foreach \x in {0,...,10}
{
  \draw[shift={(\x,0)}] 
   (0pt,3pt) -- (0pt,-3pt) node[below,font=\small] {$\x$};
}
%\node[below] at (-5.8,-5pt) {$\cdots$};   
\node[below] at (11,-5pt) {$\cdots$};  
\end{tikzpicture}

這給了我下面的圖片:

在此輸入影像描述

如何在這張 tikz 圖片的上部繪製從每個節點 $i$ 到節點 $i+1$ 的彎曲箭頭,每個箭頭都帶有標籤“+1”?

答案1

在循環內加入以下程式碼行:

\draw[red,-latex] (\x,.2) arc(160:20:.5);

輸出將變為:

在此輸入影像描述

添加:如果你想要這個輸出:

在此輸入影像描述

要新增的程式碼行是這樣的:

\draw[red,-latex] (\x,.2) arc(160:20:.5) node[pos=.5,above] () {\small +1}; 

答案2

\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[x=7mm]
  \draw[->] (0,0) -- (11,0);
  \foreach \x [count=\xi from 1] in {0,...,9}
    \draw[->,font=\tiny]
    (\x,0) to [bend left=90] node[above]{+1} (\xi,0);
\end{tikzpicture}
 \end{document}

在此輸入影像描述

答案3

另一種方法。

\documentclass[tikz,border=5mm]{standalone}

\begin{document}

\begin{tikzpicture}[x=7mm]
  \draw[->] (0,0) -- (11,0);
  \foreach \x in {0,...,10}
  {
    \draw[shift={(\x,0)}] 
      (0pt,3pt) -- (0pt,-3pt) node[below,font=\small] {$\x$};
  }
  \node[below] at (11,-5pt) {$\cdots$};  
  
  % Draw curved arrows with labels
  \foreach \x in {0,...,9}
  {
    \draw[->, bend left=30, cyan] (\x,0.2) to node[below,font=\small, cyan] {$\scriptscriptstyle +1$} (\x+1,0.2);
  }
\end{tikzpicture}

\end{document}

在此輸入影像描述

相關內容