1

I want two pictures next to another big one and every picture has a different size (like the example below).

enter image description here

I want that all pictures keep their aspect ratio and the pictures to the right should have the same height. Also all 3 pictures should be as wide as the \textwidth.

I've tried subfigure and \resizebox, but I could not set the right heights dependent on the height of the left picture. Manually trying to fit all the sizes is way too tedious, is there an easy way to do that?

Edit: Here are more informations for my problem. My current code looks like this. I've just adjustet the sizes of the pictures until they fit (trial end error). A very tedious process.

The pictures have individual caption with (a), (b) and (c) and the whole picture has another caption.

It would be nice to manage the size of the right pictures so that they are not bigger than the left one and that alle 3 pictures don't exceed the linewitdh.

\begin{figure}[H]
\centering
\begin{subfigure}[p]{.45\textwidth}
    \includegraphics[height=\textheight]{MMC.eps}
    \caption{MMC Schaltbild, \cite{Eremia.2016}} \label{fig:ch2_MMC
\end{subfigure}
\qquad
\begin{subfigure}[p]{.45\textwidth}
    \centering
    \includegraphics[height=0.39\textheight]{Halfbridge.eps}
    \caption{Halfbridge, \cite{Shah.17.07.201621.07.2016}} \label{fig:ch2_Halfbridge}

    \vspace{2ex}

    \includegraphics[height=0.39\textheight]{Fullbridge.eps}
    \caption{Fullbridge, \cite{Shah.17.07.201621.07.2016}} \label{fig:ch2_Fullfbridge}
\end{subfigure}
\caption{MMC and Submodule}\end{figure}
  • 1
    Welcome to TeX.SE! It is not fun to write code from scratch again, which you already write to to produce the showed image. Please, be so kind and share it to as. Please help us to help you. – Zarko Dec 26 '19 at 11:48
  • 1
    Are the captions individual captions (figure 1, figure 2...) or subcaptions (figure1a, figure 1b...)? – leandriis Dec 26 '19 at 11:51
  • This question needs more work; please add code that attempts to answer the question, and a clearer notion of the result you want. – Benjamin McKay Dec 26 '19 at 12:20
  • this meets your requirement-------tex.stackexchange.com/a/302138/197451 – js bibra Dec 26 '19 at 15:16
1

If we denote by

  • a and b the width and height of the picture on the left,
  • c and d the width and height of the picture on the top right,
  • e and f the width and height of the picture on the bottom right,
  • v the the gap between the picture on the right,
  • w the desired total width (a tad less than \textwidth),

we can denote by x, y and z the required scale factors for the three pictures (left, top right and bottom right). Then solving the linear system yields

x = (2​fw + ev)/(be + 2​af)
y = (bfw - afv)/(bde + 2​adf)
z = (bw - av)/(be + 2​af)

The obvious limitation is that the second and third scaling factors are positive.

Here's an implementation.

\documentclass{article}
\usepackage{graphicx,xfp}

\begin{document}

\begin{figure}

\sbox0{\includegraphics{example-image-a}}
\sbox2{\includegraphics{example-image-1x1}}
\sbox4{\includegraphics{example-image-b}}

\edef\Da{\fpeval{\wd0}}\edef\Db{\fpeval{\ht0}}
\edef\Dc{\fpeval{\wd2}}\edef\Dd{\fpeval{\ht2}}
\edef\De{\fpeval{\wd4}}\edef\Df{\fpeval{\ht4}}

\edef\Dv{\fpeval{8ex}}
\edef\Dw{\fpeval{\textwidth-3em}}

\edef\Dx{\fpeval{(2*\Df*\Dw + \De*\Dv)/(\Db*\De + 2*\Da*\Df)}}
\edef\Dy{\fpeval{(\Db*\Df*\Dw - \Da*\Df*\Dv)/(\Db*\Dd*\De + 2*\Da*\Dd*\Df)}}
\edef\Dz{\fpeval{(\Db*\Dw - \Da*\Dv)/(\Db*\De + 2*\Da*\Df)}}

\sbox{0}{%
  \begin{minipage}[b]{\fpeval{\Da*\Dx}pt}
  \vspace{0pt}
  \scalebox{\Dx}{\box0}
  \caption{First pic}
  \end{minipage}%
}\usebox{0}\hfill
\begin{minipage}[b][\ht0][s]{\fpeval{\Dw-\Da*\Dx}pt}
\centering
\vspace{0pt}
\scalebox{\Dy}{\box2}
\caption{Second pic}

\vfill

\scalebox{\Dz}{\box4}
\caption{Third pic}
\end{minipage}

\end{figure}

\end{document}

enter image description here

If you want subfigures, substitute minipage with subfigure.

\documentclass{article}
\usepackage{graphicx,xfp,subcaption}

\begin{document}

\begin{figure}

\sbox0{\includegraphics{example-image-a}}
\sbox2{\includegraphics{example-image-1x1}}
\sbox4{\includegraphics{example-image-b}}

\edef\Da{\fpeval{\wd0}}\edef\Db{\fpeval{\ht0}}
\edef\Dc{\fpeval{\wd2}}\edef\Dd{\fpeval{\ht2}}
\edef\De{\fpeval{\wd4}}\edef\Df{\fpeval{\ht4}}

\edef\Dv{\fpeval{8ex}}
\edef\Dw{\fpeval{\textwidth-3em}}

\edef\Dx{\fpeval{(2*\Df*\Dw + \De*\Dv)/(\Db*\De + 2*\Da*\Df)}}
\edef\Dy{\fpeval{(\Db*\Df*\Dw - \Da*\Df*\Dv)/(\Db*\Dd*\De + 2*\Da*\Dd*\Df)}}
\edef\Dz{\fpeval{(\Db*\Dw - \Da*\Dv)/(\Db*\De + 2*\Da*\Df)}}

\sbox{0}{%
  \begin{subfigure}[b]{\fpeval{\Da*\Dx}pt}
  \vspace{0pt}
  \scalebox{\Dx}{\box0}
  \caption{First pic}
  \end{subfigure}%
}\usebox{0}\hfill
\begin{subfigure}[b][\ht0][s]{\fpeval{\Dw-\Da*\Dx}pt}
\centering
\vspace{0pt}
\scalebox{\Dy}{\box2}
\caption{Second pic}

\vfill

\scalebox{\Dz}{\box4}
\caption{Third pic}
\end{subfigure}

\caption{Global caption}

\end{figure}

\end{document}

enter image description here

|improve this answer|||||
  • Wow, very impressive solution. It works very well thanks. I've got just one question. Is it possible to treat the pictures as subpictures so that they get the same caption number followed by the according letter (a), (b) and (c)? – Daniel Dec 30 '19 at 8:20
  • @Daniel Added the trick. – egreg Dec 30 '19 at 22:21
1

an @egreg solution--https://tex.stackexchange.com/a/87976/197451

You can use some minipage environment and \sbox to measure the height of the biggest box.

Notice that I've used subfig and not the obsolete subfigure. Also subcaption can be a choice and should if you use hyperref.

The demo option to graphicx is just to produce some mock pictures; I gave them a height to show the example.

enter image description here

\documentclass{article}
\usepackage{subfig}
\documentclass{article}
\usepackage{subfig}
\usepackage[demo]{graphicx}

\newsavebox{\measurebox}

\begin{document}

\begin{figure}
\centering
\sbox{\measurebox}{%
  \begin{minipage}[b]{.33\textwidth}
  \subfloat
    []
    {\label{fig:figA}\includegraphics[width=\textwidth,height=5cm]{figA}}
  \end{minipage}}
\usebox{\measurebox}\qquad
\begin{minipage}[b][\ht\measurebox][s]{.33\textwidth}
\centering
\subfloat
  []
  {\label{fig:figB}\includegraphics[width=\textwidth,height=2cm]{figB}}

\vfill

\subfloat
  []
  {\label{fig:figC}\includegraphics[width=\textwidth,height=2cm]{figC}}
\end{minipage}
\caption{my caption. (a) is .... (b) is .... (c) is ....}
\label{fig:Test}
\end{figure}
\end{document}
|improve this answer|||||

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