[Tex/LaTex] How to reduce the space between two figures side by side

spacingsubcaptionsubfloats

I would like to reduce the space between two figure that are side by side. I am using the following code but I don't know how to do that.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{caption}


\begin{document}



\begin{figure}
  \begin{subfigure}[tbp]{0.3\textwidth}
    \includegraphics[width=\textwidth]{img1}
    \caption{traditional.}
     \label{fig:atzeni_trad}
  \end{subfigure}
  %
  \begin{subfigure}[tbp]{0.4\textwidth}
    \includegraphics[width=\textwidth]{img2}
    \caption{SLS}
    \label{fig:atzeni_sls}
  \end{subfigure}
  \caption[.]{Fluoriscent lamp holder. Traditional on left-side, CAD redesigned centered, and SLS manufactured on right-side}
  \label{fig:lamp}
\end{figure}


\end{document}

Moreover, do you know how to have the caption of each of the figure at the same hight?

Best Answer

A negative \hskip in between reduces the space. Shifting from [tbp] to [b] aligns the subfigures entirely at their bottoms, including aligning the captions at the bottom. But this also aligns the images at their bottoms; I don't know if you mind this or not.

Here's the modified source; you can change -2ex to whatever distance you want.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{caption}

\begin{document}

\begin{figure}
  \begin{subfigure}[b]{0.3\textwidth}
    \includegraphics[width=\textwidth]{img1}
    \caption{traditional.}
    \label{fig:atzeni_trad}
  \end{subfigure}
  \hskip -2ex
  \begin{subfigure}[b]{0.4\textwidth}
    \includegraphics[width=\textwidth]{img2}
    \caption{SLS}
    \label{fig:atzeni_sls}
  \end{subfigure}
  \caption[.]{Fluoriscent lamp holder. Traditional on left-side, CAD redesigned centered, and SLS manufactured on right-side}
  \label{fig:lamp}
\end{figure}

\end{document}

If you want to align captions without aligning the pictures, I think you want \subcaptionbox. Here's an example:

\begin{figure}    
    \subcaptionbox{traditional.\label{fig:atzeni_trad}}[0.3\textwidth]{\includegraphics[width=0.3\textwidth]{img1}}
    \hskip -2ex
    \subcaptionbox{SLS\label{fig:atzeni_sls}}[0.4\textwidth]{\vspace*{3em}\includegraphics[width=0.4\textwidth]{img2}}
    \caption[.]{Fluoriscent lamp holder. Traditional on left-side, CAD redesigned centered, and SLS manufactured on right-side}
    \label{fig:lamp}
\end{figure}

In this case, I've moved the second image up with \vspace*{}, but of course you can move it however you prefer. Note as well that \textwidth is not redefined inside a subcaptionbox, so the width argument to \includegraphics has changed.

Related Question