# How to draw a table with annotation? (screenshot inside)

I need to draw a table like this into my paper. I know to draw a table but I'm not sure how to annotate it (rows and columns) with indexes. Do you have some example how to do it in LaTex?

• Please give us the code for the table so somebody can concentrate on the indices rather than having to reproduce the picture. – cfr Apr 2 '15 at 12:47
• Are the labels on the top supposed to align with the columns? – Aditya Apr 2 '15 at 14:34

A possible solution with a 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}