I was trying to insert pictures with captions in a table in latex. I have read some posts here about adding pictures in the table using \raisebox. I tried something like
\begin{table}[ht]
\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline
Query Structure & The most similar structure & The second most similar structure & The third most similar structure \\
\hline
\raisebox{-.5\height}{\includegraphics[scale=0.2]{GS_Ade_PathwayA_I1A_B3LYP_631Gd}} & \raisebox{-.5\height}{\includegraphics[scale=0.2]{GS_Ade_PathwayA_I1A_B3LYP_631Gd}} & \raisebox{-.5\height}{\includegraphics[scale=0.2]{GS_Ade_PathwayA_I1A_G3MP2B3}} &\raisebox{-.5\height}{\includegraphics[scale=0.2]{GS_Ade_PathwayA_I1A_G3B3}}\\
\hline
\end{tabular}
\end{center}
\end{table}
It worked. But I want these pictures with captions. At first, I tried to add caption{} in raisebox directly like:
\raisebox{-.5\height}{\includegraphics[scale=0.2]{GS_Ade_PathwayA_I1A_B3LYP_631Gd} \caption{structure GS\_Ade\_PathwayA\_I1A\_B3LYP\_631Gd}}
I got error msg for writing latex like this. So I tired to put the captions in the next row with no \hline in between to work around.
\begin{table}[ht]
\label{table2}
\begin{center} %Note American spelling
\begin{tabular}{| p{0.25\textwidth} | p{0.25\textwidth} | p{0.25\textwidth} | p{0.25\textwidth} |}
\hline
Query Structure & The most similar structure & The second most similar structure & The third most similar structure \\
\hline
\raisebox{-.5\height}{\includegraphics[scale=0.2]{GS_Ade_PathwayA_I1A_B3LYP_631Gd}} & raisebox{-.5\height}{\includegraphics[scale=0.2]{GS_Ade_PathwayA_I1A_B3LYP_631Gd}} & \raisebox{-.5\height}{\includegraphics[scale=0.2]{GS_Ade_PathwayA_I1A_G3MP2B3}} &\raisebox{-.5\height}{\includegraphics[scale=0.2]{GS_Ade_PathwayA_I1A_G3B3}} \\
GS\_Ade\_PathwayA\_I1A\_B3LYP\_631Gd.out1.ar &GS\_Ade\_PathwayA\_I1A\_B3LYP\_631Gd.out1.ar &GS\_Ade\_PathwayA\_I1A\_G3MP2B3.out1.ar &GS\_Ade\_PathwayA\_I1A\_G3B3.out1.ar \\
\hline
\caption{Results Table}
\end{tabular}
\end{center}
\end{table}
By doing above, I got two problems with the result.
- The pictures are not centered in each cell. Although I have set the height of the raisbox, the pictures are still closely attached to the upper cell edge.
- I have set the width of each column to be 1/4 width of the \textwidth. It worked for the texts in the header. Some long text such as "The second most similar structure" was splited into two rows. However, for the text under the pictures, they were all overlapped. I think Latex consider it as a whole word, so it didn't split into multiple rows.
Can anyone suggest how to solve these problems?
Thank you.