-1

I have a table below and I would like to insert a figure to its right. Both table and figure will use a single caption. Below is my code for the table.

\begin{table*}
\begin{center}
\begin{tabular}{|l|l|cc|cc|cc|}
\hline%\noalign{\smallskip}
\multirow{2}{*}{Type} & \multirow{2}{*}{Model} & \multicolumn{2}{c|}{$\text{x}_{1:10} \rightarrow \hat{\text{x}}_{11:30}$} & \multicolumn{2}{c|}{$\text{x}_{1:10} \rightarrow \hat{\text{x}}_{11:50}$} & \multicolumn{2}{c|}{$\text{x}_{1:10} \rightarrow \hat{\text{x}}_{11:70}$} \\
 &  & SSIM & PSNR & SSIM & PSNR & SSIM & PSNR \\
\hline
\multirow{3}{*}{Deterministic} \ & 2D ConvLSTM \cite{convlstm} & 0.712 & 23.58 & 0.639 & 22.85 & 0.551 & 20.13 \\
& PredRNN++ \cite{wang-predrnn} & 0.865 & 28.47 & 0.741 & 25.21 & 0.702 & 23.51 \\ 
& E3D-LSTM \cite{wang-e3d} & \textbf{0.879} & \textbf{29.31} & 0.810 & 27.24 & 0.798 & 26.82 \\ 
\hline
\multirow{2}{*}{Stochastic} & Variational 2D ConvLSTM \cite{vrnn} & 0.787 & 25.76 & 0.733 & 24.83 & 0.672 & 23.13 \\
& Variational 3D ConvLSTM (Ours) & 0.866 & 28.31 & \textbf{0.852} & \textbf{27.89} & \textbf{0.846} & \textbf{27.66} \\ 
\hline
\end{tabular}
\end{center}
\caption{Results on the KTH action dataset when using 10 frames to predict 20 ($\text{x}_{1:10} \rightarrow \hat{\text{x}}_{11:30}$), 40 ($\text{x}_{1:10} \rightarrow \hat{\text{x}}_{11:50}$), and 60 ($\text{x}_{1:10} \rightarrow \hat{\text{x}}_{11:70}$) timesteps into the future. The metrics are computed frame-wise. Higher SSIM and PSNR scores indicate better results.}
\label{table:quantitativekth}
\end{table*}

enter image description here

I tried following the code here Include table as a subfigure but the figure always appears below.

\begin{table*}
\begin{center}
\subfloat[][]{\begin{tabular}{|l|l|cc|cc|cc|}
\hline%\noalign{\smallskip}
\multirow{2}{*}{Type} & \multirow{2}{*}{Model} & \multicolumn{2}{c|}{$\text{x}_{1:10} \rightarrow \hat{\text{x}}_{11:30}$} & \multicolumn{2}{c|}{$\text{x}_{1:10} \rightarrow \hat{\text{x}}_{11:50}$} & \multicolumn{2}{c|}{$\text{x}_{1:10} \rightarrow \hat{\text{x}}_{11:70}$} \\
 &  & SSIM & PSNR & SSIM & PSNR & SSIM & PSNR \\
\hline
\multirow{3}{*}{Deterministic} \ & 2D ConvLSTM \cite{convlstm} & 0.712 & 23.58 & 0.639 & 22.85 & 0.551 & 20.13 \\
& PredRNN++ \cite{wang-predrnn} & 0.865 & 28.47 & 0.741 & 25.21 & 0.702 & 23.51 \\ 
& E3D-LSTM \cite{wang-e3d} & \textbf{0.879} & \textbf{29.31} & 0.810 & 27.24 & 0.798 & 26.82 \\ 
\hline
\multirow{2}{*}{Stochastic} & Variational 2D ConvLSTM \cite{vrnn} & 0.787 & 25.76 & 0.733 & 24.83 & 0.672 & 23.13 \\
& Variational 3D ConvLSTM (Ours) & 0.866 & 28.31 & \textbf{0.852} & \textbf{27.89} & \textbf{0.846} & \textbf{27.66} \\ 
\hline
\end{tabular}
}
\quad
\subfloat[][]{\includegraphics[width=0.1\textwidth]{kth.png}}
\end{center}
\caption{Results on the KTH action dataset when using 10 frames to predict 20 ($\text{x}_{1:10} \rightarrow \hat{\text{x}}_{11:30}$), 40 ($\text{x}_{1:10} \rightarrow \hat{\text{x}}_{11:50}$), and 60 ($\text{x}_{1:10} \rightarrow \hat{\text{x}}_{11:70}$) timesteps into the future. The metrics are computed frame-wise. Higher SSIM and PSNR scores indicate better results.}
\label{table:quantitativekth}
\end{table*}

enter image description here

Kong
  • 2,313
  • 2
    Please make your code compilable by adding the documentclass as well as the required packages. Regarding the second image: Did you get any error messages compiling your code? If so, which? (The [][] in your second screenshot makes me guess that you got an error message such as " Undefined control sequence. \subfloat" because you forgot to add the subfig package to your preamble.) Apart from that, your table and image are probably wider than the textwidth, hence they are placed below each other instead of side-by-side. This guess is however hard to confirm without a full MWE. – leandriis Sep 19 '20 at 12:54
  • Your table is very wide as it is, so there's very little (no) room to place an image (chart) next to it. – Werner Sep 19 '20 at 19:36

1 Answers1

2

