我對 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}