我的问题基本上与这个,但用许多箭头代替。(我想看看 TikZ 解决方案——我觉得一旦我在这里得到它,我就可以推断并在其他情况下做到这一点......)
如何在下表中绘制指向西南方向的对角箭头?我想要一个穿过 的箭头x_{1}^1
、一个穿过x_{1}^2
AND 的箭头x_{2}^1
、一个穿过x_{1}^3
和x_{2}^2
的箭头x_{3}^1
、一个穿过x_{2}^3
和的箭头x_{3}^2
和一个穿过 的箭头x_{3}^3
。为了使图片更清晰,我希望每个箭头从它穿过的第一个元素的右上角开始,到它穿过的最后一个元素的左下角结束。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows}
\newcommand{\tikzmark}[1]{%
\tikz[overlay,remember picture] \node (#1) {};}
\[
\begin{array}{*{6}{c}}
E_{1} & = & x_{1}^1 & x_{1}^2 & x_{1}^3 & ... \\
\\
E_{2} & = & x_{2}^1 & x_{2}^2 & x_{2}^3 & ... \\
\\
E_{3} & = & x_{3}^1 & x_{3}^2 & x_{3}^3 & ... \\
... \\
\end{array}
\]
\end{document}
答案1
您可以为每个箭头放置两个节点(一个表示起点,另一个表示终点),然后使用循环连接每对节点:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows}
\newcommand{\tikzmark}[1]{%
\tikz[overlay,remember picture] \node (#1) {};}
\begin{document}
\[
\begin{array}{*{6}{c}}
E_{1} & = & \tikzmark{e1}x_{1}^1\tikzmark{s1} & x_{1}^2\tikzmark{s2} & x_{1}^3\tikzmark{s3} & ... \\
\\
E_{2} & = & \tikzmark{e2}x_{2}^1 & x_{2}^2 & x_{2}^3\tikzmark{s4} & ... \\
\\
E_{3} & = & \tikzmark{e3}x_{3}^1 & \tikzmark{e4}x_{3}^2 & \tikzmark{e5}x_{3}^3\tikzmark{s5} & ... \\
... \\
\end{array}
\]
\begin{tikzpicture}[overlay,remember picture]
\foreach \i in {1,2,...,5}
\draw[->] ($(s\i.north east)+(-0.1,0.1)$) -- ($(e\i.south west)+(0.1,0)$);
\end{tikzpicture}
\end{document}
如上图所示,线条不是平行的;为了纠正这个问题,也许最快的方法是使用节点矩阵:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of math nodes,inner sep=1pt,row sep=1em,column sep=1em] (M)
{
E_1 & = & x_{1}^{1} & x_{1}^{2} & x_{1}^{3} & \cdots \\
E_2 & = & x_{2}^{1} & x_{2}^{2} & x_{2}^{3} & \cdots \\
E_3 & = & x_{3}^{1} & x_{3}^{2} & x_{3}^{3} & \cdots \\
\cdots \\
}
;
\draw[->] (M-1-3.north east) -- (M-1-3.south west);
\draw[->] (M-1-4.north east) -- (M-2-3.south west);
\draw[->] (M-1-5.north east) -- (M-3-3.south west);
\draw[->] (M-1-3.north east) -- (M-1-3.south west);
\draw[->] (M-2-5.north east) -- (M-3-4.south west);
\draw[->] (M-3-5.north east) -- (M-3-5.south west);
\end{tikzpicture}
\end{document}
答案2
这是我很久以前做的一个例子 texample.net 您只需进行少量修改即可获得您想要的。
% Mnemonic rule for matrix determinant
% Author: Alain Matthes
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[upright]{fourier}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{fullpage,amsmath}
\begin{document}
\tikzset{node style ge/.style={circle}}
det(M)=
$\left|
\begin{matrix}
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33} \\
\end{matrix}%
\right|$
=$\big(a_{11}a_{22}a_{33}+a_{21}a_{32}a_{13}+a_{31}a_{12}a_{33}\big)-\big(a_{13}a_{22}a_{31}+a_{23}a_{32}a_{11}+a_{33}a_{12}a_{31}\big)$
\begin{tikzpicture}[baseline=(A.center)]
\tikzset{BarreStyle/.style = {opacity=.4,line width=4 mm,line cap=round,color=#1}}
\tikzset{SignePlus/.style = {above left,,opacity=1,circle,fill=#1!50}}
\tikzset{SigneMoins/.style = {below left,,opacity=1,circle,fill=#1!50}}
% les 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_{13 }\\
};
\draw [BarreStyle=blue] (A-1-1.north west) node[SignePlus=blue] {$+$} to (A-3-3.south east) ;
\draw [BarreStyle=blue] (A-2-1.north west) node[SignePlus=blue] {$+$} to (A-4-3.south east) ;
\draw [BarreStyle=blue] (A-3-1.north west) node[SignePlus=blue] {$+$} to (A-5-3.south east) ;
\draw [BarreStyle=red] (A-3-1.south west) node[SigneMoins=red] {$-$} to (A-1-3.north east);
\draw [BarreStyle=red] (A-4-1.south west) node[SigneMoins=red] {$-$} to (A-2-3.north east);
\draw [BarreStyle=red] (A-5-1.south west) node[SigneMoins=red] {$-$} to (A-3-3.north east);
\end{tikzpicture}
\end{document}
答案3
相同psmatrix
。使用以下命令运行xelatex
\documentclass{article}
\usepackage{pst-node}
\begin{document}
\[ \begin{psmatrix}[colsep=2mm,rowsep=2mm]
E_1 & = & [name=A]x_1^1 & x_1^2 & x_1^3 & \ldots \\
E_2 & = & x_2^1 & x_2^2 & x_2^3 & \ldots \\
E_3 & = & x_3^1 & x_3^2 & [name=B]x_3^3 & \ldots \\
\ldots
\end{psmatrix} \]
\psset{arrows=-D>,arrowscale=1.5,nodesep=-1.5em,linewidth=0.5pt}
\pcline(!\psGetNodeCenter{A} A.x 0.01 add A.y 0.01 add)(A)
\ncline{1,4}{2,3}\ncline{1,5}{3,3}\ncline{2,5}{3,4}
\pcline(!\psGetNodeCenter{B} B.x 0.01 add B.y 0.01 add)(B)
\end{document}
答案4
带有{NiceMatrix}
包装的nicematrix
。箭头平行。
\documentclass{article}
\usepackage{nicematrix,tikz}
\begin{document}
\renewcommand{\arraystretch}{1.6}
$\begin{NiceMatrix}
E_1 & = & x_{1}^{1} & x_{1}^{2} & x_{1}^{3} & \cdots \\
E_2 & = & x_{2}^{1} & x_{2}^{2} & x_{2}^{3} & \cdots \\
E_3 & = & x_{3}^{1} & x_{3}^{2} & x_{3}^{3} & \cdots \\
\CodeAfter
\begin{tikzpicture}
\draw [->] (1-|4) -- (2-|3) ;
\draw [->] (1-|5) -- (3-|3) ;
\draw [->] (1-|6) -- (4-|3) ;
\draw [->] (2-|6) -- (4-|4) ;
\draw [->] (3-|6) -- (4-|5) ;
\end{tikzpicture}
\end{NiceMatrix}$
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。