我不明白表格中红色箭头的含义
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x/\xtext/\ytext in{0/x/y,1/1/4,2/1.5/6,3/2/8,4/5/20}
{\draw (\x,0.5) +(-0.5,-0.25) rectangle ++(0.5,0.25) ;
\draw (\x,0) +(-0.5,-0.25) rectangle ++(0.5,0.25);
\node[] at (\x,0.5) {$\xtext$};
\node[] at (\x,0) {$\ytext$};
}
\draw[color=red,->,thick,>=stealth,shorten >=2pt,shorten <=2pt] (4.5,.65) edge [distance=1.2cm,bend left=80 ] node [right]{$\times 4$} (4.5,-.15);
\end{tikzpicture}
\end{document}
答案1
是一条edge
单独的路径,默认情况下,它会继承其父路径的所有属性。因此,会在主路径和 中添加箭头edge
。但是,您只想在 上使用edge
。因此,不要将其添加到主路径。
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\foreach \x/\xtext/\ytext in{0/x/y,1/1/4,2/1.5/6,3/2/8,4/5/20}
{\draw (\x,0.5) +(-0.5,-0.25) rectangle ++(0.5,0.25) ;
\draw (\x,0) +(-0.5,-0.25) rectangle ++(0.5,0.25);
\node[] at (\x,0.5) {$\xtext$};
\node[] at (\x,0) {$\ytext$};
}
\draw[color=red,thick,>=Stealth,shorten >=2pt,shorten <=2pt] (4.5,.65) edge [distance=1.2cm,bend left=80, -> ] node [right]{$\times 4$} (4.5,-.15);
\end{tikzpicture}
\end{document}
或者,您可以避免使用edge
。这样您就只有一条路径,并且 Ti钾Z 将只使用一个箭头尖,如下所述balcinus 的回答。
答案2
我也不知道它为什么在那里,但是如果你写
(4.5,.65) to [distance=1.2cm,bend left=80 ] node [right]{$\times 4$} (4.5,-.15);
而不是
(4.5,.65) edge [distance=1.2cm,bend left=80 ] node [right]{$\times 4$} (4.5,-.15);
(注意to
而不是edge
),它就会消失
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x/\xtext/\ytext in{0/x/y,1/1/4,2/1.5/6,3/2/8,4/5/20}
{
\draw (\x,0.5) +(-0.5,-0.25) rectangle ++(0.5,0.25) ;
\draw (\x,0) +(-0.5,-0.25) rectangle ++(0.5,0.25);
\node[] at (\x,0.5) {$\xtext$};
\node[] at (\x,0) {$\ytext$};
}
\draw[color=red,->,thick,>=stealth,shorten >=2pt,shorten <=2pt] (4.5,.65) to[distance=1.2cm,bend left=80 ] node [right]{$\times 4$} (4.5,-.15);
\end{tikzpicture}
\end{document}