The m
columns should have some length associated, so you should use some like m{2cm}
or use another type of column.
The l
, c
and r
columns adjust automatically to the content, so it is all you need. You can use also @{}
before and after the column to avoid the default padding defined by \tabcolsep.
On the other hand, note that by default the image will be aligned at bottom with "cm" of the left cell (is placed just as character), but you can center with the help of adjustbox
package as showed in the MWE, and then will fit perfectly the biggest image.
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{array}
\begin{document}
\tabcolsep10pt
\begin{tabular}{|l|c|@{}c@{}|}\hline
& Size & Figure \\\hline
One & 1cm*1cm & \includegraphics[valign=c,width=1cm]{example-image-1x1.jpg} \\\hline
Two & 2cm*2cm & \includegraphics[valign=c,width=2cm]{example-image-1x1.jpg} \\\hline
\end{tabular}
\end{document}
If you want some padding around the image, a trick without additional package is put the image in a \fbox{}
but previously set \fboxrule to 0pt and \fboxsep to more that 0pt, obviously. (e.g. \fboxrule0pt\fboxsep1em\fbox{}. That allow even different paddings in the same column. For instance:
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{array}
\begin{document}
\tabcolsep10pt\fboxrule0pt\fboxsep\tabcolsep
\begin{tabular}{|l|c|@{}c@{}|}\hline
& Size & Figure \\\hline
One & 1cm*1cm & \fbox{\includegraphics[valign=c,width=1cm]{example-image-1x1.jpg}} \\\hline
Two & 2cm*2cm & \fboxsep2pt\fbox{\includegraphics[valign=c,width=2cm]{example-image-1x1.jpg}} \\\hline
\end{tabular}
\end{document}
m
type columns need a width argument in order to work properly. Do you want allo columns to be equally wide?