0

I would like to know how we can put images side by side like here as in Figure 4. The images are attached very closely. From my internet search, I found only solutions that putting images side by side but with some small gaps in betweeen, which what I don't want. Below is the MWE of what I've tried:

\documentclass[a4paper, 10pt, conference]{ieeeconf}
\usepackage[style=base]{caption}
\usepackage{subcaption}

\begin{figure*}[tp]
  % \centering
  \begin{subfigure}[h]{0.1\textwidth}\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig1.jpg}\label{fig:fig1}
    \end{subfigure}
  \begin{subfigure}[h]{0.1\textwidth}\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig2.jpg}\label{fig:fig2}
    \end{subfigure}\\
  \begin{subfigure}[h]{0.1\textwidth}\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig3.jpg}\label{fig:fig3}
    \end{subfigure}
  \begin{subfigure}[h]{0.1\textwidth}\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig4.jpg}\label{fig:fig4}
    \end{subfigure}
\end{figure*}

\end{document}
14
  • you should provide a MWE, that we can show, how to do this. It should be simple \includegraphics{image-1}\includegraphics{image-2} ...
    – Zarko
    Mar 14, 2017 at 22:02
  • Just don't leave a space. Did you try it? Why would this be a problem?
    – cfr
    Mar 14, 2017 at 22:59
  • @Zarko: I've added the WME accordingly.
    – alfa_80
    Mar 15, 2017 at 8:40
  • @cfr: Thanks for the idea, I've tried but didn't work.
    – alfa_80
    Mar 15, 2017 at 8:41
  • 1
    First, a subfigure is basically a minipage, so no [h] option. Second without a caption, there are no counters for \label to reference. Mar 15, 2017 at 15:29

1 Answer 1

1

This solution measures the images using \sbox and uses that width as the width of the subfigure. An easier solution would be to not use subfigures.

Note: (almost) every time you end a line with a brace you add a space.

\documentclass[a4paper, 10pt, conference]{ieeeconf}
\usepackage[draft]{graphicx}
\usepackage[style=base]{caption}
\usepackage{subcaption}

\begin{document}
\begin{figure*}[tp]
  % \centering
  \sbox0{\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig1.jpg}}%
  \sbox1{\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig2.jpg}}%
  \begin{subfigure}{\wd0}\usebox0\end{subfigure}%
  \begin{subfigure}{\wd1}\usebox1\end{subfigure}\\
  \sbox0{\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig3.jpg}}%
  \sbox1{\includegraphics[width=2cm,height=3cm,keepaspectratio]{fig4.jpg}}%
  \begin{subfigure}{\wd0}\usebox0\end{subfigure}%
  \begin{subfigure}{\wd1}\usebox1\end{subfigure}
\end{figure*}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .