1

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

  • 2
    Please reveal how \ul is defined. – Mico Apr 14 at 12:09
  • 1
    Off-topic: Don't mix-and-mismatch visual metaphores: If you're going to highlight the header row by giving it a color, there's no need for \toprule and \midrule to provide an additional visual highlight, or offset. – Mico Apr 14 at 12:24
  • @Mico, thank you - you are absolutely right, it makes no sense. However, the \ul part I am quite unsure of how that is defined. I used the Tablegenerator from tablesgenerator.com – Philip Apr 14 at 12:52
  • tablesgenerator.com tells you exactly what is needed and how \ul is defined: % Please add the following required packages to your document preamble: % \usepackage[normalem]{ulem} % \useunder{\uline}{\ul}{} – leandriis Apr 14 at 12:53
  • Thank you Leandriis, but I have already done that. :) – Philip Apr 14 at 12:56
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.