在下面的输出中,我想改变红色路径的开始和结束:参见绿色箭头。
这是我的代码。
\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{nicematrix}
\newcommand\explainit[3]{& $\leftarrow \,\, #1 = 2\cdot#2 + #3$}
\begin{document}
\begin{NiceTabular}{r|ll}
& 77
\\
1 & 38 \explainit{77}{38}{1}
\\
0 & 19 \explainit{38}{19}{0}
\\
1 & 9
\\
1 & 4
\\
0 & 2
\\
0 & 1
\CodeAfter
\begin{tikzpicture}
\draw[red, rounded corners, ->, transform canvas={yshift=-2.5pt}](8-|3) -- (8-|1) -- (2-|1);
\end{tikzpicture}
\end{NiceTabular}
\medskip
Donc $(77)_{10} = (1001101)_2$ .
\end{document}
答案1
使用单元格名称代替表格线名称,并稍微移动它们:
\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{nicematrix}
\newcommand\explainit[3]{& $\leftarrow \,\, #1 = 2\cdot#2 + #3$}
\begin{document}
\begin{NiceTabular}{r|ll}
& 77
\\
1 & 38 \explainit{77}{38}{1}
\\
0 & 19 \explainit{38}{19}{0}
\\
1 & 9
\\
1 & 4
\\
0 & 2
\\
0 & 1
\CodeAfter %\ShowCellNames
\begin{tikzpicture}
\draw[red, rounded corners, ->]([yshift=-7pt]7-2.south) -| ([xshift=-7pt]2-1.west);
\end{tikzpicture}
\end{NiceTabular}
\medskip
Donc $(77)_{10} = (1001101)_2$ .
\end{document}