I'd like to highlight certain cells of my table. In particular, I'd like to set the border of these sells colored and thick. These cells should also have a background color.
Here's a minimal example of my table:
\documentclass{article}
\usepackage{array,colortbl,xcolor}
\begin{document}
\begin{tabular}{p{1.4cm}p{2.55cm}p{2.55cm}p{2.55cm}p{2.55cm}}
\hline
\multicolumn{1}{c}{} & \multicolumn{2}{c}{\textbf{Football}} & \multicolumn{2}{c}{\textbf{Basketball}} \\\hline
\multicolumn{1}{c}{} & \multicolumn{1}{c}{\textbf{1. League}} & \multicolumn{1}{c}{\textbf{2. League}} & \multicolumn{1}{c}{\textbf{1. League}} & \multicolumn{1}{c}{\textbf{2. League}} \\ \hline
\textbf{Average} & 10000000000 & \cellcolor{lightgray}20000000000 & 30000000000 & 40000000000\\ \hline
\textbf{Total} & 50000000000 & 60000000000 & 70000000000 & \cellcolor{lightgray}80000000000\\ \hline
\end{tabular}
\end{document}
I tried to set the border of specific cells using a combination of multicolumn and hhline but failed miserably 🙁 (One of the problems was that the cell background partially covers the border).
I also tried tikz but failed to paint exactly on the cell's border, especially when a linebreak occurs.
Here's how it should look optimally:
Can someone please help me to get this working?
Best Answer
I have prevented the cell from becoming wider due to the border, but allowed it to grow vertically. If that isn't desired a bit more negative spacing is needed.
rather than use
colortbl
it is easier to grab the cell contents in a box (since you are doing that anyway forp
columns) and using\fcolorbox
.