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-3347914

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


documentclass{article}

usepackage[english]{babel}
usepackage{colortbl}

begin{document}

section{Table test}

begin{tabular}{|l|p{8cm}|}

hline

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

hline

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

hline

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.

hline

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

hline

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

hline

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

hline

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

hline

end{tabular}

end{document}

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)
Previous Post
Next Post