在下面的代码中
\begin{figure}[htbp!]
\begin{center}
\begin{tikzpicture}[>=stealth,baseline,anchor=base,inner sep=0pt]
\draw[thick,->] (-3.5,0) -- (4.5,0) node[anchor=north west] {$\mathbb{Z}$};
\foreach \x in {-3,-2,-1,0,1,2,3,4}
\draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {$\x$};
\end{tikzpicture}
\caption{Somma algebrica} \label{fig:somma algebrica} %\label va messo qui
\end{center}
\end{figure}
我想添加如下图所示的箭头
这样我可以展示如何计算两个或多个数字之和,但我不知道如何在我的代码中集成它。
谢谢你的提示
吉安卡洛
答案1
\documentclass[tikz, margin=3.14159mm]{standalone}
\usetikzlibrary{arrows.meta,
positioning}
\usepackage{amssymb}
\begin{document}
\begin{tikzpicture}[
node distance = 6mm,
> = Straight Barb,
arr/.style = {very thick, gray, shorten <=1pt,
-{Triangle[length=3pt]}, looseness=3}
]
\draw[thick,->] (-3.5,0) -- (5,0) node[below left=2pt] {$\mathbb{Z}$};
\foreach \x in {-3,-2,-1,0,1,2,3,4}
\draw (\x,2pt) -- ++ (0,-4pt) node (n\x) [below] {$\x$};
\draw[arr] (n1) to [out=270, in=270] (n0);
\draw[arr] (n0) to [out=270, in=270] (n-1);
\end{tikzpicture}
\end{document}