# Why are my subfloats not aligned?

I am putting a figure and a table side by side:

\documentclass[format=acmsmall, review=false, screen=true]{acmart}

\usepackage{multicol}      % http://ctan.org/pkg/multicols
\usepackage{balance}       % to better equalize the last page
\usepackage{subfig}

\begin{document}
\begin{figure}
\centering
\subfloat[]{\includegraphics[width=0.4\columnwidth, keepaspectratio]{OSM_copy.png}\label{OSM}}
\subfloat[]
{
\resizebox{0.5\columnwidth}{!}{
\begin{tabular}{|c|c|c|c|}
\hline \rule[-2ex]{0pt}{5.5ex}  \bf Location Type & \bf Index & \bf Location Type & \bf Index  \\
\hline
\hline \rule[-1ex]{0pt}{5.5ex}  Bar & \raisebox{-0.1cm}{\includegraphics[scale=0.7]{index_bar.png}} & Taxi stand &  \raisebox{-0.1cm}{\includegraphics[scale=0.5]{index_taxi.png}}\\
\hline \rule[-2ex]{0pt}{5.5ex}  Food court &  \raisebox{-0.3cm}{\includegraphics[scale=0.7]{index_foodcourt.png}} & Hospital &  \raisebox{-0.2cm}{\includegraphics[scale=0.5]{index_hospital.png}} \\
\hline \rule[-2ex]{0pt}{5.5ex}  Library &  \raisebox{-0.2cm}{\includegraphics[scale=0.5]{index_library.png}} & Pharmacy &  \raisebox{-0.2cm}{\includegraphics[scale=0.5]{index_pharmacy.png}} \\
\hline \rule[-2ex]{0pt}{5.5ex}  Fuel station &  \raisebox{-0.2cm}{\includegraphics[scale=0.5]{index_fuel.png}} & Movie theater &  \raisebox{-0.2cm}{\includegraphics[scale=0.5]{index_movie.png}} \\
\hline \rule[-2ex]{0pt}{5.5ex}  Parking &  \raisebox{-0.1cm}{\includegraphics[scale=0.5]{index_parking.png}} & Public telephone &  \raisebox{-0.2cm}{\includegraphics[scale=0.5]{index_phone.png}} \\
\hline
\end{tabular}}
\label{table2}
}
\caption[]{(a) An area in Taipei showing different location types. (b) Some of the location types defined in OSM. }
\label{fig:location}
\end{figure}

\end{document}


And this is the output I am getting:

Why are they not appearing in the same "plane"? And how do I rectify it?

The default vertical alignment of a tabular (unless specified otherwise) is at the centre, while those of images are its baseline. These vertical alignment locations can be seen as anchor points and they align with one another if placed on the same horizontal line. Here's a quick demonstration:

\documentclass{article}

\begin{document}

x
\includegraphics[height=2\baselineskip]{example-image}
x
\begin{tabular}{c} \hline a \\ b \\ c \\ \hline \end{tabular}
x
\begin{tabular}[t]{c} \hline a \\ b \\ c \\ \hline \end{tabular}
x
\begin{tabular}[b]{c} \hline a \\ b \\ c \\ \hline \end{tabular}
x
\adjustbox{valign=t}{\begin{tabular}[b]{c} \hline a \\ b \\ c \\ \hline \end{tabular}}
x
\adjustbox{valign=T}{\begin{tabular}[b]{c} \hline a \\ b \\ c \\ \hline \end{tabular}}
x
\adjustbox{valign=b}{\begin{tabular}[b]{c} \hline a \\ b \\ c \\ \hline \end{tabular}}
x
\adjustbox{valign=B}{\begin{tabular}[b]{c} \hline a \\ b \\ c \\ \hline \end{tabular}}
x

\bigskip\bigskip

x
\includegraphics[height=2\baselineskip,valign=c]{example-image}
x
\begin{tabular}{c} a \\ b \\ c \end{tabular}
x

\end{document}


With the above in mind, you can either align the image to its vertical centre (rather than the baseline), or align the tabular to its Baseline (rather than its vertical centre) to align the two images.

