Figure and Image on same line but one higher than the other

299 Views Asked by At

I am trying to put an image and a table on the same line. I am using the subfigure environment to do that. Unfortunately, my figure appear much higher that my table - See image attached. I have also included the code relating to the figure below.

\documentclass[a4paper,11pt,twoside]{article} 
\usepackage{float}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document} 

\begin{figure}[H]
\begin{subfigure}{0.45\linewidth}
\centering
\begin{tabular}{||c c c c||} 
\hline
Parameter & Value \\ [0.5ex] 
\hline\hline
$\mu_a$ Background& 500  \\ 
\hline
$\mu_a$ Balls& 750  \\ 
\hline
$\mu_s$ & 3000  \\
\hline
$B_{xx}/B_{zz}$ & 0.6\\
\hline
$B_{xz}$ & 0.05 \\
\hline
Mesh Order& 10k \\
\hline
Polynomial Order & 3  \\ [1ex] 
\hline
\end{tabular}
\end{subfigure}\hfill
\begin{subfigure}{0.45\linewidth}
\centering
\includegraphics[scale=0.3]{figures/Initial Wavefield and 
Model/muaModel.PNG} 
\caption{Geometry of Problem using $\mu_a$.}
\label{fig3}
\end{subfigure}
\end{figure}

\end{document}

enter image description here

1

There are 1 best solutions below

0
samcarter_is_at_topanswers.xyz On

One possibility would be to use the T option for the subfigures, which will align them on top:

\documentclass[a4paper,11pt,twoside]{article} 
\usepackage{float}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document} 

\begin{figure}[H]
\begin{subfigure}[T]{0.45\linewidth}
\centering
\begin{tabular}{||c c c c||} 
\hline
Parameter & Value \\ [0.5ex] 
\hline\hline
$\mu_a$ Background& 500  \\ 
\hline
$\mu_a$ Balls& 750  \\ 
\hline
$\mu_s$ & 3000  \\
\hline
$B_{xx}/B_{zz}$ & 0.6\\
\hline
$B_{xz}$ & 0.05 \\
\hline
Mesh Order& 10k \\
\hline
Polynomial Order & 3  \\ [1ex] 
\hline
\end{tabular}
\end{subfigure}\hfill
\begin{subfigure}[T]{0.45\linewidth}
\centering
\includegraphics[width=\textwidth]{example-image-duck} 
\caption{Geometry of Problem using $\mu_a$.}
\label{fig3}
\end{subfigure}
\end{figure}

\end{document}

enter image description here

Another possibility is the adjustbox package and then use the valign=... option for your image:

\documentclass[a4paper,11pt,twoside]{article} 
\usepackage{float}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\begin{document} 

\begin{figure}[H]
\begin{subfigure}{0.45\linewidth}
\centering
\begin{tabular}{||c c c c||} 
\hline
Parameter & Value \\ [0.5ex] 
\hline\hline
$\mu_a$ Background& 500  \\ 
\hline
$\mu_a$ Balls& 750  \\ 
\hline
$\mu_s$ & 3000  \\
\hline
$B_{xx}/B_{zz}$ & 0.6\\
\hline
$B_{xz}$ & 0.05 \\
\hline
Mesh Order& 10k \\
\hline
Polynomial Order & 3  \\ [1ex] 
\hline
\end{tabular}
\end{subfigure}\hfill
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\textwidth,valign=m]{example-image-duck} 
\caption{Geometry of Problem using $\mu_a$.}
\label{fig3}
\end{subfigure}
\end{figure}

\end{document}

enter image description here