[Tex/LaTex] Minipages with figure and tables side by side: Alignment of captions

floatsminipagetables

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!

Best Answer

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