Latex tables

I wrote my Master’s Thesis in Latex since it allows me to focus on the content of the paper rather than on how it looks. Having the content it is possible to change the output style by changing the Latex code. Recently, I faced a problem of creating tables with background color. After some time Googleing I found some information. On its basis a created table I wanted (look below).

table Latex tables

The Latex code for the document containing page with such a output looks as follows:




\section{Table test}



\multicolumn{1}{| >{\columncolor[rgb]{0.8,0.8,0.8}}r|}{Id} & 
UC01 \\


\multicolumn{1}{| >{\columncolor[rgb]{0.8,0.8,0.8}}r|}{Title} & 
Delivering a list of LOs\\


\multicolumn{1}{| >{\columncolor[rgb]{0.8,0.8,0.8}}r|}{Description} & 
Providing a list of existing Learning Objects created from 
the informal knowledge stored in the repository.\\


\multicolumn{1}{| >{\columncolor[rgb]{0.8,0.8,0.8}}r|}{Actors} & 
A02, A03 \\


\multicolumn{1}{| >{\columncolor[rgb]{0.8,0.8,0.8}}r|}{Initial occurence} 
& Claim for list of LOs.\\


\multicolumn{1}{| >{\columncolor[rgb]{0.8,0.8,0.8}}r|}{
Exceptional occurence}
 &  Unsuccesful connection to the repository\\


\multicolumn{1}{| >{\columncolor[rgb]{0.8,0.8,0.8}}r|}{Related use cases} & 
UC07, UC17\\




So whenever You use tables with coloured cells:

  • inlcude colortbl package
  • use \multicolumn{1}{| >{\columncolor[rgb]{0.8,0.8,0.8}}r|}{Id}, where in first bracket you define the number of columns this applies to, in the second the color and in the last the content of the cell(s)

9 Responses to “Latex tables”

  • Thnak you very much! :D I was also working on use cases hahaha

  • Hello,
    nice tips, thanks. Would you know how we can change the color of the borders of a table in LaTeX? Have you tried this before?


  • Unfortunately I haven’t tried that. I hope Google will me more of the help :)

  • hi,

    thax for posting. exactly what i was looking for.

    can you add an explanation how the rgb code works? must be a value between 0 and 1. i only found either hex or decimal numbers as reverences to the color. how do i get the right number for a specific color, if i got the hex number or decimal number?


  • Thanks a lot!!!!

  • you can also use \columncolor{red} for example. For some reason the color model of RGB does not work (enabling values of 0-255) and it also breaks the printing of cells in a multirow cell. In other words yet more latex hack and pain. I could never have believed something so painfully necessary as colored columnds and rows could be implemented so painfully. In addition, the comments about latex separating content from presentation are ludicrous : its one of the most presentation orientated content management forums I have ever seen.

  • Zeid:
    Here is how to have colored \hline .
    Hope this helps,


    \arrayrulecolor{green} %always at the beginning of a table row
    \midrule[2pt] %see booktabs.pdf

  • When I use \cellcolor[gray]{0.9} to color a cell (in a table) and convert to .pdf, the left and top borders of the cell, which were black get erased. How could I fix this problem. Thanks!

  • Thanks to you all!

    I was looking for the colored \hline and I got just what I wanted here.



Leave a Reply