![在矩阵上绘制箭头的最优方法是什么?](https://linux22.com/image/461156/%E5%9C%A8%E7%9F%A9%E9%98%B5%E4%B8%8A%E7%BB%98%E5%88%B6%E7%AE%AD%E5%A4%B4%E7%9A%84%E6%9C%80%E4%BC%98%E6%96%B9%E6%B3%95%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F.png)
tikz
我想使用的功能绘制类似于所示的内容nicematrix
。此外,是否可以控制注释和箭头尾部之间的间距?
\documentclass[11pt, a4paper]{article}
\usepackage{tikz}
\usepackage{nicematrix}
\NiceMatrixOptions{rules/color=[gray]{0.75}, hvlines}
\begin{document}
\begin{alignat*}{2}
x
& =
\begin{bNiceMatrix}[r]
1 & 4 & 7
\\
2 & 5 & 8
\\
3 & 6 & 9
\\
\end{bNiceMatrix}
\end{alignat*}
\end{document}
答案1
\documentclass[11pt, a4paper]{article}
\usepackage{tikz}
\usepackage{nicematrix}
\NiceMatrixOptions{rules/color=[gray]{0.75}, hvlines}
\begin{document}
\begin{alignat*}{2}
x
& =
\begin{bNiceMatrix}[r]
1 & 4 & 7
\\
2 & 5 & 8
\\
3 & 6 & 9
\\
\CodeAfter
\begin{tikzpicture}
\draw [->] (1-|2) -- (3-|4) ;
\node at ([yshift=1mm]1-|2) {\tiny\(k=+1\)} ;
\draw [->] (2-|1) -- (4-|3) ;
\node at ([xshift=-0.7mm]2-|1) [rotate=90] {\tiny\(k=-1\)} ;
\end{tikzpicture}
\end{bNiceMatrix}
\end{alignat*}
\end{document}
与往常一样nicematrix
,您需要进行多次编译。