1

My question is very similar to this one: Sub-figures of different sizes grid layout

However, I can't use the subcaption package (I am using subfigure) and I also do not want them to have captions, so if I can avoid using subfigure at all maybe it would be better?

This is the output that I need:

enter image description here

I tried using the code from this answer by Zarko but I could not get it to work.

\begin{figure}[!htb]
    \centering
    \begin{tabular}[t]{cc}
    \includegraphics[width=0.32\linewidth,height=1.7\textwidth]{example-image-a}
    &
        \begin{tabular}{c}
        \smallskip
        \includegraphics[width=0.32\textwidth]{example-image-b}
        \includegraphics[width=0.32\textwidth]{example-image-c}
        \end{tabular}\\
    \end{tabular}
    \caption{Cats}
\end{figure}

Do note that this code is only for the first two columns, I have not yet tried to add the last one.

Edit: My current attempt is the following (the tabular lines are just for reference):

\begin{figure}[!htb]
    \centering
    \setkeys{Gin}{width=\linewidth}
    \begin{tabular}{|c|c|c|}
    \hline
    \multirow{2}{*}{\includegraphics[width=0.3\linewidth, valign=m]{example-image-a}} &
    \includegraphics[width=0.25\linewidth, valign=m]{example-image-b} &
    \multirow{2}{*}{\includegraphics[width=0.4\linewidth, valign=m]{example-image-c}}
    \\ \hline
    & \includegraphics[width=0.25\linewidth, valign=m]{example-image-c} & \\
    \\ \hline
    \end{tabular}
\end{figure}

enter image description here

Edit 2: Using Zarko's answer and changing each width is making the images very small:

\begin{figure}[!htb]
    \centering
\setkeys{Gin}{width=\linewidth}
\setlength\tabcolsep{0pt}
\begin{tblr}[t]{colspec={*{3}{X[c,m]}},
                cell{1}{1,3} = {r=2}{ }
                }
\includegraphics[width=0.3\linewidth, valign=m]{example-image-a}
    &   \includegraphics[width=0.15\linewidth, valign=m]{example-image-b}
        &   \includegraphics[width=0.4\linewidth, valign=m]{example-image-c} \\
    &   \includegraphics[width=0.15\linewidth,valign=m]{example-image-b}
        &   \\
    \end{tblr}
    \caption{Cats}
\end{figure}

enter image description here

  • And what is now the problem? – Zarko Oct 09 '22 at 19:04
  • @Zarko In my solution using multirow, the dimensions are correct but the last column is misaligned vertically. In the solution adapted from your answer, the images are all too small, as they do not occupy the whole space (0.4\linewidth, 0.15\linewidth, and 0.3\linewidth). – João David Oct 09 '22 at 19:06
  • I still guessing what you after. Your use of my code is wrong. See edit of ma answer, – Zarko Oct 09 '22 at 19:16
  • @Zarko it was exactly that, I am not familiar with the tabularray package. Thank you. – João David Oct 09 '22 at 19:24
  • 1
    tabularray package is very powerful and it is worth to make yourself more familiar with it. It has good, concise documentation with a lot of examples. – Zarko Oct 09 '22 at 19:26

1 Answers1

2

Try the following:

\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{tabularray}

\begin{document} \begin{figure}[!htb] \centering \setkeys{Gin}{width=\linewidth} \begin{tblr}[t]{colspec={*{3}{X[c,m]}}, cell{1}{1,3} = {r=2}{ } % <--- define multirow cells } \includegraphics[height=1.5\linewidth, valign=m]{example-image-a} & \includegraphics[valign=m]{example-image-b} & \includegraphics[height=1.5\linewidth, valign=m]{example-image-c} \ & \includegraphics[valign=m]{example-image-b} & \ \end{tblr} \caption{Cats} \end{figure} \end{document}

enter image description here

Edit: From edited question, where you change desired appearance of images, now I guess, that you looking for something like this:

enter image description here

\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{tabularray}

\begin{document} \begin{figure}[!htb] \centering \setkeys{Gin}{width=\linewidth} \begin{tblr}[t]{colspec={Q[c,m, wd=0.3\linewidth] Q[c,m, wd=0.25\linewidth] Q[c,m, wd=0.4\linewidth] }, cell{1}{1,3} = {r=2}{ } % <--- define multirow cells } \includegraphics[valign=m]{example-image-a} & \includegraphics[valign=m]{example-image-b} & \includegraphics[valign=m]{example-image-c} \ & \includegraphics[valign=m]{example-image-b} & \ \end{tblr} \caption{Cats} \end{figure} \end{document}

Zarko
  • 296,517
  • I got a LaTeX error: File 'tabulararray.sty' not found. Is it possible to do this with multirow instead? I have been trying but everything is misaligned vertically. – João David Oct 09 '22 at 17:49
  • Just instal this package! – Zarko Oct 09 '22 at 17:56
  • Seems like I just imported it wrongly, it works. Could you explain why the \setkeys{Gin}{width=\linewidth} is necessary? Also, can I specify the proportions based on width? I want 0.3\linewidth for the first column, 0.15\linewidth for the middle column, and 0.4\linewidth for the last one. – João David Oct 09 '22 at 18:06
  • 1
    All, what you now explain in comment, is not present in question. I show you a skeleton, how you can solve your šproblem, in it you can change options as you wish. Keys Gin˛ is not needed, you can write desired image width in \includegraphics options. But in case, when width of all image is the same (as can be understand from your question) with its use, the code is quite shorter. – Zarko Oct 09 '22 at 18:22
  • I apologize, some images are too small using the same width for all columns, which I did not anticipate. When I change the width of each column, each image becomes very small. I updated my question with an example to demonstrate this. – João David Oct 09 '22 at 18:34