表中的箭头

表中的箭头

有没有办法将粗体栏稍微向左移动一点?(最后一个 0 之前的那个)。另外,有人能帮我修复最后一个箭头的倾斜度,让它变直吗?谢谢!我的代码现在看起来像这样:

\begin{tikzpicture}
\matrix[matrix of nodes,column sep=0pt,
nodes={anchor=base east,inner xsep=6pt,inner ysep=6pt}] (M) {
& 1 & 5 & 4 & 20\\[-3pt]
-5 &   & -5 & -5  & -20\\[3pt]
& 1 & 0 & 4 & 0\\
};
\draw (M-2-1.south west) -- (M-2-6.south east);
\draw (M-1-2.north west) -- (M-3-2.south west);
\draw[line width=3pt] (M-2-6.south west) -- ++(0pt,-20pt);

\begin{scope}[->, shorten >=-4pt, shorten <=-4pt]
\draw (M-1-2) -- (M-3-2);
\draw (M-3-2) -- (M-2-3);
\draw (M-2-3) -- (M-3-3);
\draw (M-3-3) -- (M-2-4);
\draw (M-2-4) -- (M-3-4);
\draw (M-3-4) -- (M-2-5);
\draw (M-2-5) -- (M-3-5);
\end{scope}
\end{tikzpicture}

答案1

像这样?

在此处输入图片描述

  • 首先你需要纠正代码片段中的错误
  • 第二,请始终提供以 开头\documentclass{...}和结尾的完整小文档\end{document}。帮助我们帮助您......(写下代码的缺失部分并不好玩,我们可以对其进行测试)
  • 可以移动xshift{...}
  • 节点宽度不相等,因此需要更改垂直箭头的起始坐标

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes,column sep=0pt,
        nodes={anchor=base east,inner sep=6pt}] (M) {
   & 1 & 5  & 4  &  20\\[-3pt]
-5 &   & -5 & -5 & -20\\[3pt]
   & 1 & 0  & 4  &   0\\
};
\draw (M-2-1.south west) -- (M-2-5.south east);
\draw (M-1-2.north west) -- (M-3-2.south west);
\draw[line width=3pt, semitransparent] ([xshift=-1mm] M-2-5.south west) -- ++(0pt,-20pt);

\begin{scope}[->, shorten >=-4pt, shorten <=-4pt]
\draw (M-1-2) -- (M-3-2);
\draw (M-3-2) -- (M-2-3);
\draw (M-2-3.south -| M-3-3) -- (M-3-3);
\draw (M-3-3) -- (M-2-4);
\draw (M-2-4.south -| M-3-4) -- (M-3-4);
\draw (M-3-4) -- (M-2-5);
\draw (M-2-5.south -| M-3-5) -- (M-3-5);
\end{scope}
\end{tikzpicture}
\end{document}

相关内容