4

I have the following table:

\begin{table}
\centering
\begin{tabular}{ | c | c | }
\hline
\includegraphics[scale=.5]{image1.png} & \includegraphics[scale=.5]{image2.png} \\
\hline
\includegraphics[scale=.5]{image3.png} & \includegraphics[scale=.5]{image4.png} \\
\hline
\end{tabular}
\end{table}

The problem is that the images seem to be on top of cell borders and hide them. Can I add some padding to prevent them from being over the borders?

3

Include the image in a \fbox{}and set the space around it. But use @{} in tabular columns. See the MWE:

\documentclass{article}
\usepackage{graphicx}

% Command just to avoid too much typing in tabular 
\newcommand{\imgtest}{
  \framebox{
   \includegraphics[width=.4\textwidth]{img.jpg}}}

\begin{document}

\setlength{\fboxsep}{20pt}
\setlength{\fboxrule}{0pt}

\begin{table}[ht]
\begin{tabular}{|@{}c@{}|@{}c@{}|}
\hline
\imgtest & \imgtest \\
\hline
\imgtest & \imgtest \\
\hline
\end{tabular}
\end{table}

\setlength{\fboxsep}{10pt}
\setlength{\fboxrule}{2pt}

\begin{table}[ht]
\begin{tabular}{|@{}c@{}|@{}c@{}|}
\imgtest & \imgtest \\
\imgtest & \imgtest \\
\end{tabular}
\end{table}

\end{document}

Other solution could be make a minipage in each cell instead of a framed box (modify the lengths as needed):

\begin{minipage}{0.4\textwidth}
\vspace{1mm}
\centering
\includegraphics[scale=.5]{image1.png}
\vspace{1mm}
\end{minipage}

But if you do not want to see the vertical lines in the table (ie, {cc} instead of {|c|c|}) a \\ after \hline might be enough.

Finally: May be do you are searching for a float with subfigures instead of a table with figures? In this case, see the package subcaption.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.