0

I am writing a research paper in where I have to write a table in latex. My Code in latex is as follows:

 \begin{table}[!t]
\noindent\makebox[\textwidth]{
\begin{tabular}{|r|r|r|r}
    \hline
    cell1 & cell2 & cell3 \\ 
    \hline
    cell4 & cell5 & cell6 \\ 
    \hline
    cell7 & cell8 & cell9 \\ 
    \hline
\end{tabular}  
} 
\captionsetup{justification=centering}
\caption{Some caption}
\end{table}

But the table is now colliding with section content as described in the screenshot. How can I get rid of this?

enter image description here

Also, I want to center my caption of table which does not work here. How can I do this ?

5
  • 2
    Remove the makebox command. To horizontally center the table within its column of text, you can use \centering instead.
    – leandriis
    Jan 25 '21 at 6:23
  • 1
    Not directly related but eplace positioning specifier [!t] with [htb].
    – Zarko
    Jan 25 '21 at 7:20
  • The \noindent\makebox[\textwidth]{ is completely wrong here it is adding a word space (from the newline after {) to the left of the table and then centering the tabular in the width of the page when your image suggestes that you have a two column docuemnt and this is a single column float. Just remove the whole line and use \centering to centre the tabular within the column Jan 25 '21 at 8:57
  • I want to place the table in center of table. If I remove \noindent\makebox then the table does not reside in center of table. Jan 25 '21 at 9:13
  • That is why they ask you to use \centering. The proper way to center a tabular is the following \begin{table}[htp] \centering <tabular and stuff> \end{table}
    – daleif
    Jan 25 '21 at 13:11

Your Answer

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

Browse other questions tagged or ask your own question.