7

I have two subfigures that I want to align as such: Ideal Layout

But what I got is this with the codes below: Actual Layout

\documentclass{book}
\usepackage{subcaption}
\usepackage{pdfpages}

\begin{document}
\begin{figure}[!htb]
    \centering
    \begin{tabular}[t]{cc}
        \begin{tabular}[t]{c}
            \begin{subfigure}[t]{0.4\textwidth}
                \includegraphics[width=0.9\textwidth]{"fig/example/cat_tall"} 
                \caption{Cat 1} 
            \end{subfigure} 
        \end{tabular}
        &
        \begin{tabular}[t]{c}
            \begin{subfigure}[t]{0.4\textwidth}
                \centering
                \includegraphics[width=0.9\textwidth]{"fig/example/cat1"}
                \caption{Cat 2}
            \end{subfigure} 
            \\
            \begin{subfigure}[t]{0.4\textwidth}
                \centering
                \includegraphics[width=0.9\textwidth]{"fig/example/cat2"}
                \caption{Cat 3} 
            \end{subfigure}
        \end{tabular}
    \end{tabular}
    \caption{Cats}
\end{figure}
\end{document}
tuzzer
  • 173
  • Welcome to SE! Pleas add to your code sniped documentclass and used package and make it compilable. The cats are cute ... – Zarko Jan 09 '16 at 01:10

1 Answers1

9

You nested tabular ... if you omit the first, the cute cats appear in the image as you desired.

\documentclass{article}
    \usepackage{caption}
    \usepackage{subcaption}
    \usepackage{graphicx}

\usepackage[active,floats,tightpage]{preview}
    \setlength\PreviewBorder{1em}

    \begin{document}
\begin{figure}[!htb]
    \centering
    \begin{tabular}[t]{|c|c|}
    \hline
\begin{subfigure}{0.4\textwidth}
    \centering
    \smallskip
    \includegraphics[width=0.9\linewidth,height=1.7\textwidth]{example-image-a}
    \caption{Cat 1} %{Light Unit}
\end{subfigure}
    &
        \begin{tabular}{c}% if you add [t], than sub images are pushed down
        \smallskip
            \begin{subfigure}[t]{0.4\textwidth}
                \centering
                \includegraphics[width=0.9\textwidth]{example-image-b}
                \caption{Cat 2}
            \end{subfigure}\\
            \begin{subfigure}[t]{0.4\textwidth}
                \centering
                \includegraphics[width=0.9\textwidth]{example-image-c}
                \caption{Cat 3}
            \end{subfigure}
        \end{tabular}\\
\hline
    \end{tabular}
    \caption{Cats}
\end{figure}
    \end{document}

Unfortunately I haven't pictures of cats, so instead of them I use example image from `graphics package and guess about cats heights. Lines in table are added only for orientation to see sub images positions. In final use they should be omitted

enter image description here

Edit: If you add option `[t] to inner table, it will push right sub images down as can be seen on second image (where the height is increased that this can be noticed)

enter image description here

Zarko
  • 296,517
  • There's a picture of a tiger in all standard TeX distributions. Or I provide some cat code here (at the end). – cfr Jan 09 '16 at 01:35
  • @cfr, your cat is nice, but code is very complex. This time I will not include it in answer, however, I will make standalone picture for its use in future! – Zarko Jan 09 '16 at 01:43
  • Thanks! Actually at first, I didn't have the nested tabular for the "cat_tall" image; that wasn't the problem. I compared your code to mine. I realized that the part that made the difference was the "[t]" after the first "\begin{subfigure}". If I remove that the cat pictures appear as I intended! – tuzzer Jan 09 '16 at 01:45
  • It was not a serious suggestion. However, the tiger is quite useful in examples. – cfr Jan 09 '16 at 01:47
  • About tiger: Thank you for information. I unsuccessful search in my MikTeX installation, can me give tip, how to find it? – Zarko Jan 09 '16 at 01:50