1

I want to place a figure next to a table. To do so, I use the minipage environment. Here's the MWE:

\documentclass{article}
\usepackage{caption}

\begin{document}


{\centering
\begin{minipage}[t]{0.45\textwidth}
   \centering
   \rule{4cm}{2cm} %to simulate an actual figure
   \captionof{figure}{Figure caption}
\end{minipage}
\begin{minipage}{0.45\textwidth}
   \centering
      \begin{tabular}[t]{lccc}
      \hline
      Parameter & Symbol & Value & Unit \\
      \hline
      XXX                                   & abc & XXX & $\mathrm{m}^2$  \\
      XXX                                   & abc & XXX & $\mathrm{m}^2$  \\
      XXX                                   & abc & XXX & kg \\
      XXX                                   & abc & XXX & $\mathrm{N}/\mathrm{m}$ \\
      XXX                                   & abc & XXX & $\mathrm{N}$ \\ 
      \hline
      \end{tabular}
     \captionof{table}{Table caption}
 \end{minipage}
}

\end{document}

I have not yet found a means to achieve identical alignment vertically for the caption of the figure and the table, respectively. Also, is there any way to center the table vertically on its minipage? Thanks in advance, any help is highly appreciated!

2
  • 1
    See, if minipages position options [b]in both mini pages solve your problem. It should work as long you have on line captions.
    – Zarko
    Commented May 30, 2016 at 12:45
  • It partially does, thank you. I did not yet know the [b]-option.
    – user62795
    Commented May 30, 2016 at 12:47

1 Answer 1

1

Solution suggested in comment works if captions have only one line of text. Better is instead of minipages to use tabularx andadjusbox as follows:

\documentclass{article}
\usepackage{caption}
\usepackage{tabularx}% <-- added
\usepackage[export]{adjustbox}% <-- added

\begin{document}
\begin{center}
\begin{tabularx}{\textwidth}{*{2}{>{\centering\arraybackslash}X}}
   \centering
\includegraphics[width=0.9\linewidth,valign=B]{example-image} % instead of actual figure
   \captionof{figure}{Figure caption}
& 
      \begin{tabular}[b]{lccc}
      \hline
      Parameter & Symbol & Value & Unit \\
      \hline
      XXX       & abc & XXX & $\mathrm{m}^2$  \\
      XXX       & abc & XXX & $\mathrm{m}^2$  \\
      XXX       & abc & XXX & kg \\
      XXX       & abc & XXX & $\mathrm{N}/\mathrm{m}$\\ 
      XXX       & abc & XXX & $\mathrm{N}$ \\
      \hline
      \end{tabular}
     \captionof{table}{Table caption Table caption Table caption Table caption}
\end{tabularx}
 \end{center}
\end{document}

enter image description here

Addendum: To have picture and table vertical centered and the same time vertical aligned their captions at the top, as in figure below, you need two rows in tabularx and change their options which determine their baseline (vertical position in table):

\documentclass{article}
\usepackage{caption}
\usepackage{tabularx}
\usepackage[export]{adjustbox}

\begin{document}
\begin{center}
\begin{tabularx}{\textwidth}{*{2}{>{\centering\arraybackslash}X}}
   \centering
\includegraphics[width=0.9\linewidth,valign=m]{example-image} % <-- valing is chanded from T to m
&
      \begin{tabular}{lccc}% <-- omited [t]
      \hline
      Parameter & Symbol & Value & Unit \\
      \hline
      XXX       & abc & XXX & $\mathrm{m}^2$  \\
      XXX       & abc & XXX & $\mathrm{m}^2$  \\
      XXX       & abc & XXX & kg \\
      XXX       & abc & XXX & $\mathrm{N}/\mathrm{m}$\\
      XXX       & abc & XXX & $\mathrm{N}$ \\
      \hline
      \end{tabular}          \\ % <-- added new row for captions
\captionof{figure}{Figure caption}
&     
    \captionof{table}{Table caption Table caption Table caption Table caption}
\end{tabularx}
 \end{center}
\end{document}

enter image description here

3
  • Great, thanks! I almost don't dare asking: is there any way to now center the table vertically with respect to the image?
    – user62795
    Commented May 31, 2016 at 6:38
  • Of course, it is possible. How you like to have aligned captions? As now? In this case you need to put them in separate tabularx row. See addendum to my answer.
    – Zarko
    Commented May 31, 2016 at 7:41
  • Gorgeous! Exactly what I want! Thank you, Zarko!
    – user62795
    Commented Jun 1, 2016 at 6:00

You must log in to answer this question.

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