1

I want to create a table with image on side by side. The problem I encountered is the alignment of the table. Can anyone fix the code to make the Lambda_1 and Lambda_2 become the caption for each figure accordingly? And if i don't include the & beside 1.~Real unequal eigenvalues of same sign &
Then the left border of the table will not be connecting to the title border. I know the problem is with \begin{tabularx}{\textwidth}{|XX|}. Can somehelp give me guide to change the code to make a better alignment? I want to change the column of the figure to 1, and include the figure side by side instead of 2 columns.
I insisted to use tabularx is because i did not want the table to move over the margin of my document.

\begin{table} [H]
\begin{tabularx}{\textwidth}{|XX|}
\hline
    \multicolumn{2}{|c|}{Collection of Figures of 2D Phase Portraits} \\ \hline 
    1.~Real unequal eigenvalues of same sign & \\ 
        \includegraphics[height=1.8in]{2D/rup.png}        $\lambda_1 > \lambda_2 > 0$ & \includegraphics[height=1.8in]{2D/run.png}$\lambda_1 > \lambda_2 < 0$  \\ 
\hline
\end{tabularx}
\end{table} 

enter image description here

2

There's really no need for a tabularx for just one column; a simple tabular can be used instead. I used the subfigure environment from subcaption and the features from booktabs (without the vertical rules fot the table):

\documentclass[11pt]{article} 
\usepackage[demo]{graphicx} 
\usepackage{subcaption}
\usepackage{booktabs}

\begin{document} 

\begin{table}[H]
\begin{tabular}{l}
\toprule
\multicolumn{1}{c}{Collection of Figures of 2D Phase Portraits} \\ 
\midrule 
1.~Real unequal eigenvalues of same sign  \\ 
\begin{subfigure}{\dimexpr.5\linewidth-2\fboxsep\relax}
  \centering
  \includegraphics[height=1.8in]{2D/rup.png}
  \caption{$\lambda_1 > \lambda_2 > 0$}
\end{subfigure}\hfill%  
\begin{subfigure}{\dimexpr.5\linewidth-2\fboxsep\relax}
  \centering
  \includegraphics[height=1.8in]{2D/run.png}
  \caption{$\lambda_1 > \lambda_2 < 0$}
\end{subfigure} \\
\bottomrule
\end{tabular}
\end{table} 

\end{document}

enter image description here

If captions don't require numbering for cross-referencing, one can simply use minipages:

\documentclass[11pt]{article} 
\usepackage[demo]{graphicx} 
\usepackage{booktabs}

\begin{document} 

\begin{table}[H]
\begin{tabular}{l}
\toprule
\multicolumn{1}{c}{Collection of Figures of 2D Phase Portraits} \\ 
\midrule 
1.~Real unequal eigenvalues of same sign  \\ 
\begin{minipage}{\dimexpr.5\linewidth-2\fboxsep\relax}
  \centering
  \includegraphics[height=1.8in]{2D/rup.png}\par
  $\lambda_1 > \lambda_2 > 0$
\end{minipage}%  
\begin{minipage}{\dimexpr.5\linewidth-2\fboxsep\relax}
  \centering
  \includegraphics[height=1.8in]{2D/run.png}\par
  $\lambda_1 > \lambda_2 < 0$
\end{minipage} \\
\bottomrule
\end{tabular}
\end{table} 

\end{document}

enter image description here

The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.

  • is it possible to change the column to only single column and place the figure side by side? – superhuman1314 Mar 16 '14 at 17:57
  • I've tried to use subfloat, \subfloat[a]{\includegraphics[height=1.8in]{2D/rup.png}}, but there is an error "No counter 'subtable@save' defined. \end{tabularx}". I do not know what's gone wrong. – superhuman1314 Mar 16 '14 at 18:00
  • @AndrewOoi please see the second code in my updated answer. Something like that? Do you want the captions to be numbered? – Gonzalo Medina Mar 16 '14 at 18:12
  • Thanks @Gonzalo Medina, the answer helped me. But i found that the spacing between the image and the caption is kinda far, is it possible to shorten the spacing between them? and is it possible to align the '1.~Real unequal eigenvalues of same sign' to the left? – superhuman1314 Mar 16 '14 at 18:24
  • @AndrewOoi which of the two codes of my recently updated answer are you using? – Gonzalo Medina Mar 16 '14 at 18:27

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.