TeX - LaTeX Asked by Allan Juan on August 26, 2021
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:
How do I fix this? I’m also getting a warning Overfull hbox (114pt too wide) in paragraph at lines 7-13
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}{>{centeringarraybackslash}X}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
begin{document}
chapter{Resultados}
begin{table}[ht]
centering
caption{Resultados Para o Conjunto de Dados Image}
%small
setlengthtabcolsep{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}
(red lines indicate text borders)
Correct answer by Zarko on August 26, 2021
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
Answered by Don Hosek on August 26, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP