Draw a box around selected entries of array

With a simple array environment:

\documentclass[12pt]{article}
\usepackage{array,amsmath}
\begin{document}

$\arraycolsep=2pt
\begin{array}{ | *7c | *8c }\cline{1-7}
  \rule{0pt}{3ex}% more  vertical space for 1st line
  c^{(1)} & \geq & c^{(2)} & \geq & \cdots & \geq & c^{(j)} & \geq & \cdots & \geq & 
  c^{((N-1)K+1)} & \geq & \cdots & \geq & c^{(NK)}\\
  \downarrow &  & \downarrow &  &  &  & \downarrow &  &  &  & \downarrow & & & & 
  \downarrow \\
  \gamma^{(1)} &  & \gamma^{(2)} &  & \cdots &  & \gamma^{(j)} &  & \cdots &  & 
  \gamma^{((N-1)K+1)}& &\cdots &  & \gamma^{(NK)}\\\cline{1-7}
\end{array} 
$

\end{document}

enter image description here


Using tcolorbox package

   \documentclass[10.0pt,a4paper]{article}
   \usepackage[all]{tcolorbox}
  \usepackage[english]{babel}

   \begin{document}
   \begin{minipage}{5mm}
   \begin{tcolorbox}[enhanced,arc=0mm,boxrule=1.5mm,frame hidden,colback=green!8!white,borderline={1mm}{0mm}{black,dotted},text width=5cm]

   $\begin{array}{ccccccc}
   c^{(1)} & \geq & c^{(2)} & \geq & \cdots & \geq & c^{(j)}\\ %& \geq & \cdots & \geq & c^{((N-1)K+1)} & \geq & \cdots & \geq & c^{(NK)}\\
   \downarrow &  & \downarrow &  &  & & \downarrow  \\ %\downarrow &  &  &  & \downarrow & & & & \downarrow &\\
   \gamma^{(1)} &  & \gamma^{(2)} &  & \cdots &  & \gamma^{(j)}\\ %&  & \cdots &  & \gamma^{((N-1)K+1)}& &\cdots &  & \gamma^{(NK)}
   \end{array}$
   \end{tcolorbox}
   \end{minipage}\hfill\hfill\hfill
   \raisebox{0.5ex}{\begin{minipage}{5mm}
    $\begin{array}{ccccccccc}
   \geq & \cdots & \geq & c^{((N-1)K+1)} & \geq & \cdots & \geq & c^{(NK)}\\
      &  &  & \downarrow & & & & \downarrow \\
    & \cdots &  & \gamma^{((N-1)K+1)}& &\cdots &  & \gamma^{(NK)}
   \end{array}$
   \end{minipage}}\hfill\hfill~

   \end{document}

enter image description here

Using TikZ Matrix nodes

    \documentclass[10pt,a4paper]{article}
    \usepackage{tikz}
    \usetikzlibrary{matrix}
    \begin{document}
    \begin{center}
    \begin{tikzpicture}
    \matrix [column sep=1mm]
    {
    \node (a) {};& &  &  &  &  & &  &  \node (b) {}; &  &  &   & & & &  \\
    &\node {$c^{(1)}$}; & \node {$\geq$}; & \node {$c^{(2)}$}; & \node {$\geq$}; & \node {$\cdots$}; & \node {$\geq$}; & \node {$c^{(j)}$}; & &\node {}; \node {$\geq$}; & \node {$\cdots$}; & \node {$\geq$}; & \node {$c^{((N-1)K+1)}$}; & \node {$\geq$}; & \node {$\cdots$}; & \node {$\geq$}; & \node {$c^{(NK)}$};\\
    &\node {$\downarrow$}; &  & \node {$\downarrow$}; &  &  &  & \node {$\downarrow$}; &  & &  &  & \node {$\downarrow$}; & & & & \node {$\downarrow$}; \\
    &\node {$\gamma^{(1)}$}; &  & \node {$\gamma^{(2)}$}; &  & \node {$\cdots$}; &  & \node {$\gamma^{(j)}$}; &\node {};&  & \node {$\cdots$}; &  & \node {$\gamma^{((N-1)K+1)}$}; &  & \node {$\cdots$}; &  & \node {$\gamma^{(NK)}$};\\
    \node (c) {};& &  &  &  &  &  &  & \node (d) {}; &  &  &   & & & &  \\
    };
    \draw [black,thick,dashed] (a.east) -- (c.east) {};
    \draw [black,thick,dashed] (d.west) -- (b.west) {};
    \draw [black,thick,dashed] (a.east) -- (b.west) {};
    \draw [black,thick,dashed] (c.east) -- (d.west) {};
    \end{tikzpicture}

    \end{center}
    \end{document}

enter image description here


With a tikz matrix:

\documentclass[12pt]{article}
\usepackage{array,amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix,fit}
\begin{document}
\begin{center}
\begin{tikzpicture}
\matrix[matrix of math nodes](m){%
c^{(1)} & \geq & c^{(2)} & \geq & \cdots & \geq & c^{(j)} &[8pt] \geq & \cdots & \geq & c^{((N-1)K+1)} & \geq & \cdots & \geq & c^{(NK)}\\
\downarrow &  & \downarrow &  &  &  & \downarrow &  &  &  & \downarrow & & & & \downarrow \\
\gamma^{(1)} &  & \gamma^{(2)} &  & \cdots &  & \gamma^{(j)} &  & \cdots &  & \gamma^{((N-1)K+1)}& &\cdots &  & \gamma^{(NK)}\\
};
\node[fit=(m-1-1)(m-3-7), draw, thick] {};
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

Tags:

Arrays

Draw

Boxes