我使用以下方法创建了此列数组matrix
:
\documentclass[crop,tikz,convert={outext=.svg,command=\unexpanded{pdf2svg \infile\space\outfile}},multi=false]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, matrix, arrows.meta}
\begin{document}
\begin{tikzpicture}[x=1cm,y=1.5cm]
\matrix (F) [%
matrix of nodes,
nodes={
rectangle,
minimum height=6mm,
minimum width=6mm,
anchor=center,
inner sep=0pt, outer sep=0pt
}
] at (0, 0) { 0 \\ 3 \\ 7 \\ 13 \\ 14 \\ };
\draw (F-1-1.north west) --
(F-1-1.north east) --
(F-5-1.south east) --
(F-5-1.south west) --
(F-1-1.north west);
\end{tikzpicture}
\end{document}
答案1
首先,您可以在矩阵周围放置节点。
\documentclass[crop,tikz,convert={outext=.svg,command=\unexpanded{pdf2svg \infile\space\outfile}},multi=false]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, matrix, arrows.meta}
\begin{document}
\begin{tikzpicture}[x=1cm,y=1.5cm]
\matrix (F) [%
matrix of nodes,
nodes={
rectangle,
minimum height=6mm,
minimum width=6mm,
anchor=center,
inner sep=0pt, outer sep=0pt
}
] at (0, 0) { 0 \\ 3 \\ 7 \\ 13 \\ 14 \\ };
\draw (F-1-1.north west) rectangle (F-5-1.south east);
\foreach \c [count=\i from 1] in {$\$_i$,A,C,G,T}
\node[left=3pt of F-\i-1]{\c};
\node[above=3pt of F-1-1]{$F$};
\end{tikzpicture}
\end{document}
这样,您还可以使用节点坐标和锚点在矩阵周围绘制您想要的内容。
编辑
有很多方法可以绘制左侧的括号,但使用节点名称,您可以轻松完成:
\begin{tikzpicture}[x=1cm,y=1.5cm]
\matrix (F) [%
matrix of nodes,
nodes={
rectangle,
minimum height=6mm,
minimum width=6mm,
anchor=center,
inner sep=0pt, outer sep=0pt
}
] at (0, 0) { 0 \\ 3 \\ 7 \\ 13 \\ 14 \\ };
\draw (F-1-1.north west) rectangle (F-5-1.south east);
\draw ([xshift=-4pt]F-1-1.north west) --++ (-2pt,0) |- ([xshift=-4pt]F-3-1.south west) node[left,pos=0.25]{$A$};
\node[above=3pt of F-1-1]{\textit{last}};
\end{tikzpicture}