I'm trying to create a table with equal width for all columns however if some word needs more space the column width will change. Is it possible to autofit "biiggwwoorrdd" reducing the font size?
Thank you
\centering
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{tabularx}{\textwidth}{ |*{7}{Y|} }
\cline{1-7}
\multicolumn{1}{|c|}{Ano/Mes}
& \multicolumn{3}{c|}{Fantastical aardvarks}
& \multicolumn{3}{c|}{Spelunking elephants}\\
\hline
Foo bar & A & B & C & A & B & C\\
\hline
5 & 87 & 5 & 2 & 82 & 18 & 48\\
6 & 5 & 43 & 4 & 7 & 47 & 4\\
7 & 7 & 18 & 63 & 2 & 9 & 99\\
\hline
2º
& \multicolumn{1}{Y|}{\cellcolor[HTML]{EFEFEF}long test small words}
& \multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}biiggwwoorrdd}
& \multicolumn{4}{c|}{\cellcolor[HTML]{EFEFEF}teste?} \\
\hline
\end{tabularx}
Best Answer
You could use the
\resizebox*
directive, provided by thegraphicx
package, to force the word to be as wide as\hsize
-- the default width of anX
column.I can't help but remark that the result of this exercise looks awful. IF I ever came across a table with similarly terrible font size variations, I would probably start to either laugh, or more likely, cry. For sure, I'd simply stop reading the paper...