2

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?

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

| improve this answer | |
  • I do it, and got this error: ! LaTeX Error: Option clash for package xcolor. – Rebecca Jun 16 '14 at 3:59
  • @Maryam This error was on my example or some of its inclusion into your file? An error suggests that an option (probably table) is used in some other place. – Przemysław Scherwentke Jun 16 '14 at 4:03
  • @ Przemysław I copied your codes, and added that package, then got the error – Rebecca Jun 16 '14 at 4:05
  • @Maryam And what packages have you got in your preamble? – Przemysław Scherwentke Jun 16 '14 at 4:08
  • Thanks, I found the problem. That's here: tex.stackexchange.com/questions/51488/… – Rebecca Jun 16 '14 at 4:09
2
\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}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.