下面链接的图片显示了我想要做的事情和我得到的结果。我对 Tikz 完全陌生。我做错了什么?
\text{det}\left[\begin{array}{ccc}
a_{11}\tikzmark{a11} & a_{12}\tikzmark{a12} & a_{13}\tikzmark{a13} \\
a_{21} & a_{22}\tikzmark{a22} & a_{23}\tikzmark{a23} \\
a_{31} & a_{32} & a_{33}\tikzmark{a33} \\
\end{array}\right]
\begin{array}{cc}
a_{11} & a_{12} \\
a_{21}\tikzmark{a21} & a_{22} \\
a_{31}\tikzmark{a31} & a_{32}\tikzmark{a31} \\
\end{array} =(a_{11}a_{22}a_{33}+a_{12}a_{23}a_{31}+a_{13}a_{21}a_{32}) - (a_{13}a_{22}a_{31}+a_{11}a_{23}a_{32}+a_{12}a_{21}a_{33}).
\end{equation}
\begin{tikzpicture}[overlay, remember picture]
\draw [-] ({pic cs:a11}) to ({pic cs:a22});
\draw [-] ({pic cs:a22}) to ({pic cs:a33});
\draw [-] ({pic cs:a12}) to ({pic cs:a23});
\end{tikzpicture}
答案1
一个简单的解决方案是pstricks
,使用blkarray
:每个元素定义为\Rnode
。接下来,每对相关节点都与节点连接相连:
\documentclass[svgnames]{article}
\usepackage{blkarray, bigstrut}
\usepackage{pst-node}
\begin{document}
\[ \begin{blockarray}{r@{\enspace}[ccc]cc}
& \Rnode{A11}{a_{11}} & \Rnode{A12}{a_{12}} & \Rnode{A13}{a_{13}} & \Rnode{B11}{a_{11}} & \Rnode{B12}{a_{12}}\\
\det{} & a_{21} & \Rnode{A22}{a_{22}} & \Rnode{A23}{a_{23}} & \Rnode{A21}{a_{21}} & a_{22}\\
& \Rnode{B31}{a_{31}} & \Rnode{B32}{a_{32}} & \Rnode{A33}{a_{33}} \bigstrut[b] & \Rnode{A31}{a_{31}} & \Rnode{A32}{a_{32}}
\end{blockarray} \]
\psset{nodesep=0.5pt, linewidth=0.5pt, arrowinset=0.2, linejoin=1}
\foreach \s \t in{A11/A22, A22/A33, A12/A23, A23/A31, A13/A21, A21/A32}%
{\ncline[linecolor=Lavender]{->}{\s}{\t}}
\foreach \s \t in{B31/A22, A22/A13, B32/A23, A23/B11, A33/A21, A21/B12}%
{\ncline[linecolor=Moccasin]{->}{\s}{\t}}
\end{document}
答案2
\documentclass[12pt]{article}
\usepackage{nicematrix,tikz}
\usetikzlibrary{calc}
\tikzset{
arp/.style={cyan,line width=1pt,opacity=0.5,->},
arm/.style={orange,line width=1pt,opacity=0.5,->}}
\begin{document}
\def\r{.5} % ratio for arrows outer length
\NiceMatrixOptions{cell-space-limits=5pt}
$\det%
\begin{NiceArray}{[*{3}{W{c}{15pt}}]*{2}{W{c}{15pt}}}
a_{11} & a_{12} & a_{13} & a_{11} & a_{12}\\
a_{21} & a_{22} & a_{23} & a_{21} & a_{22}\\
a_{31} & a_{32} & a_{33} & a_{31} & a_{32}\\
\CodeAfter
\tikz
\foreach \i [count=\j from 3] in {1,2,3} \draw[arp] ($(1-\i)!-\r!(3-\j)$) -- ($(3-\j)!-\r!(1-\i)$) node[pos=1.1] {\Large $\oplus$};
\CodeAfter
\tikz
\foreach \i [count=\j from 3] in {1,2,3} \draw[arm] ($(1-\j)!-\r!(3-\i)$) -- ($(3-\i)!-\r!(1-\j)$) node[pos=1.1] {\Large $\ominus$};
\end{NiceArray}%
\quad=\quad\dots$\\
\end{document}