# resize font and images in a table

I have a big font size document where i want to add 4*9 table containing images. I used resizebox to automatically reduce the font size and the images to fit the cell, and to force the table to be wide as the textwidth and with height a bit less than the page height.

The problem is that the text looks weird after the resizing as the resizing vertically stretches the text.

Is there any solution?

\documentclass[48pt,oneside,a4paper,extrafontsizes]{memoir}
\usepackage[demo]{graphicx}
\begin{document}
\begin{table*}[h!]\centering
\resizebox{\textwidth}{0.4\textheight}{
\begin{tabular}{|c|c|c|c|}
\hline\noalign{}
Chair&
air&
international&
Ali
\\\hline
latex &latex &latex &latex\\\hline
latex &latex &latex &latex\\\hline
latex &latex &latex &latex\\\hline
\includegraphics[width=\linewidth,height=0.2\textwidth]{demo}
&\includegraphics[width=\linewidth,height=0.2\textwidth]{demo}
&\includegraphics[width=\linewidth,height=0.2\textwidth]{demo}
&\includegraphics[width=\linewidth,height=0.2\textwidth]{demo}\\\hline
Chair&
air&
international&
Ali
\\\hline
Chair&
air&
international&
Ali
\\\hline
latex &latex &latex &latex\\\hline
latex &latex &latex &latex\\\hline
\end{tabular}}
\end{table*}

\end{document}

• Crosspost – Johannes_B Aug 2 '16 at 14:53
• To preserve the font's normal aspect ratio, change {0.4\textheight} to {!}. – Steven B. Segletes Aug 2 '16 at 15:00
• Just add \renewcommand\arraystretch{3} (3 is adjustable) prior to the \resizebox command. – Steven B. Segletes Aug 2 '16 at 15:17
• you can not use h with table* so \begin{table*}[h!] should be \begin{table*} – David Carlisle Aug 2 '16 at 16:02
• do not specify both height and width on the image or it will distort width=\linewidth,height=0.2\textwidth just specify one or the other (or add keepaspectratio) – David Carlisle Aug 2 '16 at 16:04

I tried expanding on the comments (I thank @StevenB.Segletes and @DavidCarlisle) and:

1. removed the 0.4\textheight to keep the font aspect ratio
2. removed the [h!] which is not to be used with table*
3. removed the height of the image to keep the aspect ratio (you could choose the other one)

Then I also:

1. used the booktabs package for fancy lines
2. used the array package (mainly to suppress the extra external separations with @{})
3. removed all vertical separators
4. refactored the horizontal separators.

I am now ready to propose two solutions. The "natural" one (which I think looks the best)

\documentclass[48pt,oneside,a4paper,extrafontsizes]{memoir}
\usepackage[demo]{graphicx}
\usepackage{booktabs,array}
\begin{document}
\begin{table*}\centering

\resizebox{\textwidth}{!}{
\begin{tabular}{@{}cccc@{}}
\toprule                    Chair&
air&
international&
Ali
\\\midrule
latex &latex &latex &latex\\
latex &latex &latex &latex\\
latex &latex &latex &latex\\
\includegraphics[width=\linewidth]{demo}
&\includegraphics[width=\linewidth]{demo}
&\includegraphics[width=\linewidth]{demo}
&\includegraphics[width=\linewidth]{demo}\\
Chair&
air&
international&
Ali
\\
Chair&
air&
international&
Ali
\\
latex &latex &latex &latex\\
latex &latex &latex &latex\\\bottomrule
\end{tabular}}
\end{table*}

\end{document}


This table looks already ok for me, and way less dense than before. Should you feel it too dense still, I can propose you one with the array stretched, the line:

 \renewcommand{\arraystretch}{1.4}


Basically inserts vertical spacing between the lines. Please feel free to readjust it to obtain what you want. I still prefer the first example

\documentclass[48pt,oneside,a4paper,extrafontsizes]{memoir}
\usepackage[demo]{graphicx}
\usepackage{booktabs,array}
\begin{document}
\begin{table*}\centering
\renewcommand{\arraystretch}{1.4}
\resizebox{\textwidth}{!}{
\begin{tabular}{@{}cccc@{}}
\toprule                    Chair&
air&
international&
Ali
\\\midrule
latex &latex &latex &latex\\
latex &latex &latex &latex\\
latex &latex &latex &latex\\
\includegraphics[width=\linewidth]{demo}
&\includegraphics[width=\linewidth]{demo}
&\includegraphics[width=\linewidth]{demo}
&\includegraphics[width=\linewidth]{demo}\\
Chair&
air&
international&
Ali
\\
Chair&
air&
international&
Ali
\\
latex &latex &latex &latex\\
latex &latex &latex &latex\\\bottomrule
\end{tabular}}
\end{table*}

\end{document}