2

I'd like to color the background of a single line of text in a some cells of a table. I need to obtain a result like this:

enter image description here

I have tried with \columncolor and \cellcolor but they don't leave me a white border. Here is my sample code:

\begin{tabular}{|l|l|l|}
    \hline
    ID: \cellcolor{gray}{0.9} & blabla &  blabla \\ \hline
    Title: & blabla & blabla \\ \hline
    State: & blabla & blabla\\ \hline
    Description: & blabla & blabla \\ \hline
    Type: & blabla  & blabla \\ \hline
    Priority: & blabla & blabla \\ \hline
\end{tabular}
3

enter image description here

\documentclass[12pt]{article} 

\usepackage{color}

\newcommand\celltitle[1]{{\fboxrule=0pt\fbox{\colorbox[gray]{0.9}{\makebox[3cm]{#1}}}}}

\begin{document}

\begin{tabular}{|l|l|l|}
    \hline
    \celltitle{ID:}  & blabla &  blabla \\ \hline
    \celltitle{Title:} & blabla & blabla \\ \hline
    \celltitle{State:} & blabla & blabla\\ \hline
    \celltitle{Description:} & blabla & blabla \\ \hline
    \celltitle{Type:} & blabla  & blabla \\ \hline
    \celltitle{Priority:} & blabla & blabla \\ \hline
\end{tabular}

\end{document}
0

Here is a simple adjustment of your code. It requires the packages color and colortbl. The key point is to define the colour using a \definecolor command.

\documentclass[12pt]{article} 

\usepackage{color,colortbl} 
\definecolor{Gray}{gray}{0.9}

\begin{document}

\begin{tabular}{|l|l|l|}
    \hline
    \cellcolor{Gray}ID:  & blabla &  blabla \\ \hline
    \cellcolor{Gray}Title: & blabla & blabla \\ \hline
    \cellcolor{Gray}State: & blabla & blabla\\ \hline
    \cellcolor{Gray}Description: & blabla & blabla \\ \hline
    \cellcolor{Gray}Type: & blabla  & blabla \\ \hline
    \cellcolor{Gray}Priority: & blabla & blabla \\ \hline
\end{tabular}

\end{document}
  • It doesn't give me the white border around the coulored text. – eang Dec 7 '12 at 10:35

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.