我对 Beamer 和 LaTeX 还很陌生。我想画一个楼梯矩阵,如附件所示。它应该很简单,但我不知道如何绘制它。请只使用 tikZ(和矩阵),不要使用其他库。非常感谢]1
答案1
相当小:
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\tikz[x=1em, y=1em, inner sep=1em/6]]
\matrix [left delimiter={[}, right delimiter={]}] {
\draw (0,0) \foreach \i [count=\j] in {1,2,1,3,1,2,2,1,1}{
\ifnum\j>1-- ++(0,-1)\fi node [above right] (x-\j) {$x$} -- ++(\i,0)
}
(x-1 -| x-\j) node [left] {possibly nonzero entries}
(x-1 |- x-\j) node [right] {zero entries};
\\};
\end{document}
答案2
使用 TikZ 通过 创建的 Tikz{NiceTabular}
节点nicematrix
。
\documentclass{article}
\usepackage{nicematrix,tikz}
\begin{document}
\begin{NiceTabular}{[*{14}c]}[margin=1em]
x \\
& x && & &&& & \clap{possibly non zero entries} \\
& && x \\
& && & x \\
& && & &&& x \\
& && & &&& & x \\
& && & &&& & && x \\
& && \clap{zero entries}
& &&& & && && x \\
& && & &&& & && && & x \\
\CodeAfter
\tikz \draw (2-|1) -| (3-|2) -| (4-|4) -| (5-|5)
-| (6-|8) -| (7-|9) -| (8-|11) -| (9-|13) -| (10-|14) -- (10-|15) ;
\end{NiceTabular}
\end{document}
答案3
一种选择:
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (A) [matrix of nodes, left delimiter=[,right delimiter={]}]{
x \\
& x\hspace*{3mm}\\
& & x \\
& & & x\hspace*{6mm}\\
& & & & x\\
& & & & & x\hspace*{3mm}\\
& & & & & & x\hspace*{3mm}\\
& & & & & & & x\\
& & & & & & & & x\\};
\foreach \i [remember=\i as \j (initially 1)] in {2,...,9}
\draw (A-\j-\j.south west) -|(A-\i-\i.south west);
\draw (A-9-9.south west)--(A-9-9.south east);
\node[anchor=south west] at ([shift={(5mm,5mm)}]A.south west) {zero entries};
\node[anchor=north east] at ([shift={(-3mm,-3mm)}]A.north east) {possibly nonzero entries};
\end{tikzpicture}
\end{document}