1

I am using the answer shown here provided by egreg:

How to put a matrix of images?

However I would like a line between the graph and the caption under the graph. I tried doing it by modifying the \subf function by placing an \hline between #1 and #2. This seems to work before you add the images. But when the images are added there is a gap between the hline above the caption and the vertical lines of the surrounding matrix (see image below)?

How can this gaps be removed?

\usepackage[spanish]{babel}
\usepackage{graphicx}

\newcommand{\subf}[2]{%
{\small\begin{tabular}[t]{@{}c@{}}
#1\ \hline \#2
\end{tabular}}%
}


\begin{document}
\begin{figure}
\centering
\begin{tabular}{|c|c|}
\hline
\subf{\includegraphics[width=60mm]{example-image-4x3.pdf}}
 {``iteraciones máximas \\ de BT''$=20$}
&
\subf{\includegraphics[width=60mm]{example-image-4x3.pdf}}
 {``Periodo de Tenencia \\ en Lista Tabú''$=2$}
\\
\hline
\subf{\includegraphics[width=60mm]{example-image-4x3.pdf}}
 {``iteraciones máximas \\ de BT''$=20$}
&
\subf{\includegraphics[width=60mm]{example-image-4x3.pdf}}
 {``Periodo de Tenencia \\ en Lista Tabú''$=2$}
\\
\hline
\end{tabular}
\end{figure}
\end{document} 

enter image description here

2
  • The gap is most likely due to |c|c| from the outer tabular, you've got extra spacing there between the vertical lines and the columns! Use |@{}c@{}|@{}c@{}| to remove the spacing
    – user31729
    Sep 18, 2015 at 17:58
  • There's also a \documentclass{...} missing
    – user31729
    Sep 18, 2015 at 18:04

1 Answer 1

3

The difference is from additional space added by \tabcolsep. You can, e.g., change your \begin{tabular}{|c|c|} into \begin{tabular}{|@{}c@{}|@{}c@{}|}.

You can also set (locally) \tabcolsep to 0pt.

(Alas, without the illustrating picture, as your images are not reachable.)

1
  • 1
    Damn, you were quicker ;-) -- You could use demo mode of course
    – user31729
    Sep 18, 2015 at 18:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .