# Vertical alignment problem when organizing image with tabular

I would like to display multiple images organized by tabular. Here's my code, which demonstrate what I want to do.

\documentclass[11pt]{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\renewcommand{\arraystretch}{0}
\begin{tabular}{@{}c@{}c@{}}
\begin{tabular}{@{}c@{}c@{}}
\includegraphics[scale=0.8]{app2.png}&\includegraphics[scale=0.8]{v2.png}\\
\includegraphics[scale=0.8]{h2.png}&\includegraphics[scale=0.8]{d2.png}\\
\end{tabular}& \includegraphics[scale=0.8]{v.png}\\
\includegraphics[scale=0.8]{h.png}&\includegraphics[scale=0.8]{d.png}\\
\end{tabular}
\caption{Result}
\end{figure}
\end{document}


However, in the display result there is some weird vertical space, which I cannot figure out why it is there and how to remove it.

Any help would be really appreciated!

• Welcome to SE! Please, make your code snipped compilable! Add to it \documentclass{...}, used packages, \begin{document} and end{document}. – Zarko Feb 29 '16 at 21:45

## 1 Answer

tabular has a default anchor on its vertical center, while \includegraphics sets content with its anchor on the baseline. The following recreates the problem:

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\begin{figure}
\centering
\renewcommand{\arraystretch}{0}
\begin{tabular}{ c c }
\begin{tabular}{ c c }
\includegraphics[scale=0.2]{example-image-1x1} & \includegraphics[scale=0.2]{example-image-1x1} \\
\includegraphics[scale=0.2]{example-image-1x1} & \includegraphics[scale=0.2]{example-image-1x1} \\
\end{tabular} & \includegraphics[scale=0.2]{example-image-1x1}
\end{tabular}
\caption{Result}
\end{figure}

\end{document}


You'll either have to correct the anchor of the tabular, or the anchor of the image:

• For the former, you can force the anchor using the optional argument of tabular. That is use \begin{tabular}[b]{..} for the inner/nested tabular, which will provide an anchor point on the baseline, just like \includegraphics does.

• Alternatively,adjustbox's valign=c places an \includegraphics image with a centred vertical anchor:

\documentclass{article}

\usepackage[export]{adjustbox}

\begin{document}

\begin{figure}
\centering
\renewcommand{\arraystretch}{0}
\begin{tabular}{ c c }
\begin{tabular}{ c c }
\includegraphics[scale=0.2]{example-image-1x1} & \includegraphics[scale=0.2]{example-image-1x1} \\
\includegraphics[scale=0.2]{example-image-1x1} & \includegraphics[scale=0.2]{example-image-1x1} \\
\end{tabular} & \includegraphics[scale=0.2,valign=c]{example-image-1x1}
\end{tabular}
\caption{Result}
\end{figure}

\end{document}


You'll have to export the adjustbox key-value options in order to use them as-is inside \includegraphics.