4

I need to highlight rows 3rd and 5th in the following table. I the package xcolor with the optional argument table, but it doesn't work. And gives me an error.

\begin{table}[h]
  \centering

\resizebox{0.8\textwidth}{!}{\begin{minipage}{\textwidth}
       \caption{\textbf{State Table for Example 1}}
  \label{table: state table1}

\hfil % This is new 
\begin{tabular}{cc|cc}
x & y & X & Y \\ 
\hline
   $\bar{0}$  & $\bar{0}$ & 1 &1 \\ 
   \rowcolor{blue}[0.9] 0  & 1 & 0 &1 \\ 
   $\bar{1}$  & $\bar{1}$ & 0 & 0 \\ 
   \rowcolor{blue}[0.9] 1  & 0 & 1 &0 \\ 
  \end{tabular}
      \end{minipage}}

\end{table}

\end{document}

Any suggestion please?

azetina
  • 28,884
Rebecca
  • 1,189

2 Answers2

4
\documentclass{article}
\usepackage{graphicx}
\usepackage{colortbl}
\begin{document}

\begin{tabular}{cc|cc}
x & y & X & Y \\ 
\hline
   $\bar{0}$  & $\bar{0}$ & 1 &1 \\ 
   \rowcolor[gray]{.9} 0  & 1 & 0 &1 \\ 
   $\bar{1}$  & $\bar{1}$ & 0 & 0 \\ 
   \rowcolor[gray]{.5} 1  & 0 & 1 &0 \\ 
  \end{tabular}

\end{document}
2

For example:

\documentclass{article}

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



\begin{document}

\begin{table}[h]
  \centering

\resizebox{0.8\textwidth}{!}{\begin{minipage}{\textwidth}
       \caption{\textbf{State Table for Example 1}}
  \label{table: state table1}


\hfil % This is new 
\begin{tabular}{cc|cc}
x & y & X & Y \\ 
\hline
   $\bar{0}$  & $\bar{0}$ & 1 &1 \\ 
   \rowcolor{blue} 0  & 1 & 0 &1 \\ 
   $\bar{1}$  & $\bar{1}$ & 0 & 0 \\ 
   \rowcolor{blue!30} 1  & 0 & 1 &0 \\ 
  \end{tabular}
      \end{minipage}}

\end{table}

\end{document}

The second of blue rows is lighter, to show, how to obtain it.

enter image description here