Color a line in array

The array package allows for inserting tokens at the start of cells:

\documentclass{article}
\usepackage{array}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}

\begin{document}

$
\def\mycolor{}
\newcolumntype{R}{>{\mycolor}r}
\newcolumntype{C}{>{\mycolor}c}
\newcolumntype{L}{>{\mycolor}l}
\begin{array}{RCC@{\mycolor{}+{}}C@{\mycolor{}+{}}C@{\mycolor{}+{}}CL}
  solution&=&\min\{
    &0&34&0&6, \\
    &&0&23&5&18, \\
    &&5&15&10&16, \\
    &&10&10&9&10, \\
    &&19&5&10&16, \\
\noalign{\gdef\mycolor{\color{Emerald}}} % the next row will be colored
    &&23&0&7&5, \\
\noalign{\gdef\mycolor{}} % the next row won't be colored
    &&30&0&9&0
    &\}
\end{array}
$

\end{document}

enter image description here


Another solution could be highlight the background of the row. Here I provide a solution based on the \tikzmark macro (basic idea taken from Background coloring with overlay specification in algorithm2e + beamer package).

The code:

\documentclass{article}
\usepackage{amsmath}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{array}
\usepackage{tikz}

\newcommand{\fcol}{Emerald!20}
\newcommand{\bcol}{Emerald}

%% code by Andrew Stacey 
% https://tex.stackexchange.com/questions/51582/background-coloring-with-overlay-specification-in-algorithm2e-beamer-package#51582

\makeatletter
\tikzset{%
     remember picture with id/.style={%
       remember picture,
       overlay,
       draw=\bcol,
       save picture id=#1,
     },
     save picture id/.code={%
       \edef\pgf@temp{#1}%
       \immediate\write\pgfutil@auxout{%
         \noexpand\savepointas{\pgf@temp}{\pgfpictureid}}%
     },
     if picture id/.code args={#1#2#3}{%
       \@ifundefined{save@pt@#1}{%
         \pgfkeysalso{#3}%
       }{
         \pgfkeysalso{#2}%
       }
     }
   }

   \def\savepointas#1#2{%
  \expandafter\gdef\csname save@pt@#1\endcsname{#2}%
}

\def\tmk@labeldef#1,#2\@nil{%
  \def\tmk@label{#1}%
  \def\tmk@def{#2}%
}

\tikzdeclarecoordinatesystem{pic}{%
  \pgfutil@in@,{#1}%
  \ifpgfutil@in@%
    \tmk@labeldef#1\@nil
  \else
    \tmk@labeldef#1,(0pt,0pt)\@nil
  \fi
  \@ifundefined{save@pt@\tmk@label}{%
    \tikz@scan@one@point\pgfutil@firstofone\tmk@def
  }{%
  \pgfsys@getposition{\csname save@pt@\tmk@label\endcsname}\save@orig@pic%
  \pgfsys@getposition{\pgfpictureid}\save@this@pic%
  \pgf@process{\pgfpointorigin\save@this@pic}%
  \pgf@xa=\pgf@x
  \pgf@ya=\pgf@y
  \pgf@process{\pgfpointorigin\save@orig@pic}%
  \advance\pgf@x by -\pgf@xa
  \advance\pgf@y by -\pgf@ya
  }%
}
\makeatother

\newcommand{\tikzmarkin}[1]{%
      \tikz[remember picture with id=#1]
      \draw[line width=1pt,rectangle,rounded corners,fill=\fcol]
      (pic cs:#1) ++(0.1,-0.15) rectangle (-0.1,0.32)
      ;}

\newcommand\tikzmarkend[2][]{%
\tikz[remember picture with id=#2] #1;}

\begin{document}
\[
\begin{array}{rcc@{+}c@{+}c@{+}cl}
  solution&=&\min\{
    &0&34&0&6, \\
    &&0&23&5&18, \\
    &&5&15&10&16, \\
    &&10&10&9&10, \\
    &&19&5&10&16, \\
   &&\tikzmarkin{a}23&0&7&5,\tikzmarkend{a} \\
    &&30&0&9&0
    &\}
\end{array}
\]

\end{document}

The graphical result:

enter image description here

The same result can be achieved by means of the hf-tikz package. The code:

\documentclass{article}
\usepackage{amsmath}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{array}
\usepackage[customcolors]{hf-tikz}

\hfsetfillcolor{Emerald!20}
\hfsetbordercolor{Emerald}


\begin{document}
\[
\begin{array}{rcc@{+}c@{+}c@{+}cl}
  solution&=&\min\{
    &0&34&0&6, \\
    &&0&23&5&18, \\
    &&5&15&10&16, \\
    &&10&10&9&10, \\
    &&19&5&10&16, \\
   &&\tikzmarkin{a}23&0&7&5,\tikzmarkend{a} \\
    &&30&0&9&0
    &\}
\end{array}
\]

\end{document}

You can use the package tabu which provides the commend \rowfont.

\documentclass{article}
\usepackage{amsmath}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{array}
\usepackage{tabu}
\begin{document}
\[
\begin{tabu}{rcc@{+}c@{+}c@{+}cl}
  solution&=&\min\{
    &0&34&0&6, \\
    &&0&23&5&18, \\
    &&5&15&10&16, \\
    &&10&10&9&10, \\
    &&19&5&10&16, \\
  \rowfont{\color{Emerald}} &&23&0&7&5, \\
    &&30&0&9&0
    &\}
\end{tabu}
\]

\end{document}