3

I have an array in my latex template something like this:

enter image description here

This picture is made with Tikz. Here is the code:

\begin{figure}[!h]
\centering
\begin{tikzpicture} [
                        nodes in empty cells,
                        nodes={minimum size=10mm},
                        row sep=-\pgflinewidth,
                        column sep=-\pgflinewidth
                    ]
    border/.style={draw}
\tikzstyle{bg_gray} = [fill=gray!20]

\matrix(vector)[
    matrix of nodes,
    row 1/.style={nodes={draw,font=\strut}},
    row 2/.style={nodes={draw=none, minimum width=0.4cm}},
    nodes={draw}
    ]
{
    |[draw=none, minimum width=1.5cm]| $\textbf{a[i]}$ & $4$ & $7$ & $10$ & |[bg_gray]| $6$ & |[bg_gray]| $4$ & |[bg_gray]| $1$ & $3$ & $6$ & $11$ & |[bg_gray]| $9$ & |[bg_gray]| $5$ \\
    \textbf{\small{i}} & \small{0} & \small{1} & \small{2} & \small{3} & \small{4} & \small{5} & \small{6} & \small{7} & \small{8} & \small{9} & \small{10} \\
};

\end{tikzpicture} \caption{A random array for observation} \label{fig:array_observation} \end{figure}

But my problem is some system like ACM doesn't allow to use Tikz (List of Accepted LaTeX Packages). Please suggest how I can re-create a similar image using any of other packages they allowed?

1 Answers1

7

The following uses only approved packages:

enter image description here

\documentclass{article}

\usepackage[table]{xcolor} \usepackage{array}

\begin{document}

\begin{figure} \centering \makebox[25pt]{$\mathbf{Arr}[\mathbf{i}]$} \begin{tabular}{ | *{11}{w{c}{12pt} |} } \hline \rule[-.75\normalbaselineskip]{0pt}{2\normalbaselineskip}% Strut 16 & 5 & 11 & \cellcolor{gray!20}6 & \cellcolor{gray!20}7 & \cellcolor{gray!20}3 & 8 & 6 & 15 & \cellcolor{gray!20}21 & \cellcolor{gray!20}14 \ \hline \end{tabular}

\medskip

\footnotesize \makebox[25pt]{$\mathbf{i}$} \begin{tabular}{ *{11}{w{c}{\dimexpr12pt+\arrayrulewidth}} } 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \end{tabular} \caption{An array $\mathbf{Arr}$} \end{figure}

\end{document}

Werner
  • 603,163