在下面的例子中,箭头适合矩阵内部,但我希望它们停止在分隔符的边界处。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,decorations.pathreplacing, calc, positioning,fit}
\begin{document}
\begin{tikzpicture}[>=stealth,thick,baseline]
\matrix [matrix of math nodes,left delimiter=(,right delimiter=)](A){
a_{1,1} & a_{1,2} & \dots & a_{1,j} & \dots & a_{1,n}\\
a_{2,1} & a_{2,2} & \dots & a_{2,j} & \dots & a_{2,n}\\
\vdots & \vdots & & \vdots & & \vdots\\
a_{i,1} & a_{i,2} & \dots & a_{i,j} & \dots & a_{i,n}\\
\vdots & \vdots & & \vdots & & \vdots\\
a_{n,1} & a_{n,2} & \dots & a_{n,j} & \dots & a_{n,n}\\
};
\node[
fit=(A-4-6)(A-4-6),
inner xsep=20pt,inner ysep=0,
label=right: $i$-ième ligne
](L) {};
\node[
fit=(A-6-4)(A-6-4),
inner xsep=20pt,inner ysep=20pt,
label=below: $j$-ième colonne
](C) {};
\draw[->](L.east)-- (A-4-6);
\draw[->](C.south)-- (A-6-4);
\end{tikzpicture}
\end{document}
答案1
添加xshift
:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,decorations.pathreplacing, calc, positioning,fit}
\begin{document}
\begin{tikzpicture}[>=stealth,thick,baseline]
\matrix [matrix of math nodes,left delimiter=(,right delimiter=)](A){
a_{1,1} & a_{1,2} & \dots & a_{1,j} & \dots & a_{1,n}\\
a_{2,1} & a_{2,2} & \dots & a_{2,j} & \dots & a_{2,n}\\
\vdots & \vdots & & \vdots & & \vdots\\
a_{i,1} & a_{i,2} & \dots & a_{i,j} & \dots & a_{i,n}\\
\vdots & \vdots & & \vdots & & \vdots\\
a_{n,1} & a_{n,2} & \dots & a_{n,j} & \dots & a_{n,n}\\
};
\node[
fit=(A-4-6)(A-4-6),
inner xsep=20pt,inner ysep=0,
label=right: $i$-ième ligne
](L) {};
\node[
fit=(A-6-4)(A-6-4),
inner xsep=20pt,inner ysep=20pt,
label=below: $j$-ième colonne
](C) {};
\draw[->](L.east)-- ([xshift=12pt]A-4-6.east);
\draw[->](C.south)-- (A-6-4);
\end{tikzpicture}
\end{document}
或者缩短箭头:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,decorations.pathreplacing, calc, positioning,fit}
\begin{document}
\begin{tikzpicture}[>=stealth,thick,baseline]
\matrix [matrix of math nodes,left delimiter=(,right delimiter=)](A){
a_{1,1} & a_{1,2} & \dots & a_{1,j} & \dots & a_{1,n}\\
a_{2,1} & a_{2,2} & \dots & a_{2,j} & \dots & a_{2,n}\\
\vdots & \vdots & & \vdots & & \vdots\\
a_{i,1} & a_{i,2} & \dots & a_{i,j} & \dots & a_{i,n}\\
\vdots & \vdots & & \vdots & & \vdots\\
a_{n,1} & a_{n,2} & \dots & a_{n,j} & \dots & a_{n,n}\\
};
\node[
fit=(A-4-6)(A-4-6),
inner xsep=20pt,inner ysep=0,
label=right: $i$-ième ligne
](L) {};
\node[
fit=(A-6-4)(A-6-4),
inner xsep=20pt,inner ysep=20pt,
label=below: $j$-ième colonne
](C) {};
\draw[->, shorten > =12pt](L.east)-- (A-4-6.east);
\draw[->](C.south)-- (A-6-4);
\end{tikzpicture}
\end{document}
顺便问一下你为什么需要fit
?
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix, positioning}
\begin{document}
\begin{tikzpicture}[>=stealth,thick,baseline]
\matrix [matrix of math nodes,left delimiter=(,right delimiter=)](A){
a_{1,1} & a_{1,2} & \dots & a_{1,j} & \dots & a_{1,n}\\
a_{2,1} & a_{2,2} & \dots & a_{2,j} & \dots & a_{2,n}\\
\vdots & \vdots & & \vdots & & \vdots\\
a_{i,1} & a_{i,2} & \dots & a_{i,j} & \dots & a_{i,n}\\
\vdots & \vdots & & \vdots & & \vdots\\
a_{n,1} & a_{n,2} & \dots & a_{n,j} & \dots & a_{n,n}\\
};
\node[right =30pt of A-4-6.east](L) {$i$-ième ligne};
\node[below=20pt of A-6-4.south](C) {$j$-ième colonne};
\draw[->, shorten > =12pt](L.west)-- (A-4-6.east);
\draw[->](C.north)-- (A-6-4.south);
\end{tikzpicture}
\end{document}
答案2
矩阵分隔符nodes
默认未命名。因此,如果您添加名称,则可以像任何其他节点一样使用它们作为参考,并且线条将在其边界上停止。
在下面的代码中,我使用every right delimiter
样式添加了稍后会使用的名称。
矩阵是一种特殊的节点,它包含其他节点。因此,如果您想在matrix
边界上停止一条线,可以使用矩阵名称作为参考。矩阵元素有自己的边界。我使用列中心和南矩阵边界之间的交点来放置垂直箭头,使用行中心和右分隔符上的东锚来放置水平箭头。如果您需要理解-|
(或|-
)语法,请查看https://tex.stackexchange.com/a/481234/1952或者https://tex.stackexchange.com/a/22954/1952。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,decorations.pathreplacing, calc, positioning,fit}
\begin{document}
\begin{tikzpicture}[>=stealth,thick,baseline,
every right delimiter/.append style={name=rd},
]
\matrix [matrix of math nodes,
left delimiter=(,
right delimiter=),
](A){
a_{1,1} & a_{1,2} & \dots & a_{1,j} & \dots & a_{1,n}\\
a_{2,1} & a_{2,2} & \dots & a_{2,j} & \dots & a_{2,n}\\
\vdots & \vdots & & \vdots & & \vdots\\
a_{i,1} & a_{i,2} & \dots & a_{i,j} & \dots & a_{i,n}\\
\vdots & \vdots & & \vdots & & \vdots\\
a_{n,1} & a_{n,2} & \dots & a_{n,j} & \dots & a_{n,n}\\
};
\draw[<-] (rd.east|-A-4-1.center)--++(0:6mm) node[right]{$i$-ième colonne};
\draw[<-] (A.south-|A-1-4.center) --++(-90:6mm) node[below]{$j$-ième colonne};
\end{tikzpicture}
\end{document}