# Latex multiple tables with different colors and header alignment

I am trying to have different tables in my report. Some of them I need to have the headers one color (black with white text) and different rowcolor (Table 1).

While others I need only the headers to be coloured and that to be centered.

I have added my current code to overleaf and adding an image to what I am trying to achieve.

Could someone help me with this?

Here you are. The cells contents were already centred, so there was nothing to do. Note hyperref should be loaded as the last package, with very few exceptions (cleveref is such an exception).

\documentclass{article}
\usepackage[utf8]{inputenc}

%** latex setup**%
\usepackage[table]{xcolor}
\rowcolors{2}{gray!15}{white}

\usepackage{booktabs}
\usepackage{quotchap}
\usepackage[nottoc,notindex,notlot,notlof]{tocbibind}
\usepackage{multicol}
\usepackage{minitoc}
\usepackage{multirow}
\usepackage{wrapfig}

\definecolor{Gray}{gray}{0.85}
\definecolor{LightCyan}{rgb}{0.88,1,1}

\usepackage[font=small,labelfont=bf]{caption}
\usepackage{fancyhdr}
%\usepackage{times}
\usepackage{tikz}            % For drawing stuff
\usepackage{glossaries}      % For abbrevations
\usepackage{acronym}
\usepackage[most]{tcolorbox}

%** new commands**%
\textcolor{white}{\textbf{#1}}}
\renewcommand{\arraystretch}{1.5}
\renewcommand*{\sectfont}{\bfseries}

\title{Table Formating}
\begin{document}

\maketitle

\section{Table 1}
\begin{table}[!h]
\centering
\sffamily
\caption{Table variant 1} \label{tb:1}
\begin{tabular}{|cccc|}
\rowcolor{black!75}
1 & Top Solder Mask &  & Solder Resist \\
\hline
2 & Top Layer & 1.4 mil &  \\
\end{tabular}
\end{table}

\section{Table Formating}

\begin{table}[!h]
\centering
\sffamily
\rowcolors{3}{}{}
\caption{Table 2} \label{tb:2}
\begin{tabular}{c|c}
\rowcolor{black!75}
\hline
Sensor & ... \\
\hline
Pressure sensor &  \\
\hline
Name ... & ... \\
\hline
Resolution & ...  \\
\hline
Accelometer and Magnometer &  \\

\end{tabular}
\end{table}

\end{document}


• The code doesn't produce the table you showed as table 2. With your code, table 2 still has striped rows. It will work if you insert the following after \begin{table}[!h]: \rowcolors{1}{white}{white} – jaspast Mar 9 '19 at 21:37
• @jaspast: Sorry, it was a clipboard accident. I copied the O.p.s code instead of mine. It's fixed (\rowcolors... just before \begin{tabular}. Thanks for pointing it! – Bernard Mar 9 '19 at 21:39
• Hi, about centering. I would like the TEMPERATURE SENSOR to take the whole row and be centered. That's what I meant. Is this possible ? – user3874252 Mar 9 '19 at 21:41
• Yes, it is. Please see my updated code. – Bernard Mar 9 '19 at 22:01
• Thank you very much @Bernard! – user3874252 Mar 9 '19 at 23:20