enter image description here

  • Your table is litle bit to wide, so in the following MWE i reduce used font size in table and size of \tabcolsep
  • table and image are encapsulated in table
  • for vertical centering of figure is used valign=c c option defined in adjustbox package (it also load graphicx package,
\documentclass[twocolumn]{article}
%\usepackage{geometry}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\usepackage[export]{adjustbox} \usepackage{multirow} \usepackage{siunitx}

\begin{document} \begin{table} \centering \setlength\tabcolsep{4pt} \begin{tabular}{@{} lr @{}} \small \begin{tabular}{@{} |l|l|cc|cc|cc|@{}} \hline \multirow{2}{}{Type} & \multirow{2}{}{Model} & \multicolumn{2}{c|}{$\text{x}{1:10} \rightarrow \hat{\text{x}}{11:30}$} & \multicolumn{2}{c|}{$\text{x}{1:10} \rightarrow \hat{\text{x}}{11:50}$} & \multicolumn{2}{c|}{$\text{x}{1:10} \rightarrow \hat{\text{x}}{11:70}$} \ & & SSIM & PSNR & SSIM & PSNR & SSIM & PSNR \ \hline \multirow{3}{}{Deterministic} \ & 2D ConvLSTM \cite{convlstm} & 0.712 & 23.58 & 0.639 & 22.85 & 0.551 & 20.13 \ & PredRNN++ \cite{wang-predrnn} & 0.865 & 28.47 & 0.741 & 25.21 & 0.702 & 23.51 \ & E3D-LSTM \cite{wang-e3d} & \textbf{0.879} & \textbf{29.31} & 0.810 & 27.24 & 0.798 & 26.82 \ \hline \multirow{2}{*}{Stochastic} & Variational 2D ConvLSTM \cite{vrnn} & 0.787 & 25.76 & 0.733 & 24.83 & 0.672 & 23.13 \ & Variational 3D ConvLSTM (Ours) & 0.866 & 28.31 & \textbf{0.852} & \textbf{27.89} & \textbf{0.846} & \textbf{27.66} \ \hline \end{tabular} & \includegraphics[width=0.1\linewidth,valign=c]{example-image-duck} \end{tabular}

\caption{Results on the KTH action dataset when using 10 frames to predict 20 ($\text{x}{1:10} \rightarrow \hat{\text{x}}{11:30}$), 40 ($\text{x}{1:10} \rightarrow \hat{\text{x}}{11:50}$), and 60 ($\text{x}{1:10} \rightarrow \hat{\text{x}}{11:70}$) time steps into the future. The metrics are computed frame-wise. Higher SSIM and PSNR scores indicate better results.} \label{table:quantitativekth} \end{table*} \end{document}

Addendum: If you like to have aligned table and image at their bottoms, than you just add option [b]˙to insert4d table and at image remove option valign=c`:

\documentclass[twocolumn]{article}
\usepackage[export]{adjustbox}
\usepackage{multirow}
\usepackage{siunitx}

\begin{document} \begin{table} \centering \setlength\tabcolsep{4pt} \begin{tabular}{@{} lr @{}} \small \begin{tabular}[b]{@{} |l|l|cc|cc|cc|@{}} \hline \multirow{2}{}{Type} & \multirow{2}{}{Model} & \multicolumn{2}{c|}{$\text{x}{1:10} \rightarrow \hat{\text{x}}{11:30}$} & \multicolumn{2}{c|}{$\text{x}{1:10} \rightarrow \hat{\text{x}}{11:50}$} & \multicolumn{2}{c|}{$\text{x}{1:10} \rightarrow \hat{\text{x}}{11:70}$} \ & & SSIM & PSNR & SSIM & PSNR & SSIM & PSNR \ \hline \multirow{3}{}{Deterministic} \ & 2D ConvLSTM \cite{convlstm} & 0.712 & 23.58 & 0.639 & 22.85 & 0.551 & 20.13 \ & PredRNN++ \cite{wang-predrnn} & 0.865 & 28.47 & 0.741 & 25.21 & 0.702 & 23.51 \ & E3D-LSTM \cite{wang-e3d} & \textbf{0.879} & \textbf{29.31} & 0.810 & 27.24 & 0.798 & 26.82 \ \hline \multirow{2}{*}{Stochastic} & Variational 2D ConvLSTM \cite{vrnn} & 0.787 & 25.76 & 0.733 & 24.83 & 0.672 & 23.13 \ & Variational 3D ConvLSTM (Ours) & 0.866 & 28.31 & \textbf{0.852} & \textbf{27.89} & \textbf{0.846} & \textbf{27.66} \ \hline \end{tabular} & \includegraphics[width=0.1\linewidth]{example-image-duck} \end{tabular}

\caption{Results on the KTH action dataset when using 10 frames to predict 20 ($\text{x}{1:10} \rightarrow \hat{\text{x}}{11:30}$), 40 ($\text{x}{1:10} \rightarrow \hat{\text{x}}{11:50}$), and 60 ($\text{x}{1:10} \rightarrow \hat{\text{x}}{11:70}$) time steps into the future. The metrics are computed frame-wise. Higher SSIM and PSNR scores indicate better results.} \label{table:quantitativekth} \end{table*} \end{document}

enter image description here

Zarko
  • 296,517
  • Thank you very much! Latex is so difficult to understand. One last question, how would I vertically align my table to the bottom (or center) if the figure is taller than the table? e.g. valign=bottom or valign=c for tabular but I can't find a similar type of command for the table environment. – Kong Sep 19 '20 at 20:15
  • 1
    @Kong, you are welcome! Well, with some experiences all become clear and understandable :-) – Zarko Sep 19 '20 at 20:16
  • 1
    @Kong, for bottom align of table and image remove \valign=c and at option [b] to inserted tabular: \begin{tabular}[b]{@{} |l|l|cc|cc|cc|@{}}. – Zarko Sep 19 '20 at 20:20
  • Thank you very much! – Kong Sep 19 '20 at 20:23