I am writing a report using latex on overleaf. After a paragraph I want to add a table:

    \caption{Two Object Detection Types}
        % \rowcolor[HTML]{C0C0C0}
        % \multicolumn{2}{c}{\cellcolor[HTML]{C0C0C0}\textbf{Types of Object Detection Detectors}} \\ \hline
        % \rowcolor[HTML]{EFEFEF} 
        \multicolumn{1}{|c|}{\cellcolor[HTML]{EFEFEF}{\ul \textbf{One Stage Detectors}}} & \multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}{\ul \textbf{Two Stage Detectors}}} \\ \hline
        \multicolumn{1}{|c|}{Single Shot Detector} & \multicolumn{1}{|c|}{RCNN family} \\ \hline
        \multicolumn{1}{|c|}{YOLO v1-v4} & \multicolumn{1}{|c|}{CenterNet} \\ \hline
        \multicolumn{1}{|c|}{Scaled YOLO v4} & \multicolumn{1}{|c|}{EfficientDet} \\ \hline

I have used this website to generate the code.

But I have a paragraph before this table and there are whitespaces in between as shown in the figure below. I would like to know how do I remove them whitespace. enter image description here

Not only that but I am also getting the error: Undefined Control Sequence for the second and third multicolumn lines in the above code. Can someone explain to me why this is and how it can be resolved?


Edit 1:

enter image description here

  • In order to help you you should show an emc. Please read carefully this page: tex.meta.stackexchange.com/q/228/231952. The "Undefined Control Sequence" error will disappear if you you load all the necessary packages: multicol, soul, xcolor, colortbl
    – Ivan
    Mar 25, 2021 at 17:19
  • Additionally \begin{table}[] should probably be \begin{table}[htbp] just in case. BTW: from where do to have that using \ul here is a good idea?
    – daleif
    Mar 25, 2021 at 17:26
  • emc? Also I have included the packages as mentioned on the website from which I converted the excel table to latex: % \usepackage[table,xcdraw]{xcolor} % If you use beamer only pass "xcolor=table" option, i.e. \documentclass[xcolor=table]{beamer} % \usepackage[normalem]{ulem} % \useunder{\uline}{\ul}{}
    – duddal
    Mar 25, 2021 at 17:32
  • I have solved it. I forgot to add [H] after \begin{table}. Apologies. Can I post this as an answer?
    – duddal
    Mar 25, 2021 at 17:33
  • you would get much simpler code if you simply hand wrote the table, that site comes up quite offten always with massively over-complicated code with redundant \multicolumn everywhere Mar 25, 2021 at 21:06

1 Answer 1


There is nothing very wrong with the table except the command \ul that must be defined or be provided by a package, that must be loaded.

For underline the first bold faced row (an overkill) you might use the package soul and its command \ul. The correct use for a bold underline is \textbf{\ul{One Stage Detectors}}.

You don't need all the complicated \multicolumn{1}{|c|}{.. for such a simple table. They are artifacts from the table generator.

What is needed is to add vertical space in the first row to accommodate the underline. Done with mutirow, making the first row two rows high.

And do not use [H]. Use [h!] instead.

Next time please provide the complete MWE with its preamble.



\usepackage{kantlipsum} % dummy text    
\usepackage{soul} % underlines
\usepackage{multirow}   % multiple rows

1.  \kant[1]

        \caption{Two Object Detection Types}    
        \cellcolor{gray!10}  &\cellcolor{gray!10}\\
        \multirow{-2}{*}{\cellcolor{gray!10}\textbf{\ul{One Stage Detectors}}}& 
        \multirow{-2}{*}{\cellcolor{gray!10}\textbf{\ul{Two Stage Detectors}}}\\
        Single Shot Detector    & mRCNN family  \\ \hline
        YOLO v1-v4              & CenterNet     \\ \hline
        Scaled YOLO v4          & EfficientDet  \\ \hline

2.  \kant[2]    
  • Okay, I understand now thank you. But the Column headings "One stage Detectors" and "Two Stage Detectors" are not centered as can be seen in Edit 1 of the question. And I have included all the necessary packages in the preamble.
    – duddal
    Mar 25, 2021 at 17:52
  • @duddal Please see the updated answer. Mar 25, 2021 at 19:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .