1

i have already searched the internet and the forum for a solution, but unfortunately no post applies to my requests. Also the merging of different posts didn't work out.

The goal is:

  1. 2 png-graphics side by side (here is already the first problem: one is about 703x775 pixel, the other about 1032x493 pixel)
  2. below both graphics there should be one caption each (one shorter, the other longer)
  3. both captions should be at the same height
  4. at the same time the 1032x493 image should be centered and have an adjustable distance to the other image
  5. A third global caption for both images should currently not be included, but can be added at any time (so no subcaptions with a) and b), but rather with "Figure X1" and "FigureX2")
  6. Nevertheless, both images should be adjustable in size

Unfortunately either the captions always shift vertically or the right image is too low or no distance between the images can be adjusted. It would be very nice of you if you can help me =) The following code is my current state:

\documentclass[fontsize=12pt, paper=a4]{scrreprt}
\usepackage{graphicx}

\begin{document}
    \begin{figure}[h!]
        \centering
        \begin{minipage}[b][][t]{0.38\linewidth}
            \centering
            \includegraphics[width=\linewidth]{pictureLeft.png} 
            \caption{Möglicherweise kurzer Text}
        \end{minipage}
        \hspace*{.02\linewidth}
        \begin{minipage}[b][][t]{0.48\linewidth}
            \centering
            \includegraphics[width=\linewidth]{pictureRight.png}
            \caption{Langer Text, der sich über mehrere Zeilen erstreckt und die Überschrift aktuell verschiebt\cite{}}
        \end{minipage}
    \end{figure}
\end{document}
  • Could you please add a sketch of the desired layout to your question? Does replacing \begin{minipage}[b][][t] by \begin{minipage}[t][][t] give your the desired result? See: i.stack.imgur.com/FSluR.png) – leandriis May 23 at 14:39
  • [![enter image description here][1]][1] [1]: i.stack.imgur.com/fBRqS.png This is the desired layout. Unfortunately the option switching from \begin{minipage}[b][][t] to \begin{minipage}[t][][t] didn't work. – Joey May 23 at 16:17
1

like this?

enter image description here

\documentclass[fontsize=12pt, paper=a4]{scrreprt}
\usepackage[demo,  % in real document remove this option
            export]{adjustbox}
\usepackage{tabularx}

\begin{document}
\begin{figure}[h!]
    \centering
\begin{tabularx}{\linewidth}{*{2}{>{\centering\arraybackslash}X}}
\includegraphics[width=\linewidth,valign=c]{pictureLeft.png}
    &
\includegraphics[width=\linewidth,height=5cm,valign=c]{pictureRight.png} \\
%
\caption{Möglicherweise kurzer Text}
    &
\caption{Langer Text, der sich über mehrere Zeilen erstreckt und die Überschrift aktuell verschiebt\cite{}}
    \end{tabularx}
\end{figure}
\end{document}

addendum: alternative solution, which enable simple adjustment of image size with kept image aspect ratio is:

\documentclass[fontsize=12pt, paper=a4]{scrreprt}
\usepackage[export]{adjustbox}
\usepackage{tabularx}

\begin{document}
\begin{figure}[h!]
    \centering
    \setkeys{Gin}{width=\linewidth,keepaspectratio}
\begin{tabular*}{\linewidth}{@{} p{0.4\dimexpr\linewidth-\tabcolsep}
                                  p{0.6\dimexpr\linewidth-\tabcolsep}}
\includegraphics[valign=c]{example-image-duck}
    &
\includegraphics[valign=c]{example-image-duck} \\
%
\caption{Möglicherweise kurzer Text}
    &
\caption{Langer Text, der sich über mehrere Zeilen erstreckt und die Überschrift aktuell verschiebt\cite{}}
    \end{tabular*}
\end{figure}
\end{document}

enter image description here

  • This solution works, i have only a few questions: 1. what kind of column/option is this? : {*{2}{>{\centering\arraybackslash}X}}<br/> 2. is it possible to adjust the gap between the images?<br/> 3. when i do \includegraphics[width=\linewidth,height=5cm,valign=c]{pictureRight.png}, the picture is a little bit distorted, is there a possibility to scale the images, leaving the ratio the same? – Joey May 23 at 16:18
  • @Joey, (i) >{\centering\arraybackslash}X is modified X column type in which cells' contents horizontally centered. (ii) *{2}{...} means two equal column types, (iii) i don't understand what you mean with "distorted" (iv) for details of image settings (width, height, trim, keepaspectrtio see documentation for graphicx package (it is part of your LaTeX installation). The image height is select only to show, how figure will looks if images are not equally high In case that you like to have different with of image, than you can change table specification. see edited answer. – Zarko May 23 at 17:46
  • Distorted meant only that i want to keep the ratio of each image, bad translation sorry^^ thanks a lot for the examples and detailled explanations, you saved my day! – Joey May 24 at 9:22
  • @Joey, does answer solve your problem? if it so, you can accept it by clicking on the check mark at the top left side of answer :-) – Zarko May 24 at 12:13
  • Good point, thank you :-) – Joey May 24 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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