我遇到了麻烦,因为我想创建两条垂直线来生成 3×3 矩阵的行列式。我尝试使用范围环境,但结果却出现错误。我该怎么办?这是我的代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[upright]{fourier}
\usepackage{tikz}
\usepackage{stix}
\usetikzlibrary{matrix}
\usepackage{fullpage,amsmath}
\begin{document}
\begin{tikzpicture}[baseline=(A.center)]
\tikzset{BarreStyle/.style = {opacity=.4,line width=4 mm,line cap=round,color=#1}}
\tikzset{SignePlus/.style = {above left,inner sep=1.5pt,opacity=.4,circle,fill=#1}}
\tikzset{SigneMoins/.style = {below left,inner sep=-0.5pt,opacity=.4,circle,fill=#1}}
\tikzset{PlusProduct/.style={anchor=north west,rectangle,rounded corners=5pt,inner sep=2pt,outer sep=2.5pt,opacity=.4,fill=#1}}
\tikzset{MoinsProduct/.style={anchor=south west,rectangle,rounded corners=5pt,inner sep=2pt,outer sep=2.5pt,opacity=.4,fill=#1}}
% the matrices
\matrix (A) [matrix of math nodes, nodes = {node style ge},,column sep=0 mm]
{ a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33} \\
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23}\\
};
\begin{scope} % From here to ...
\draw (1-|1) -- (1-|3);
\draw (3-|1) -- (3-|3);
\end{scope} % ... here, Overleaf gives me error, ... why?
\draw [BarreStyle=blue] (A-1-1.north west) node[SignePlus=blue] {$+$} to (A-3-3.south east) node[PlusProduct=blue]{$a_{11}\cdot a_{22}\cdot a_{33}$};
\draw [BarreStyle=blue] (A-2-1.north west) node[SignePlus=blue] {$+$} to (A-4-3.south east) node[PlusProduct=blue]{$a_{21}\cdot a_{32}\cdot a_{13}$};
\draw [BarreStyle=blue] (A-3-1.north west) node[SignePlus=blue] {$+$} to (A-5-3.south east) node[PlusProduct=blue]{$a_{31}\cdot a_{12}\cdot a_{23}$};
\draw [BarreStyle=red] (A-3-1.south west) node[SigneMoins=red] {\strut $-$} to (A-1-3.north east) node[MoinsProduct=red]{$a_{31}\cdot a_{22}\cdot a_{13}$};
\draw [BarreStyle=red] (A-4-1.south west) node[SigneMoins=red] {\strut $-$} to (A-2-3.north east) node[MoinsProduct=red]{$a_{11}\cdot a_{32}\cdot a_{23}$};
\draw [BarreStyle=red] (A-5-1.south west) node[SigneMoins=red] {\strut $-$} to (A-3-3.north east) node[MoinsProduct=red]{$a_{21}\cdot a_{12}\cdot a_{33}$};
\end{tikzpicture}
\end{document}
提前感谢
答案1
我猜,你喜欢在矩阵中添加左分隔符和右分隔符:
\documentclass{article}
\usepackage[upright]{fourier}
\usepackage{tikz}
\usepackage{fullpage,amsmath}
%\usepackage{stix}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[baseline=(A.center)]
\tikzset{Barr/.style = {opacity=.4,line width=4 mm,line cap=round,color=#1},
Sigp/.style = {circle, minimum size=4mm, left,inner sep=0pt,opacity=.4,fill=blue,
node contents={$+$}},
Sigm/.style = {Sigp,fill=red, node contents={\vphantom{+}$-$}},
Prod/.style = {rounded corners=5pt,
inner sep=2pt,opacity=.4,fill=#1, right},
}
% the matrices
\matrix (A) [matrix of math nodes,
%nodes = {node style ge},
column sep=1ex,
row sep=1ex
]
{ a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33} \\
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
};
\draw[semithick] (A-1-1.north west) -- (A-3-1.south west)
(A-1-3.north east) -- (A-3-3.south east);
\draw [Barr=blue] (A-1-1.north west) node[Sigp] to (A-3-3.south east) node[Prod=blue]{$a_{11}\cdot a_{22}\cdot a_{33}$};
\draw [Barr=blue] (A-2-1.north west) node[Sigp] to (A-4-3.south east) node[Prod=blue]{$a_{21}\cdot a_{32}\cdot a_{13}$};
\draw [Barr=blue] (A-3-1.north west) node[Sigp] to (A-5-3.south east) node[Prod=blue]{$a_{31}\cdot a_{12}\cdot a_{23}$};
\draw [Barr=red] (A-3-1.south west) node[Sigm] to (A-1-3.north east) node[Prod=red]{$a_{31}\cdot a_{22}\cdot a_{13}$};
\draw [Barr=red] (A-4-1.south west) node[Sigm] to (A-2-3.north east) node[Prod=red]{$a_{11}\cdot a_{32}\cdot a_{23}$};
\draw [Barr=red] (A-5-1.south west) node[Sigm] to (A-3-3.north east) node[Prod=red]{$a_{21}\cdot a_{12}\cdot a_{33}$};
\end{tikzpicture}
\end{document}
(我擅自对你的图像设计做了一些小改动)
编辑: 啊,图片的最后两行是矩阵的扩展(真丢脸)。现在(希望)图片是正确的):
\documentclass{article}
\usepackage[upright]{fourier}
\usepackage{tikz}
\usepackage{fullpage,amsmath}
%\usepackage{stix}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[baseline=(A.center)]
\tikzset{Barr/.style = {opacity=.4,line width=4 mm,line cap=round,color=#1},
Sigp/.style = {circle, fill=blue, fill opacity=0.4, text opacity=1,
minimum size=4mm, left, inner sep=0pt,
node contents={$+$}},
Sigm/.style = {Sigp,fill=red, node contents={\vphantom{+}$-$}},
Prod/.style = {rounded corners=5pt,
fill=#1, fill opacity=0.4, text opacity=1, inner sep=2pt, right},
}
% the matrices
\matrix (A) [matrix of math nodes,
column sep=1ex,
row sep=1ex
]
{ a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33} \\
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
};
\draw[semithick] (A-1-1.north west) -- (A-3-1.south west)
(A-1-3.north east) -- (A-3-3.south east);
\draw [Barr=blue] (A-1-1.north west) node[Sigp] to (A-3-3.south east) node[Prod=blue]{$a_{11}\cdot a_{22}\cdot a_{33}$}
(A-2-1.north west) node[Sigp] to (A-4-3.south east) node[Prod=blue]{$a_{21}\cdot a_{32}\cdot a_{13}$}
(A-3-1.north west) node[Sigp] to (A-5-3.south east) node[Prod=blue]{$a_{31}\cdot a_{12}\cdot a_{23}$};
\draw [Barr=red] (A-3-1.south west) node[Sigm] to (A-1-3.north east) node[Prod=red]{$a_{31}\cdot a_{22}\cdot a_{13}$}
(A-4-1.south west) node[Sigm] to (A-2-3.north east) node[Prod=red]{$a_{11}\cdot a_{32}\cdot a_{23}$}
(A-5-1.south west) node[Sigm] to (A-3-3.north east) node[Prod=red]{$a_{21}\cdot a_{12}\cdot a_{33}$};
\end{tikzpicture}
\end{document}