[Tex/LaTex] Three images on one line using subfigure

floatssubcaptionsubfloats

I'm trying to put 3 images into one figure on one line. I have done the following approach:

\documentclass[sigconf]{acmart}
\usepackage{subcaption}

\begin{document}

\begin{figure*}
  \begin{subfigure}{0.33\textwidth}
  \includegraphics[width=0.33\textwidth]{1}
  \caption{}
  \label{fig:3_classes}
  \end{subfigure}
  \begin{subfigure}{0.33\textwidth}
  \includegraphics[width=0.33\textwidth]{1}
  \caption{}
  \label{fig:5_classes}
  \end{subfigure}
    \begin{subfigure}{0.33\textwidth}
  \includegraphics[width=0.33\textwidth]{1}
  \caption{}
  \label{fig:6_classes}
  \end{subfigure}\par\medskip
    \caption{This is a test.}
\end{figure*}

\end{document}

The image 1.png is available on onedrive: https://1drv.ms/u/s!AlkQuYgB1McYg8xUxUYxiZlhf9b6Ww

The problem is that I'm getting the following results. The captions are ok but the images are really small and somehow left alligned. I would like to have the images as large as possible so that they fit on one line.

Is this possible?

enter image description here

Best Answer

It's often better to use \linewidth to measure the width of the current "block" rather than \textwidth. While you think \textwidth refers to the entire width of the text block and therefore 0.33\textwidth should refer to (roughly) 1/3 of the text block, it doesn't. Under the subfigure environment, \textwidth is updated (actually setting it's contents inside a minipage which updates \textwidth) and doesn't represent what it stands for originally. You're effectively looking at an image that has a width of 0.33 x 0.33 x \textwidth or about 1/10 of the text width.

enter image description here

\documentclass[sigconf]{acmart}

\usepackage{subcaption}

\begin{document}

\begin{figure*}
  \begin{subfigure}{0.33\textwidth}
    \includegraphics[width=\linewidth]{example-image-a}
    \caption{}
    \label{fig:figure1}
  \end{subfigure}%
  \hfill
  \begin{subfigure}{0.33\textwidth}
    \includegraphics[width=\linewidth]{example-image-b}
    \caption{}
    \label{fig:figure2}
  \end{subfigure}%
  \hfill
  \begin{subfigure}{0.33\textwidth}
    \includegraphics[width=\linewidth]{example-image-c}
    \caption{}
    \label{fig:figure3}
  \end{subfigure}
  \caption{This is a test.}
\end{figure*}

\end{document}
Related Question