1

I am using multirow to merge two rows of a table - I want the figure in that column to be vertically aligned.

enter image description here

MWE

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{multirow}


\begin{document}
\begin{figure}  \begin{center}
\begin{tabular}{c c l}
\includegraphics[width=0.4\textwidth]{example-image-a} &
\includegraphics[width=0.4\textwidth]{example-image-a} & \multirow{2}{*}{ $\vcenter{\hbox{\includegraphics[width=0.1\textwidth,height=4cm]{example-grid-100x100pt}}}$}\\
\includegraphics[width=0.4\textwidth]{example-image-a} &
\includegraphics[width=0.4\textwidth]{example-image-a} &
\end{tabular}
\caption{default}
\label{fig:}  \end{center}
\end{figure}

\end{document}  

I have tried to adapt this answer with both the raisebox and vcenter options by using

\multirow{2}{*}{\raisebox{-0.5\height}{\includegraphics[width=0.1\textwidth,height=4cm]{example-grid-100x100pt}}}

and

\multirow{2}{*}{$\vcenter{\hbox{\includegraphics[width=0.1\textwidth,height=4cm]{example-grid-100x100pt}}}$}

as well as

\multirow{2}{*}{\includegraphics[width=0.1\textwidth,height=4cm,valign=m]{example-grid-100x100pt}}

with \usepackage[export]{adjustbox} added to the preamble as suggested by this answer to a related question

without anything changing.

3 Answers 3

1

You don't really need to use \multirow here. A simple \raisebox, with the optional arguments to fool LaTeX will do the trick.

Unrelated: don't insert a center environment in floats, as it adds a supplementry, usually unwanted, vertical spacing. Use \centering instead.

\documentclass[11pt]{article}
\usepackage{graphicx}

\begin{document}

\begin{figure} \centering
\begin{tabular}{c c l}
\includegraphics[width=0.4\textwidth]{example-image-a} &
\includegraphics[width=0.4\textwidth]{example-image-a} &
\raisebox{-0.5\height}[0pt][0pt]{\includegraphics[width=0.1\textwidth,height=4cm]{example-grid-100x100pt}} \\
\includegraphics[width=0.4\textwidth]{example-image-a} &
\includegraphics[width=0.4\textwidth]{example-image-a} & %
\end{tabular}
\caption{default}
\label{fig:}
\end{figure}

\end{document} 

enter image description here

1

An alternative with minipages:

\documentclass[11pt]{article}
\usepackage{graphicx}

\begin{document}
\begin{figure}
  \begin{minipage}{0.4\textwidth}
    \includegraphics[width=\textwidth]{example-image-a}
    \includegraphics[width=\textwidth]{example-image-b}
  \end{minipage}\hfill
  \begin{minipage}{0.4\textwidth}
    \includegraphics[width=\textwidth]{example-image-c} 
    \includegraphics[width=\textwidth]{example-image-a}
  \end{minipage}\hfill
  \begin{minipage}{0.1\textwidth}
    \includegraphics[width=\textwidth,height=4cm]{example-grid-100x100pt}
  \end{minipage}
  \caption{ma caption}
  \label{fig:mylabel}
\end{figure}
\end{document} 
0

I think that multirow is not necessary. If I understand your problem description correctly, one could use the graphbox package (or any other similar package) to achieve the desired effect in a simple way.

Output

enter image description here

Code

\documentclass{article}
\usepackage{graphbox}


\begin{document}
\begin{figure}
\begin{tabular}{ccl}
\includegraphics[width=.4\textwidth]{example-image-a} &
\includegraphics[width=.4\textwidth]{example-image-a} &
\includegraphics[width=.1\textwidth,height=4cm,align=c,vsmash,vshift=-.45em]{example-grid-100x100pt}
\\
\includegraphics[width=.4\textwidth]{example-image-a} &
\includegraphics[width=.4\textwidth]{example-image-a} &
\end{tabular}
\caption{default}
\label{fig:}
\end{figure}
\end{document}

Of course, the vshift part is not an optimal solution. I hope someone will improve it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .