0

I have this code to render a table:

\chapter{Resultados}

\begin{table*}[h]
\centering
\caption{Resultados Para o Conjunto de 
Dados Image}
\begin{tabular}{|c|c|c|c|c|c|c|} 
      \hline
      Índice & Algoritmo Generativo & \multicolumn{5}{|c|}{Função Consenso} \\ \hline
      - & K-Means & Agglomerative & CSPA & IVC & LWEA & LGWP \\ \hline
      ARI & \makecell{ari-km-5 \\ ari-km-10 \\ ari-km-15 \\ ari-km-20 \\ ari-km-30} & \makecell{ari-agm-km-5 \\ ari-agm-km-10 \\ ari-agm-km-15 \\ ari-agm-km-20 \\ ari-agm-km-30} & \makecell{ari-csp-km-5 \\ ari-csp-km-10 \\ ari-csp-km-15 \\ ari-csp-km-20 \\ ari-csp-km-30} & \makecell{ari-ivc-km-5 \\ ari-ivc-km-10 \\ ari-ivc-km-15 \\ ari-ivc-km-20 \\ ari-ivc-km-30} & \makecell{ ari-lwe-km-5 \\ ari-lwe-km-10 \\ ari-lwe-km-15 \\ ari-lwe-km-20 \\ ari-lwe-km-30} & \makecell{ari-lwg-km-5 \\ ari-lwg-km-10 \\ ari-lwg-km-15 \\ ari-lwg-km-20 \\ ari-lwg-km-30} \\ \hline
\end{tabular}
\end{table*}

However, the table not only isn't being centered, it is rendering too much to the right and the content is being cut off:

screenprint depicting the table rendering

How do I fix this? I'm also getting a warning Overfull \hbox (114pt too wide) in paragraph at lines 7-13

2
  • You can take a look at the various options presented in the answer to My table doesn't fit; what are my options?
    – leandriis
    Jul 22, 2020 at 16:58
  • Please make your code compilable by adding the documentclass as well as the relevant packages. Do you use the geometry package? If so, please also include the corresponding settings. Do you use a twocolumn documentclass and did you change the font size?
    – leandriis
    Jul 22, 2020 at 18:02

2 Answers 2

1

You not provide the key information: the length of the \textwidth. Not knowing it, we can only guess about it. For example, if page borders width are 25mm, than by using \makecell also in header of the second column then we can put your table on the page as you would like it to be:

\documentclass{book}
\usepackage[margin=25mm]{geometry}
\usepackage{makecell, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\chapter{Resultados}

\begin{table}[ht]
\centering
\caption{Resultados Para o Conjunto de Dados Image}
%\small
\setlength\tabcolsep{3pt}
\begin{tabularx}{\linewidth}{|c|c|*{5}{C|}}
      \hline
Índice & \makecell{Algoritmo\\ Generativo} 
            & \multicolumn{5}{c|}{Função Consenso} \\ \hline
   --  & K-Means & Agglomerative & CSPA & IVC & LWEA & LGWP \\ \hline
  ARI & \makecell{ari-km-5 \\ ari-km-10 \\ ari-km-15 \\ ari-km-20 \\ ari-km-30} 
    & \makecell{ari-agm-km-5 \\ ari-agm-km-10 \\ ari-agm-km-15 \\ ari-agm-km-20 \\ ari-agm-km-30} 
        & \makecell{ari-csp-km-5 \\ ari-csp-km-10 \\ ari-csp-km-15 \\ ari-csp-km-20 \\ ari-csp-km-30} 
            & \makecell{ari-ivc-km-5 \\ ari-ivc-km-10 \\ ari-ivc-km-15 \\ ari-ivc-km-20 \\ ari-ivc-km-30} 
                & \makecell{ ari-lwe-km-5 \\ ari-lwe-km-10 \\ ari-lwe-km-15 \\ ari-lwe-km-20 \\ ari-lwe-km-30} 
                    & \makecell{ari-lwg-km-5 \\ ari-lwg-km-10 \\ ari-lwg-km-15 \\ ari-lwg-km-20 \\ ari-lwg-km-30} \\ 
    \hline
\end{tabularx}
\end{table}
\end{document}

enter image description here

(red lines indicate text borders)

0

The problem, not too surprisingly, is that the table is too wide (which is why you got the Overfull \hbox warning).

The options are to find a way to make the table narrower (which it doesn't look like there's much hope for besides perhaps making the text smaller) or typeset the table vertically instead of horizontally using sidewaystable

You must log in to answer this question.

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