我使用的代码与我之前的答案相同问题
\documentclass[12pt,a4paper]{report}
\usepackage{amsfonts,amsmath,amssymb,amsthm,tikz}
\usetikzlibrary{calc,matrix}
\begin{document}
\begin{align*}
D &=
\begin{tikzpicture}[
baseline=-\the\dimexpr\fontdimen22\textfont2\relax,
strip/.style = {
draw=#1,%color
line width=1em, opacity=0.2,
shorten <=-2mm,shorten >=-2mm,
},
]
\matrix (mtrx) [matrix of math nodes,
column sep=1em,
nodes={text height=1ex,text width=2ex},
ampersand replacement=\&]
{
|[red]|+ \& |[red]|+ \& |[red]| +
\\[3.3mm,between origins]
a_1 \& b_1 \& c_1 \& a_1 \& a_2 \\
a_2 \& b_2 \& c_2 \& a_2 \& b_2 \\
a_3 \& b_3 \& c_3 \& a_3 \& b_3 \\
|[blue]|- \& |[blue]|- \& |[blue]|- \\
};
\draw[thick] (mtrx-4-1.south west) -- (mtrx-2-1.north west);
\draw[thick] (mtrx-4-3.south east) -- (mtrx-2-3.north east);
\path[draw,strip=blue]
(mtrx-4-1.center) edge (mtrx-2-3.center)
(mtrx-4-2.center) edge (mtrx-2-4.center)
(mtrx-4-3.center) -- (mtrx-2-5.center);
\path[draw,strip=red]
(mtrx-2-1.center) edge (mtrx-4-3.center)
(mtrx-2-2.center) edge (mtrx-4-4.center)
(mtrx-2-3.center) -- (mtrx-4-5.center);
\end{tikzpicture} \\
&= a+b+c\dots
\end{align*}
\end{document}
但是我想更换
如果我替换代码
\begin{tikzpicture}[
baseline=-\the\dimexpr\fontdimen22\textfont2\relax,
strip/.style = {
draw=#1,%color
line width=1em, opacity=0.2,
shorten <=-2mm,shorten >=-2mm,
},
]
\matrix (mtrx) [matrix of math nodes,
column sep=1em,
nodes={text height=1ex,text width=2ex},
ampersand replacement=\&]
{
|[red]|+ \& |[red]|+ \& |[red]| +
\\[3.3mm,between origins]
a_1 \& b_1 \& c_1 \& a_1 \& a_2 \\
a_2 \& b_2 \& c_2 \& a_2 \& b_2 \\
a_3 \& b_3 \& c_3 \& a_3 \& b_3 \\
|[blue]|- \& |[blue]|- \& |[blue]|- \\
};
\draw[thick] (mtrx-4-1.south west) -- (mtrx-2-1.north west);
\draw[thick] (mtrx-4-3.south east) -- (mtrx-2-3.north east);
\path[draw,strip=blue]
(mtrx-4-1.center) edge (mtrx-2-3.center)
(mtrx-4-2.center) edge (mtrx-2-4.center)
(mtrx-4-3.center) -- (mtrx-2-5.center);
\path[draw,strip=red]
(mtrx-2-1.center) edge (mtrx-4-3.center)
(mtrx-2-2.center) edge (mtrx-4-4.center)
(mtrx-2-3.center) -- (mtrx-4-5.center);
\end{tikzpicture}
经过
\begin{tikzpicture}[>=stealth]
\matrix [%
matrix of math nodes,
column sep=1em,
row sep=1em
] (sarrus) {%
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} \\
};
\path ($(sarrus-1-1.north west)-(0.5em,0)$) edge ($(sarrus-3-1.south west)-(0.5em,0)$)
($(sarrus-1-3.north east)+(0.5em,0)$) edge ($(sarrus-3-3.south east)+(0.5em,0)$)
(sarrus-1-1) edge (sarrus-2-2)
(sarrus-2-2) edge[->] (sarrus-3-3)
(sarrus-1-2) edge (sarrus-2-3)
(sarrus-2-3) edge[->] (sarrus-3-4)
(sarrus-1-3) edge (sarrus-2-4)
(sarrus-2-4) edge[->] (sarrus-3-5)
(sarrus-3-1) edge[dashed] (sarrus-2-2)
(sarrus-2-2) edge[->,dashed] (sarrus-1-3)
(sarrus-3-2) edge[dashed] (sarrus-2-3)
(sarrus-2-3) edge[->,dashed] (sarrus-1-4)
(sarrus-3-3) edge[dashed] (sarrus-2-4)
(sarrus-2-4) edge[->,dashed] (sarrus-1-5);
\foreach \c in {1,2,3} {\node[anchor=south] at (sarrus-1-\c.north) {$+$};};
\foreach \c in {1,2,3} {\node[anchor=north] at (sarrus-3-\c.south) {$-$};};
\end{tikzpicture}
这是行不通的。
答案1
为了好玩,另一种方法是使用blkarray
、align*
环境和pstricks
:
\documentclass[svgnames]{article}
\usepackage{blkarray}
\usepackage{amsmath}
\usepackage{pst-node}
\begin{document}
\begin{align*}
D & = \begin{blockarray}{ccccc}
\color{red} + & \color{red} + & \color{red} + \\
\begin{block}{|ccc|cc}
\Rnode{a1}{a_{11}} &\Rnode{b1}{ a_{12}} & \Rnode{c1}{a_{13}} & \Rnode{A1}{a_{11}} & \Rnode{B1}{a_{12}} \\
\Rnode{a2}{ a_{21}} & \Rnode{b2}{a_{22}} & \Rnode{c2}{a_{23}} & \Rnode{A2}{a_{21} }& a_{22} \\
\Rnode{a3}{a_{31}} & \Rnode{b3}{a_{32}} & \Rnode{c3}{a_{33}} & \Rnode{A3}{a_{31}} & \Rnode{B3}{a_{32}} \\
\end{block}
\color{blue} - & \color{blue} - & \color{blue} -
\end{blockarray} \\[-3ex]
& = a_{11} a_{22}a_{33} + a_{12}a_{23}a_{31} + \dots
\psset{linewidth=0.5pt, nodesepA=1pt, nodesepB =1.5pt, arrowinset=0.1}
\foreach \s/\t in {a1/b2,b1/c2,c1/A2} {\ncline{-}{\s}{\t}}
\foreach \s/\t in {b2/c3,c2/A3,A2/B3} {\ncline{->}{\s}{\t}}
\psset{linestyle=dashed, dash=3pt 2pt}
\foreach \s/\t in {a3/b2,b3/c2,c3/A2} {\ncline{-}{\s}{\t}}
\foreach \s/\t in {b2/c1,c2/A1,A2/B1} {\ncline{->}{\s}{\t}}
%
\end{align*}
\end{document}