# colored table with some bold colored lines

How can I have a table with the following specifications:

1. The top and bottom lines are bold and all other horizontal and vertical lines are normal.
2. The whole table lines (including top and bottom lines) are in red color.
3. The whole table have a yellow background.

Here's a possibility using the tabu package:

\documentclass{article}
\usepackage{tabu}
\usepackage[table]{xcolor}

\begin{document}

\noindent\begin{tabu}{| l | l | l |}
\taburowcolors1{yellow!90!black..yellow!90!black}
\taburulecolor{red}
\tabucline[1pt]-
column1a & column2a & column3a \\
\tabucline-
column1b & column2b & column3b \\
\tabucline-
column1c & column2c & column3c \\
\tabucline-
column1d & column2d & column3d \\
\tabucline[1pt]-
\end{tabu}

\end{document}


As a personal suggestion, vertical rules are not necessary and your table will look better without them.

\documentclass{article}

\usepackage{colortbl}

\arrayrulecolor{red}
\def\widehline{%
\noalign{\global\dimen1 \arrayrulewidth
\global\arrayrulewidth8\arrayrulewidth}%
\hline
\noalign{\global\arrayrulewidth\dimen1 }}

\begin{document}

\colorbox{yellow}{%
\begin{tabular}{|l|l|}
\widehline
1&2\\
\hline
aa&bb\\
aaa&bbb\\
\hline
3&4\\
\widehline
\end{tabular}}

\end{document}

• Possibly \fboxsep=0pt? Dec 17, 2012 at 0:09
• @egreg, possibly, or possibly the OP likes having a border with the yellow being bigger than the table. As @egreg hints if you want the yellow background tight to the table, locally set \fboxsep to zero. Dec 17, 2012 at 0:13
• How can I have vertically centered cells?
– smh
Dec 17, 2012 at 10:37
• Well that is a completely different question. Perhaps m column type from the array package. Dec 17, 2012 at 10:54

Well, in this simple case tabularray can compete in code efficiency with NiceTabular :-)

\documentclass[border=3.141592]{standalone}
\usepackage{xcolor}
\usepackage{tabularray}

\begin{document}
\begin{tblr}{cells ={c, yellow!30},
hlines={red}, hline{1,5}={1pt},
vlines={red},
}
% body
un     & deux     & trois  & quatre \\
cinq   & six      & sept   & huit \\
neuf   & dix      & onze   & douze \\
treize & quatorze & quinze & seize \\
\end{tblr}
\end{document}


after one compilation the result is almost the same:

Edit: With version 2021M (2021-08-01) the table preaqble can be simplified to:

\begin{tblr}{cells ={c, yellow!30},
hlines={red}, hline{1,Z}={1pt}, % <--- observe Z, it indicate the last line in table
vlines={red},
}

• Unfortunately, in Adobe Reader, at some levels of zoom, some vertical rules disappear. Aug 2, 2021 at 16:56
• @F.Pantigny, this may be a case, so as I stated in my comment below your answer, NiceTabular is the best solution :-) Aug 2, 2021 at 18:13

With {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{nicematrix,tikz}

\begin{document}
\begin{NiceTabular}{cccc}[rules/color=red,hvlines]
\CodeBefore
\arraycolor{yellow}
\Body
un     & deux     & trois  & quatre \\
cinq   & six      & sept   & huit \\
neuf   & dix      & onze   & douze \\
treize & quatorze & quinze & seize \\
\CodeAfter
\tikz \draw [thick,red] (1-|1) -- (1-|last) (last-|1) -- (last-|last) ;
\end{NiceTabular}
\end{document}


You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

• Simple in the best solution! (+1) Aug 2, 2021 at 11:56