4

Currently, I have

\usepackage{subfig}
\usepackage{tabularx}
\usepackage{multirow}

\begin{figure*}
\def\tabularxcolumn#1{m{#1}}
\begin{tabularx}{\linewidth}{@{}ccc@{}}
%
\subfloat[caption]{\includegraphics[width=.3\linewidth]{a}}
\subfloat[caption]{\includegraphics[width=.3\linewidth]{b}}
\begin{tabular}{c}
\subfloat[caption]{\includegraphics[width=.25\linewidth]{c}} \\ 
\subfloat[caption]{\includegraphics[width=.25\linewidth]{d}} 
\end{tabular}
\\
\subfloat[caption]{\includegraphics[width=.3\linewidth]{e}} 
\subfloat[caption]{\includegraphics[width=.3\linewidth]{f}} 
\subfloat[caption]{\includegraphics[width=.3\linewidth]{g}} 
\\
\subfloat[caption]{\includegraphics[width=.3\linewidth]{h}} 
\subfloat[caption]{\includegraphics[width=.3\linewidth]{i}} 
\subfloat[caption]{\includegraphics[width=.3\linewidth]{j}} 

\end{tabularx}

\caption{A selection of the slides made during the user study}\label{slides}
\end{figure*}

I expected to see enter image description here

but instead, it looks like enter image description here

where c and d are misaligned from a and b, and causes the whole row to be taller.

I first started by following how to put subfigures in several rows, and got the images lined up as I expected. But the captions labeling was in columns not rows as follows

a d g/h
b e i
c f j

I tried using multirows, but it had a similar problem

\begin{tabular}{ccc}
\multirow{ 2}{*}{\subfloat[caption]{\includegraphics[width=.3\linewidth]{a}}}&
\multirow{ 2}{*}{\subfloat[caption]{\includegraphics[width=.3\linewidth]{b}} }&
\subfloat[caption]{\includegraphics[width=.25\linewidth]{c}} \\ 
&&\subfloat[caption]{\includegraphics[width=.25\linewidth]{d}} 
\end{tabular}

Is there a way to shift up subfloats c and d to match a and b?

2 Answers2

3

For desired align of images c and d you need to add option [b] to nested table, for example:

\begin{tabular}[b]{@{}c@{}}

Beside this your use of tabularx is wrong. If you use it, than you also should use its column type X. Also the images should be sheduled between columns:

\documentclass{article}
\usepackage{graphicx}

\usepackage{subfig}
\usepackage{tabularx}
\usepackage{multirow}

\begin{document}
\begin{figure*}
\begin{tabularx}{\linewidth}{@{}*{3}{>{\centering\arraybackslash}X}@{}}
%
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image-a}}
&
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image-b}}
&
\begin{tabular}[b]{@{}c@{}}
\subfloat[caption]{\includegraphics[width=.8\linewidth,height=1cm]{example-image}} \\
\subfloat[caption]{\includegraphics[width=.8\linewidth,height=1cm]{example-image}}
\end{tabular}
\\
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image}}
&
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image}}
&
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image}}
\\
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image}}
&
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image}}
&
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image}}
\end{tabularx}

\caption{A selection of the slides made during the user study}\label{slides}
\end{figure*}
\end{document}

enter image description here

Zarko
  • 296,517
3

You need no outer tabular (even less tabularx).

\documentclass{article}
\usepackage{graphicx}

\usepackage{subfig}

\begin{document}

\begin{figure}[htp]

\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image-a}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image-b}}\hfill
\begin{minipage}[b]{.3\textwidth}
\subfloat[caption]{\includegraphics[width=\textwidth,height=1cm]{example-image}} \\
\subfloat[caption]{\includegraphics[width=\textwidth,height=1cm]{example-image}}
\end{minipage}

\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}

\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}

\caption{A selection of the slides made during the user study}\label{slides}
\end{figure}
\end{document}

The trick is to use a suitable width, namely slightly less than 1/3 of the text width.

\documentclass{article}
\usepackage{graphicx}

\usepackage{subfig}

\begin{document}

\begin{figure}[htp]

\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image-a}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image-b}}\hfill
\begin{minipage}[b]{.3\textwidth}
\subfloat[caption]{\includegraphics[width=\textwidth,height=1cm]{example-image}} \\
\subfloat[caption]{\includegraphics[width=\textwidth,height=1cm]{example-image}}
\end{minipage}

\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}

\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}

\caption{A selection of the slides made during the user study}\label{slides}

\end{figure}

\end{document}

enter image description here

If you're not tied to subfig for specific reasons of a document class not compatible with caption, I recommend using caption together with subcaption.

\documentclass{article}
\usepackage{graphicx}

\usepackage{caption,subcaption}

\begin{document}

\begin{figure}[htp]

\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image-a}}\hfill
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image-b}}\hfill
\begin{minipage}[b]{.3\textwidth}
\subcaptionbox{caption}{\includegraphics[width=\textwidth,height=1cm]{example-image}}\\[1ex]
\subcaptionbox{caption}{\includegraphics[width=\textwidth,height=1cm]{example-image}}
\end{minipage}

\medskip

\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image}}

\medskip

\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image}}

\caption{A selection of the slides made during the user study}\label{slides}

\end{figure}

\end{document}

enter image description here

egreg
  • 1,121,712