我正在尝试排版图中所示的矩阵,我考虑过很多例子,特别是 easybmat。但没有比我下面给出的方法更接近的方法了。然而,它并没有达到我想要的准确度。有没有办法让图表更接近所需的图片?
这是我的代码:
\documentclass{article}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{easybmat}
\begin{document}
\[
\sbox0{$\begin{array}{c |}a_1\\ \hline\end{array}$}
\sbox1{$\begin{array}{c c |}b_1&b_2\\ \hline\end{array}$}
\sbox2{$\begin{array}{c c c |}c_1& \ c_2&c_3\\ \hline\end{array}$}
\sbox3{$\begin{array}{c c c c |}...&...&... &...\\ \hline\end{array}$}
\sbox4{$\begin{array}{c c c c c |}...&...&...&...&...\\ \hline\end{array}$}
\sbox5{$\begin{array}{c c c c c c |}\alpha_n &\beta_n&\gamma_n&\epsilon_n&\delta_n& ...............\\ \hline\end{array}$}
%
A=\left(
\begin{array}{c c c c c c c }
\usebox{0} \ a_2 \ \ \ a_3 \ \ a_4 \ a_5 \ ... \ ... \ ... \ ... \ ... \ a_n\\
\usebox{1} \ b_3 \ \ b_4 \ b_5 \ ... \ ... \ ... \ ... \ ... \ b_n\\
\usebox{2} \ c_4 \ c_5 \ ... \ ... \ ... \ ... \ ..\ c_n\\
\usebox{3} \ ... \ ... \ ... \ ... \ ... \ ... \ ... \\
\usebox{4} \ ... \ ... \ ... \ ... \ ... \\
\usebox{5} \\
\end{array}
\right)
\]
\end{document}
答案1
您还可以使用tikz matrix
:
\documentclass{article}
\usepackage{amsmath,tikz}
\usetikzlibrary{matrix, positioning}
\begin{document}
\begin{equation}
A=\begin{tikzpicture}[baseline=-.8ex]
\matrix[%
matrix of math nodes,
nodes in empty cells,
column 6/.style={nodes={text width=1.2em}},
nodes={minimum height=4ex, text width=1.5em, align=center, inner sep=4pt},
left delimiter={(},right delimiter={)},
inner xsep=-1pt, column sep=0pt,
] (m)
{%
a_1 & a_2 & a_3 & a_4 & \dots &[2pt] a_n \\
b_1 & b_2 & b_3 & b_4 & \dots & b_n \\
c_1 & c_2 & c_3 & c_4 & \dots & c_n \\
\dots & \dots & \dots & \dots & \dots & \dots \\
\alpha_{n} &\beta_{n}&\gamma_{n}&\delta_{n}& \dots & \mu_{n} \\
};
\foreach \n in {1,...,3}{%
\draw [->] (m-\n-1.south west) -- (m-\n-\n.south east) -- (m-1-\n.north east) node[above]{$P_{\n}$};
}
\draw [->] (m-4-1.south west) -- (m-4-5.south east) -- (m-1-5.north east) node[above]{$P_{n}$};
\end{tikzpicture}
\end{equation}
\end{document}
答案2
您可以使用tikzmark
库来标记线连接处的点,然后使用正常tikz
路径绘制这些线
\documentclass{article}
\usepackage{amsmath,tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\[
A=\left(
\begin{array}{*7c}
\tikzmark{11}\,a_2\,\tikzmark{12} & a_3 & a_4 & a_5 & \dots & \dots& a_n\\
\tikzmark{21}\,b_3 & \,b_4\,\tikzmark{22} & b_5 & \dots& \dots& \dots& b_n\\
\tikzmark{31}\,c_4 & c_5 & \dots\tikzmark{32}& \dots& \dots& \dots& c_n\\
\tikzmark{41}\dots& \dots& \dots& \dots\tikzmark{42}& \dots& \dots& \dots\\
\tikzmark{51}\dots& \dots& \dots& \dots& \dots\tikzmark{52}& \dots& \dots \\
\end{array}
\right)
\]
\begin{tikzpicture}[remember picture, overlay]
\foreach \n in {1,...,5}
\draw [->] ([yshift=-3pt]pic cs:\n1) -- ([yshift=-3pt]pic cs:\n2) --++(0,\n\baselineskip)node[above]{$p_\n$};
\end{tikzpicture}
\end{document}
答案3
pNiceArray
这是使用和 Tikz 的解决方案nicematrix
。
\documentclass{article}
\usepackage{nicematrix,tikz}
\begin{document}
$\begin{pNiceArray}[margin]{cccccc}
a_1 & a_2 & a_3 & a_4 & \cdots & a_n \\
b_1 & b_2 & b_3 & b_3 & \cdots & b_n \\
c_1 & c_2 & c_3 & c_4 & \cdots & c_n \\
\cdots & \cdots & \cdots & \cdots & \cdots & \cdots \\
\alpha_n & \beta_n & \gamma_n & \delta_n & \cdots & \mu_n \\
\CodeAfter
\begin{tikzpicture} [->]
\draw (2-|1) -| (1-|2) node [above] {$P_1$} ;
\draw (3-|1) -| (1-|3) node [above] {$P_2$} ;
\draw (4-|1) -| (1-|4) node [above] {$P_3$} ;
\draw (5-|1) -| (1-|6) node [above] {$P_n$} ;
\end{tikzpicture}
\end{pNiceArray}$
\end{document}
您需要多次编译(因为使用了 PGF/Tikz 节点nicematrix
)。