2

I just finished up my table, but noticed that the coloring goes a bit too much "outside" of the table, to the left? Is there any fix for this?

\begin{table}[]
\centering
\begin{tabular}{@{}llllll@{}}
\toprule
\rowcolor[HTML]{003085} 
{\color[HTML]{FFFFFF} \textbf{Variables}} & {\color[HTML]{FFFFFF} 
\textbf{Mean}} & {\color[HTML]{FFFFFF} \textbf{Median}} & \multicolumn{1}{c} 
{\cellcolor[HTML]{003085}{\color[HTML]{FFFFFF} \textbf{\begin{tabular}[c] 
{@{}c@{}}Harm. \\ mean\end{tabular}}}} & {\color[HTML]{FFFFFF} 
\textbf{\begin{tabular}[c]{@{}l@{}}Std. \\ dev.\end{tabular}}} & 
\multicolumn{1}{c}{\cellcolor[HTML]{003085}{\color[HTML]{FFFFFF} 
\textbf{\begin{tabular}[c]{@{}c@{}}IQ \\ range\end{tabular}}}} \\ \midrule
Revenue & {\ul } & {\ul } & {\ul } & {\ul } & {\ul } \\
EBITDA & {\ul } & {\ul } & {\ul } & {\ul } & {\ul } \\
EV/EBIT N12M &  &  &  &  &  \\
EV/EBIT N24M &  &  &  &  &  \\ \bottomrule
\end{tabular}
\end{table}

Which gives me this:

enter image description here

Philip
  • 421

2 Answers2

3

The problem comes from your removing the padding at both ends of the table. Here is a work-around:

\documentclass{report}
\usepackage[utf8]{inputenc} 
\usepackage[table]{xcolor}
\usepackage{booktabs} \def\ul{}
\usepackage{makecell}
\renewcommand{\cellgape}{\Gape[2pt]}
\renewcommand{\theadfont}{\normalsize\bfseries\color[HTML]{FFFFFF}}
\renewcommand{\theadset}{\cellcolor[HTML]{003085}}
\newcolumntype{C}{>{\cellcolor[HTML]{003085}\color[HTML]{FFFFFF}\bfseries}c}
\newcolumntype{L}{>{\columncolor[HTML]{003085}[0pt][\tabcolsep]\color[HTML]{FFFFFF}\bfseries}l}

\begin{document}

\begin{table}[!htb]
\centering
\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}
\begin{tabular}{@{}llllll@{}}
\toprule
 \multicolumn{1}{@{}L}{Variables} & \multicolumn{1}{C}{Mean} & \multicolumn{1}{C}{Median} & \multicolumn{1}{C}
{\makecell{Harm. \\ mean}} & \multicolumn{1}{C}{\makecell{Std. \\ dev.}} &
\multicolumn{1}{C}{\makecell{IQ \\ range}} \\ \midrule\addlinespace
Revenue & {\ul } & {\ul } & {\ul } & {\ul } & {\ul } \\
EBITDA & {\ul } & {\ul } & {\ul } & {\ul } & {\ul } \\
EV/EBIT N12M & & & & & \\
EV/EBIT N24M & & & & & \\ \addlinespace\bottomrule
\end{tabular}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350
0

With {NiceTabular} of nicematrix and its tools, you will have directly the expected output (and you won't see the thin white lines you see in some PDF viewers such as SumatraPDF).

 \documentclass{article}
\usepackage{nicematrix}
\usepackage{booktabs}

\begin{document}

\begin{table}[] \centering \newcommand{\headfont}{\color{white}\bfseries} \begin{NiceTabular}{@{}llllll@{}} \CodeBefore \rowcolor[HTML]{003085}{1} \Body \toprule \headfont Variables & \headfont Mean & \headfont Median & \Block{}<\headfont>{Harm. \ mean} & \Block{}<\headfont>{Std. \ dev.} & \Block{}<\headfont>{IQ \ range} \ \midrule Revenue \ EBITDA \ EV/EBIT N12M \ EV/EBIT N24M \ \bottomrule \end{NiceTabular} \end{table}

\end{document}

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

Output of the above code

F. Pantigny
  • 40,250