However, you're still left with two objects of differing heights, and this might be off-putting. I've taken your code and added some pizzaz to it, including the use of valign modifications for the image and tabular, as well as using booktabs. Note the use of a consistent height for each of the images in the legend (subfigure (b)); this provides consistency across the rows of the table without having to guess an appropriate scale.

\documentclass[format=acmsmall, review=false, screen=true]{acmart}

\usepackage{subfig,booktabs,makecell}

\begin{document}
\begin{figure}
\centering
\subfloat[]
\subfloat[]
\renewcommand{\arraystretch}{1.5}%
\begin{tabular}{ *{4}{c} }
\toprule
\bfseries \makecell[b]{Location \\ type} & \bfseries Index &
\bfseries \makecell[b]{Location \\ type} & \bfseries Index \\
\midrule
Bar          & \includegraphics[height=12pt,valign=c]{index_bar.png}       &
Taxi stand       & \includegraphics[height=12pt,valign=c]{index_taxi.png}     \\
Food court   & \includegraphics[height=12pt,valign=c]{index_foodcourt.png} &
Hospital         & \includegraphics[height=12pt,valign=c]{index_hospital.png} \\
Library      & \includegraphics[height=12pt,valign=c]{index_library.png}   &
Pharmacy         & \includegraphics[height=12pt,valign=c]{index_pharmacy.png} \\
Fuel station & \includegraphics[height=12pt,valign=c]{index_fuel.png}      &
Movie theater    & \includegraphics[height=12pt,valign=c]{index_movie.png}    \\
Parking      & \includegraphics[height=12pt,valign=c]{index_parking.png}   &
Public telephone & \includegraphics[height=12pt,valign=c]{index_phone.png}    \\
\bottomrule
\end{tabular}}
}
\caption{%
(a) An area in Taipei showing different location types.
(b) Some of the location types defined in OSM.}
\end{figure}

\end{document}

• Thanks for the detailed explanation. I think the operative line in your solution is \adjustbox{width=0.5\columnwidth,valign=B,raise=2\baselineskip}. By adjusting the parameters in only this line, one can achieve the desired result. Nonetheless, your detailed response helped me learn something new. – Kristada673 Oct 20 '17 at 14:13

Here's a solution that uses a tabularx environment instead of tabular. It also uses some of the macros of the booktabs package to give the tabular material a more open space. Finally, it employs the subcaption package. (I used the 'demo' option since I don't have access to the various image files; omit the 'demo' option in your real code.)

\documentclass[format=acmsmall, review=false, screen=true,
demo]{acmart} % remove 'demo' option in real document

\usepackage{multicol} % Q: Do you really need this package?
\usepackage{balance}
\usepackage{graphicx}
\usepackage{tabularx,booktabs,ragged2e}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\newcolumntype{C}{>{\Centering\arraybackslash}X}

\begin{document}

\begin{figure}
\begin{subfigure}[t]{0.42\textwidth}
\includegraphics[width=\linewidth, keepaspectratio]{OSM_copy.png}
\caption{} \label{OSM}
\end{subfigure}%
\hfill% Maximize the distance between the two subfigure environments
\begin{subfigure}[t]{0.55\textwidth}
\begin{tabularx}{\linewidth}{@{}Cm{10mm}Cm{10mm}@{}}
Location Type & Index & Location Type & Index  \\
\midrule
Bar              & \includegraphics[width=\linewidth,height=\linewidth]{index_bar.png} &
Taxi stand       & \includegraphics[width=\linewidth,height=\linewidth]{index_taxi.png}\\
Food court       & \includegraphics[width=\linewidth,height=\linewidth]{index_foodcourt.png} &
Hospital         & \includegraphics[width=\linewidth,height=\linewidth]{index_hospital.png} \\
Library          & \includegraphics[width=\linewidth,height=\linewidth]{index_library.png} &
Pharmacy         & \includegraphics[width=\linewidth,height=\linewidth]{index_pharmacy.png} \\
Fuel station     & \includegraphics[width=\linewidth,height=\linewidth]{index_fuel.png} &
Movie theater    & \includegraphics[width=\linewidth,height=\linewidth]{index_movie.png} \\