3

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.

enter image description here

Any help would be really appreciated!

  • 1
    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
3

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

enter image description here

\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:

    enter image description here

    \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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.