如何绘制带注释的表格?(内有截图)

如何绘制带注释的表格?(内有截图)

我需要在我的论文中绘制一个这样的表格。我知道如何绘制表格,但我不知道如何用索引注释它(行和列)。您有在 LaTex 中如何绘制的示例吗?

在此处输入图片描述

答案1

一种可能的解决方案是tikzmatrix

在此处输入图片描述

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}
\matrix (A) [matrix of math nodes, nodes in empty cells,
    nodes={draw, minimum width=8mm, minimum height=5mm, outer sep=0pt, anchor=center},
    row sep=-\pgflinewidth, column sep=-\pgflinewidth,
    row 3/.style = {nodes={minimum height=8mm}},
    row 5/.style = {nodes={minimum height=8mm}},
    column 3/.style = {nodes={minimum width=10mm}},
    column 4/.style = {nodes={fill=gray}},
    column 6/.style = {nodes={fill=gray}},
    column 7/.style = {nodes={minimum width=10mm}},]
    {& & & R & & ? & & &  \\
     & & & R & & R & & &  \\
     & & & & & & & &  \\
     & & & R & & R & & &  \\ 
     & & & & & & & &  \\
     & & & ? & & R& & &  \\
     & & & R & & R& & &  \\};
    \foreach \i [count=\xi] in {1,2,\dots,$i$,$j$,$k$,\dots,$m-1$,$m$}
        \node[above, font=\scriptsize] at (A-1-\xi.north) {\i\strut};
    \foreach \i [count=\xi] in {1,2,\vdots,$l$,\vdots,$n-1$,$n$}
        \node[left, font=\scriptsize] at (A-\xi-1.west) {\i\strut};
    \foreach \i in {2,4,7}
     \draw[dashed] ([shift={(.5mm,-.5mm)}]A-\i-4.north west) rectangle ([shift={(-.5mm,.5mm)}]A-\i-6.south east);
\end{tikzpicture}
\end{document}

相关内容