0

I am trying to adjust a figure containing 2 images of different sizes. Is there a way to adjust the left image on the centerline of the template ? I have tried to use the command \centerline but without any result...

enter image description here

\documentclass[french]{beamer}

\usepackage[most]{tcolorbox}

\newcommand\WWider[2][2em]{%
\makebox[\linewidth][c]{%
  \begin{minipage}{\dimexpr\textwidth+#1\relax}
  \raggedright#2
  \end{minipage}%
  }%
}

\begin{document}

\subsection{Etat de l'art}
\begin{frame}{Les précèdents travaux}
 \WWider[2em]{
\begin{figure}    
    \subfloat[{\scriptsize J.Lister, J.Neufeld, JFM (2018)} ] {{\includegraphics[height = 0.35 \textheight,width=0.45 \linewidth ]{pic/ListerExperiment.png} }}%
    \qquad
    \subfloat[{\scriptsize En bleu, les résultats expérimentaux. En rouge, le modèle (PF). En vert, le modèle (VT)}] {{\includegraphics[width=0.45 \linewidth]{pic/BerhanuExperiment.png} }}%
    \end{figure}
    }
\end{frame}

\end{document}

Thank you for your help.

1
  • Your example is not compiling: \usepackage{graphicx} is missing and you should use place holder images like example-image.
    – dexteritas
    Sep 22 at 13:54

2 Answers 2

3

You can use beamer columns to vertically centre the images including their captions.

This will avoid your \WWider workarounds to cause more problems. Beamer columns automatically decrease the width of the margins.

\documentclass[french]{beamer}

\usepackage{subcaption}


\begin{document}

\subsection{Etat de l'art}
\begin{frame}{Les précèdents travaux}
\begin{columns}
\begin{column}{.5\linewidth}
\begin{figure}    
    \subfloat[{\scriptsize J.Lister, J.Neufeld, JFM (2018)} ] {{\includegraphics[height = 0.15 \textheight,width=\linewidth ]{example-image} }}%
    \end{figure}
\end{column}
\begin{column}{.5\linewidth}
\begin{figure}
\phantomsubcaption
\subfloat[{\scriptsize En bleu, les résultats expérimentaux. En rouge, le modèle (PF). En vert, le modèle (VT)}] {{\includegraphics[width=\linewidth]{example-image} }}%
\end{figure}
\end{column}
\end{columns}
\end{frame}

\end{document}

enter image description here

2

Load adjustbox after graphicx with [export] and add the option valign=c to \includegraphics if you want only images themselves to be aligned by their middle points (excluding sub-caption).

enter image description here

However, if you want to align images including their sub-captions, just insert each \subfloat into a separate \parbox

enter image description here

Multi-lined sub-captions can also be changed to using hanging format; this is set by \captionsetup in case you would prefer that.


Code for the first example

\documentclass[french]{beamer}
\usepackage[export]{adjustbox}
\usepackage[most]{tcolorbox}
\usepackage{subfig}
\captionsetup{format=hang}

\begin{document}

\subsection{Etat de l'art}
\begin{frame}{Les précèdents travaux}
  \begin{figure}
    \subfloat[\scriptsize J.Lister, J.Neufeld, JFM (2018)]%
      {\includegraphics[
        height=0.25\textheight,
        width=0.45\linewidth,
        valign=c,
      ]{example-image}}%
    \hfill%
    \subfloat[\scriptsize En bleu, les résultats expérimentaux. En rouge, le modèle (PF). En vert, le modèle (VT)]%
      {\includegraphics[
        width=0.45\linewidth,
        valign=c,
      ]{example-image}}
  \end{figure}
\end{frame}

\end{document}

A snippet for figure environment for the second example (the rest of the code is the same)

  \begin{figure}
    \parbox{0.45\linewidth}{%
      \subfloat[\scriptsize J.Lister, J.Neufeld, JFM (2018)]%
        {\includegraphics[
        height=0.25\textheight,
        width=\linewidth,
      ]{example-image}}
    }%
    \hfill%
    \parbox{0.45\linewidth}{%
      \subfloat[\scriptsize En bleu, les résultats expérimentaux. En rouge, le modèle (PF). En vert, le modèle (VT)]%
        {\includegraphics[
        width=\linewidth,
      ]{example-image}}}
  \end{figure}
3

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