以下是我目前所掌握的信息:
\documentclass[tikz]{amsart}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{arrows}
\begin{document}
\tikzset{->-/.style={decoration={
markings,
mark=at position #1 with {\arrow{>}}},postaction={decorate}}}
\begin{tikzpicture}
% a straight line segment
\draw[->-=0.5] (1,0) -- (0,0);
\draw[->-=0.5] (0,0) -- (-1,0);
% the ticks and their labels
\foreach \x [count=\i start from 0] in {-1,...,1}
\draw[xshift=\x cm] node[below,fill=white] (\i) {\x};
\draw[->] (-1,0.15) to [out=65, in=115] (0,0.15);
\end{tikzpicture}
\end{document}
但我想像这样分开数轴,而不是将其连接起来:
答案1
一个简单的解决方案tikz-cd
:
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
1 \arrow[r] & 0 \arrow[r] & -1 \arrow[l,bend left]
\end{tikzcd}
\end{document}
答案2
除非我误解了你的请求,否则你不需要这种类型的图表装饰。使用你的,foreach
你可以为每个节点绘制一个箭头。不过我不得不使用一个if
语句来避免在右侧排版一个额外的箭头。
输出
代码
\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,calc}
\tikzset{
every node/.style={
minimum width=2cm
}
}
\begin{document}
\begin{tikzpicture}[->]
\foreach \name [count=\xi from -1] in {1,...,-1}{
\coordinate (\name) at (\name,0);
\node[yshift=.3pt,] (n\name) at (\name,0) {$\xi$};
\ifnum\name=1\relax
\else
\draw[shorten >=2.5mm,shorten <=2.5mm] (\name,0) -- (\name+1,0);
\fi
}
\draw (1,-.15) to [out=225, in=315] (0.1,-.15);
\end{tikzpicture}
\end{document}